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

Contents of /eclass/gems.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.30 - (hide annotations) (download)
Sat Nov 28 08:26:40 2009 UTC (4 years, 7 months ago) by a3li
Branch: MAIN
Changes since 1.29: +3 -2 lines
gems.eclass: Fetch gems from gems.rubyforge.org only for the moment

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

  ViewVC Help
Powered by ViewVC 1.1.20