/[gentoo-x86]/eclass/gems.eclass
Gentoo

Contents of /eclass/gems.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (show annotations) (download)
Sat May 23 12:22:06 2009 UTC (5 years, 4 months ago) by flameeyes
Branch: MAIN
Changes since 1.25: +4 -4 lines
Change the blocker from generic dev-ruby/rdoc to rdoc earlier than 2.

We're going to need an rdoc-2 one day.

1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/gems.eclass,v 1.25 2009/03/17 19:39:51 a3li Exp $
4
5 # @ECLASS: gems.eclass
6 # @MAINTAINER:
7 # ruby@gentoo.org
8 #
9 # Original Author: Rob Cakebread <pythonhead@gentoo.org>
10 #
11 # @BLURB: Eclass helping with the installation of RubyGems
12 # @DESCRIPTION:
13 # See http://dev.gentoo.org/~pythonhead/ruby/gems.html for notes on using gems with Portage.
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)
20
21 inherit eutils ruby
22
23 SRC_URI="mirror://rubyforge/gems/${P}.gem"
24
25 IUSE="doc"
26
27 DEPEND="
28 || ( >=dev-ruby/rubygems-0.9.4 =dev-lang/ruby-1.9* )
29 !<dev-ruby/rdoc-2
30 "
31 RDEPEND="${DEPEND}"
32
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
38 gems_location() {
39 local ruby_version
40 if [[ -z "$1" ]]; then
41 ruby_version="gem"
42 else
43 ruby_version=${1/ruby/gem}
44 fi
45 export GEMSDIR=$(/usr/bin/${ruby_version} env gemdir)
46 }
47
48 # @FUNCTION: gems_src_unpack
49 # @DESCRIPTION:
50 # does nothing
51 gems_src_unpack() {
52 true
53 }
54
55 # @FUNCTION: gems_src_compile
56 # @DESCRIPTION:
57 # does nothing
58 gems_src_compile() {
59 true
60 }
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 # I'm not sure how many ebuilds have correctly set USE_RUBY - let's assume
74 # ruby18 if they haven't, since even pure Ruby gems that have been written
75 # against 1.8 can explode under 1.9.
76 if [[ -z "${USE_RUBY}" ]]; then
77 einfo "QA notice"
78 einfo "The ebuild doesn't set USE_RUBY explicitly. Defaulting to ruby18."
79 einfo "Please check compatibility and set USE_RUBY respectively."
80
81 USE_RUBY="ruby18"
82 elif [[ "${USE_RUBY}" == "any" ]]; then
83 ewarn
84 ewarn "DEPRECATION NOTICE"
85 ewarn "USE_RUBY=\"any\" is deprecated. Please use explicit versions instead."
86 ewarn "Support will be removed in April 2009."
87 ewarn "For questions, please contact ruby@gentoo.org."
88 ewarn
89
90 # Get the installed versions.
91 USE_RUBY=`ls /usr/bin/ruby* | grep -E 'ruby1(8|9)' | sed -e 's@/usr/bin/@@g'`
92 fi
93
94 local num_ruby_slots=$(echo "${USE_RUBY}" | wc -w)
95
96 for ruby_version in ${USE_RUBY} ; do
97 # Check that we have the version installed
98 [[ -e "/usr/bin/${ruby_version/ruby/gem}" ]] || continue
99
100 einfo "Installing for ${ruby_version}..."
101 gems_location ${ruby_version}
102 dodir ${GEMSDIR} || die
103
104 if [[ -z "${MY_P}" ]]; then
105 [[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${P}"
106 spec_path="${D}/${GEMSDIR}/specifications/${P}.gemspec"
107 else
108 [[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${MY_P}"
109 spec_path="${D}/${GEMSDIR}/specifications/${MY_P}.gemspec"
110 fi
111
112 # >=1.3.0 needs a path fix
113 local gte13=$(/usr/bin/${ruby_version} -rubygems -e 'puts Gem::RubyGemsVersion >= "1.3.0"')
114
115 if [[ "${gte13}" == "true" ]] ; then
116 /usr/bin/${ruby_version} /usr/bin/gem install ${GEM_SRC} \
117 --version ${PV} ${myconf} --local --install-dir "${D}/${GEMSDIR}" \
118 --sandbox-fix --no-user-install || die "gem (>=1.3.0) install failed"
119 else
120 /usr/bin/${ruby_version} /usr/bin/gem install ${GEM_SRC} \
121 --version ${PV} ${myconf} --local --install-dir "${D}/${GEMSDIR}" \
122 || die "gem (<1.3.0) install failed"
123 fi
124
125 if [[ -d "${D}/${GEMSDIR}/bin" ]] ; then
126 exeinto /usr/bin
127 for exe in "${D}"/${GEMSDIR}/bin/* ; do
128 if [ "$num_ruby_slots" -ge 2 ] ; then
129 # Ensures that the exe file gets run using the currently
130 # selected version of ruby.
131 sed -i -e 's@^#!/usr/bin/ruby.*$@#!/usr/bin/ruby@' "${exe}"
132 fi
133 doexe "${exe}" || die
134 done
135 fi
136 done
137 }
138
139 EXPORT_FUNCTIONS src_unpack src_compile src_install

  ViewVC Help
Powered by ViewVC 1.1.20