1 | # Copyright 1999-2005 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/Attic/gems.eclass,v 1.3 2005/03/31 00:47:05 pythonhead Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/Attic/gems.eclass,v 1.32 2009/11/29 19:10:01 flameeyes Exp $ |
|
|
4 | |
|
|
5 | # @ECLASS: gems.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # ruby@gentoo.org |
4 | # |
8 | # |
5 | # Author: Rob Cakebread <pythonhead@gentoo.org> |
9 | # Original Author: Rob Cakebread <pythonhead@gentoo.org> |
6 | # Current Maintainer: Rob Cakebread <pythonhead@gentoo.org> |
|
|
7 | # |
10 | # |
8 | # The gems eclass is designed to allow easier installation of |
11 | # @BLURB: Eclass helping with the installation of RubyGems |
9 | # gems-based ruby packagess and their incorporation into |
12 | # @DESCRIPTION: |
10 | # the Gentoo Linux system. |
|
|
11 | # |
|
|
12 | # - Features: |
|
|
13 | # gems_location() - Set ${GEMSDIR} with gem install dir and ${GEM_SRC} with path to gem to install |
|
|
14 | # gems_src_install() - installs a gem into ${D} |
|
|
15 | # gems_src_unpack() - Does nothing. |
|
|
16 | # gems_src_compile() - Does nothing. |
|
|
17 | # |
|
|
18 | # NOTE: |
|
|
19 | # See http://dev.gentoo.org/~pythonhead/ruby/gems.html for notes on using gems with portage |
13 | # See http://dev.gentoo.org/~pythonhead/ruby/gems.html for notes on using gems with Portage. |
20 | |
14 | |
|
|
15 | # @ECLASS-VARIABLE: USE_RUBY |
|
|
16 | # @DESCRIPTION: |
|
|
17 | # Ruby versions the gem is compatible to. The eclass will install the gem for |
|
|
18 | # versions that are compatible and installed on the system. Format: rubyDD where |
|
|
19 | # DD is the two-digit version suffix (e.g.: USE_RUBY="ruby19" for Ruby 1.9.1) |
21 | |
20 | |
22 | inherit ruby eutils |
21 | inherit eutils ruby |
23 | |
22 | |
24 | ECLASS=gems |
23 | SRC_URI="mirror://rubygems/${P}.gem" |
25 | INHERITED="$INHERITED $ECLASS" |
|
|
26 | |
24 | |
27 | DEPEND=">=dev-ruby/rubygems-0.8.4-r1" |
25 | IUSE="doc" |
28 | |
26 | |
29 | S=${WORKDIR} |
27 | DEPEND=" |
|
|
28 | || ( >=dev-ruby/rubygems-1.3.1 =dev-lang/ruby-1.9* ) |
|
|
29 | !<dev-ruby/rdoc-2 |
|
|
30 | " |
|
|
31 | RDEPEND="${DEPEND}" |
30 | |
32 | |
31 | |
33 | # @FUNCTION: gems_location |
|
|
34 | # @USAGE: [Ruby binary] |
|
|
35 | # @DESCRIPTION: |
|
|
36 | # Exports GEMSDIR to the path Gems are installed to for the respective Ruby |
|
|
37 | # version |
32 | gems_location() { |
38 | gems_location() { |
33 | local sitelibdir |
39 | local ruby_version |
34 | sitelibdir=`ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]'` |
40 | if [[ -z "$1" ]]; then |
35 | export GEMSDIR=${sitelibdir/site_ruby/gems} |
41 | ruby_version="gem" |
36 | |
42 | else |
|
|
43 | ruby_version=${1/ruby/gem} |
|
|
44 | fi |
|
|
45 | export GEMSDIR=$(/usr/bin/${ruby_version} env gemdir) |
37 | } |
46 | } |
38 | |
47 | |
|
|
48 | # @FUNCTION: gems_src_unpack |
|
|
49 | # @DESCRIPTION: |
|
|
50 | # does nothing |
39 | gems_src_unpack() { |
51 | gems_src_unpack() { |
40 | true |
52 | true |
41 | } |
53 | } |
42 | |
54 | |
43 | gems_src_install() { |
55 | # @FUNCTION: gems_src_compile |
44 | gems_location |
56 | # @DESCRIPTION: |
45 | |
57 | # does nothing |
46 | if [ -z "${MY_P}" ]; then |
|
|
47 | GEM_SRC=${DISTDIR}/${P} |
|
|
48 | else |
|
|
49 | GEM_SRC=${DISTDIR}/${MY_P} |
|
|
50 | fi |
|
|
51 | |
|
|
52 | dodir ${GEMSDIR} |
|
|
53 | gem install ${GEM_SRC} -v ${PV} -l -i ${D}/${GEMSDIR} || die "gem install failed" |
|
|
54 | |
|
|
55 | if [ -d ${D}/${GEMSDIR}/bin ] ; then |
|
|
56 | exeinto /usr/bin |
|
|
57 | for exe in ${D}/${GEMSDIR}/bin/* ; do |
|
|
58 | doexe ${exe} |
|
|
59 | done |
|
|
60 | fi |
|
|
61 | } |
|
|
62 | |
|
|
63 | gems_src_compile() { |
58 | gems_src_compile() { |
64 | true |
59 | true |
65 | } |
60 | } |
66 | |
61 | |
|
|
62 | # @FUNCTION: gems_src_install |
|
|
63 | # @DESCRIPTION: |
|
|
64 | # Installs the gem |
|
|
65 | gems_src_install() { |
|
|
66 | local myconf |
|
|
67 | if use doc; then |
|
|
68 | myconf="--rdoc --ri" |
|
|
69 | else |
|
|
70 | myconf="--no-rdoc --no-ri" |
|
|
71 | fi |
|
|
72 | |
|
|
73 | if [[ -n "${GEMS_FORCE_INSTALL}" ]]; then |
|
|
74 | myconf="${myconf} --force" |
|
|
75 | fi |
|
|
76 | |
|
|
77 | # I'm not sure how many ebuilds have correctly set USE_RUBY - let's assume |
|
|
78 | # ruby18 if they haven't, since even pure Ruby gems that have been written |
|
|
79 | # against 1.8 can explode under 1.9. |
|
|
80 | if [[ -z "${USE_RUBY}" ]]; then |
|
|
81 | einfo "QA notice" |
|
|
82 | einfo "The ebuild doesn't set USE_RUBY explicitly. Defaulting to ruby18." |
|
|
83 | einfo "Please check compatibility and set USE_RUBY respectively." |
|
|
84 | |
|
|
85 | USE_RUBY="ruby18" |
|
|
86 | elif [[ "${USE_RUBY}" == "any" ]]; then |
|
|
87 | eerror "USE_RUBY=\"any\" is no longer supported. Please use explicit versions instead." |
|
|
88 | die "USE_RUBY=\"any\" is no longer supported." |
|
|
89 | fi |
|
|
90 | |
|
|
91 | local num_ruby_slots=$(echo "${USE_RUBY}" | wc -w) |
|
|
92 | |
|
|
93 | for ruby_version in ${USE_RUBY} ; do |
|
|
94 | # Check that we have the version installed |
|
|
95 | [[ -e "/usr/bin/${ruby_version/ruby/gem}" ]] || continue |
|
|
96 | |
|
|
97 | einfo "Installing for ${ruby_version}..." |
|
|
98 | gems_location ${ruby_version} |
|
|
99 | dodir ${GEMSDIR} || die |
|
|
100 | |
|
|
101 | if [[ -z "${MY_P}" ]]; then |
|
|
102 | [[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${P}" |
|
|
103 | spec_path="${D}/${GEMSDIR}/specifications/${P}.gemspec" |
|
|
104 | else |
|
|
105 | [[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${MY_P}" |
|
|
106 | spec_path="${D}/${GEMSDIR}/specifications/${MY_P}.gemspec" |
|
|
107 | fi |
|
|
108 | |
|
|
109 | # >=1.3.0 needs a path fix |
|
|
110 | local gte13=$(/usr/bin/${ruby_version} -rubygems -e 'puts Gem::RubyGemsVersion >= "1.3.0"') |
|
|
111 | |
|
|
112 | /usr/bin/${ruby_version} /usr/bin/gem install ${GEM_SRC} \ |
|
|
113 | --version ${PV} ${myconf} --local --install-dir "${D}/${GEMSDIR}" \ |
|
|
114 | --sandbox-fix --no-user-install || die "gem (>=1.3.0) install failed" |
|
|
115 | |
|
|
116 | if [[ -d "${D}/${GEMSDIR}/bin" ]] ; then |
|
|
117 | exeinto /usr/bin |
|
|
118 | for exe in "${D}"/${GEMSDIR}/bin/* ; do |
|
|
119 | if [ "$num_ruby_slots" -ge 2 ] ; then |
|
|
120 | # Ensures that the exe file gets run using the currently |
|
|
121 | # selected version of ruby. |
|
|
122 | sed -i -e 's@^#!/usr/bin/ruby.*$@#!/usr/bin/ruby@' "${exe}" |
|
|
123 | fi |
|
|
124 | doexe "${exe}" || die |
|
|
125 | done |
|
|
126 | fi |
|
|
127 | done |
|
|
128 | } |
67 | |
129 | |
68 | EXPORT_FUNCTIONS src_unpack src_compile src_install |
130 | EXPORT_FUNCTIONS src_unpack src_compile src_install |
69 | |
|
|