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

Contents of /eclass/gems.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.34 - (hide annotations) (download)
Tue Aug 3 15:51:10 2010 UTC (4 years ago) by flameeyes
Branch: MAIN
Changes since 1.33: +3 -2 lines
Require an older version of rubygems, since this is compatibility-only now.

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

  ViewVC Help
Powered by ViewVC 1.1.20