/[gentoo-x86]/eclass/ruby-fakegem.eclass
Gentoo

Diff of /eclass/ruby-fakegem.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.7
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.1 2009/12/14 12:32:18 a3li Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-fakegem.eclass,v 1.7 2009/12/21 19:07:38 flameeyes Exp $
4# 4#
5# @ECLASS: ruby-fakegem.eclass 5# @ECLASS: ruby-fakegem.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ruby herd <ruby@gentoo.org> 7# Ruby herd <ruby@gentoo.org>
8# 8#
29# RUBY_FAKEGEM_VERSION="${PV}" 29# RUBY_FAKEGEM_VERSION="${PV}"
30 30
31# @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_DOC 31# @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_DOC
32# @DESCRIPTION: 32# @DESCRIPTION:
33# Specify the rake(1) task to run to generate documentation. 33# Specify the rake(1) task to run to generate documentation.
34# RUBY_FAKEGEM_VERSION="rdoc" 34# RUBY_FAKEGEM_TASK_DOC="rdoc"
35 35
36# @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_TEST 36# @ECLASS-VARIABLE: RUBY_FAKEGEM_TASK_TEST
37# @DESCRIPTION: 37# @DESCRIPTION:
38# Specify the rake(1) task used for executing tests. 38# Specify the rake(1) task used for executing tests.
39# RUBY_FAKEGEM_VERSION="test" 39# RUBY_FAKEGEM_TASK_TEST="test"
40
41# @ECLASS-VARIABLE: RUBY_FAKEGEM_DOCDIR
42# @DESCRIPTION:
43# Specify the directory under which the documentation is built;
44# if empty no documentation will be installed automatically.
45# RUBY_FAKEGEM_DOCDIR=""
46
47# @ECLASS-VARIABLE: RUBY_FAKEGEM_EXTRADOC
48# @DESCRIPTION:
49# Extra documentation to install (readme, changelogs, …).
50# RUBY_FAKEGEM_EXTRADOC=""
51
52# @ECLASS-VARIABLE: RUBY_FAKEGEM_BINWRAP
53# @DESCRIPTION:
54# Binaries to wrap around (relative to the bin/ directory)
55# RUBY_FAKEGEM_BINWRAP="*"
40 56
41RUBY_FAKEGEM_NAME="${RUBY_FAKEGEM_NAME:-${PN}}" 57RUBY_FAKEGEM_NAME="${RUBY_FAKEGEM_NAME:-${PN}}"
42RUBY_FAKEGEM_VERSION="${RUBY_FAKEGEM_VERSION:-${PV}}" 58RUBY_FAKEGEM_VERSION="${RUBY_FAKEGEM_VERSION:-${PV}}"
43 59
44RUBY_FAKEGEM_TASK_DOC="${RUBY_FAKEGEM_TASK_DOC-rdoc}" 60RUBY_FAKEGEM_TASK_DOC="${RUBY_FAKEGEM_TASK_DOC-rdoc}"
45RUBY_FAKEGEM_TASK_TEST="${RUBY_FAKEGEM_TASK_TEST-test}" 61RUBY_FAKEGEM_TASK_TEST="${RUBY_FAKEGEM_TASK_TEST-test}"
62
63RUBY_FAKEGEM_BINWRAP="${RUBY_FAKEGEM_BINWRAP-*}"
46 64
47if [[ ${RUBY_FAKEGEM_TASK_DOC} != "" ]]; then 65if [[ ${RUBY_FAKEGEM_TASK_DOC} != "" ]]; then
48 IUSE="$IUSE doc" 66 IUSE="$IUSE doc"
49 ruby_add_bdepend doc "dev-ruby/rake" 67 ruby_add_bdepend doc "dev-ruby/rake"
50fi 68fi
51 69
52if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then 70if [[ ${RUBY_FAKEGEM_TASK_TEST} != "" ]]; then
53 IUSE="$IUSE test" 71 IUSE="$IUSE test"
54 ruby_add_bdepend test "dev-ruby/rake" 72 ruby_add_bdepend test "dev-ruby/rake"
55fi 73fi
74
75SRC_URI="mirror://rubygems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}.gem"
56 76
57ruby_add_rdepend virtual/rubygems 77ruby_add_rdepend virtual/rubygems
58 78
59# @FUNCTION: ruby_fakegem_gemsdir 79# @FUNCTION: ruby_fakegem_gemsdir
60# @RETURN: Returns the gem data directory 80# @RETURN: Returns the gem data directory
136# path defaults to /usr/bin/$command 156# path defaults to /usr/bin/$command
137ruby_fakegem_binwrapper() { 157ruby_fakegem_binwrapper() {
138 ( 158 (
139 local gembinary=$1 159 local gembinary=$1
140 local newbinary=${2:-/usr/bin/$gembinary} 160 local newbinary=${2:-/usr/bin/$gembinary}
161 local relativegembinary=${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin/${gembinary}
141 162
142 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF 163 cat - > "${T}"/gembin-wrapper-${gembinary} <<EOF
143#!/usr/bin/env ruby 164#!/usr/bin/env ruby
144# This is a simplified version of the RubyGems wrapper 165# This is a simplified version of the RubyGems wrapper
145# 166#
146# Generated by ruby-fakegem.eclass 167# Generated by ruby-fakegem.eclass
147 168
148require 'rubygems' 169require 'rubygems'
149 170
150load Gem::GemPathSearcher.new.find('$(tr [A-Z] [a-z] <<< ${RUBY_FAKEGEM_NAME})').full_gem_path + "/bin/${gembinary}" 171load Gem::default_path[-1] + "/gems/${relativegembinary}"
151 172
152EOF 173EOF
153 174
154 exeinto $(dirname $newbinary) 175 exeinto $(dirname $newbinary)
155 newexe "${T}"/gembin-wrapper-${gembinary} $(basename $newbinary) 176 newexe "${T}"/gembin-wrapper-${gembinary} $(basename $newbinary)
244# @FUNCTION: all_fakegem_install 265# @FUNCTION: all_fakegem_install
245# @DESCRIPTION: 266# @DESCRIPTION:
246# Install files common to all ruby targets. 267# Install files common to all ruby targets.
247all_fakegem_install() { 268all_fakegem_install() {
248 if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && use doc; then 269 if [[ -n ${RUBY_FAKEGEM_DOCDIR} ]] && use doc; then
249 pushd ${RUBY_FAKEGEM_DOCDIR} 270 for dir in ${RUBY_FAKEGEM_DOCDIR}; do
271 pushd ${dir}
250 dohtml -r * || die "failed to install documentation" 272 dohtml -r * || die "failed to install documentation"
251 popd 273 popd
274 done
252 fi 275 fi
253 276
254 if [[ -n ${RUBY_FAKEGEM_EXTRADOC} ]]; then 277 if [[ -n ${RUBY_FAKEGEM_EXTRADOC} ]]; then
255 dodoc ${RUBY_FAKEGEM_EXTRADOC} || die "failed to install further documentation" 278 dodoc ${RUBY_FAKEGEM_EXTRADOC} || die "failed to install further documentation"
279 fi
280
281 # binary wrappers; we assume that all the implementations get the
282 # same binaries, or something is wrong anyway, so...
283 if [[ -n ${RUBY_FAKEGEM_BINWRAP} ]]; then
284 local bindir=$(find "${D}" -type d -path "*/gems/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}/bin" -print -quit)
285
286 if [[ -d "${bindir}" ]]; then
287 pushd "${bindir}"
288 local binaries=$(eval ls ${RUBY_FAKEGEM_BINWRAP})
289 for binary in $binaries; do
290 ruby_fakegem_binwrapper $binary
291 done
292 popd
293 fi
256 fi 294 fi
257} 295}
258 296
259# @FUNCTION: all_ruby_install 297# @FUNCTION: all_ruby_install
260# @DESCRIPTION: 298# @DESCRIPTION:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.20