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

Diff of /eclass/gems.eclass

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

Revision 1.21 Revision 1.30
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.21 2008/02/17 08:49:19 rbrown Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/gems.eclass,v 1.30 2009/11/28 08:26:40 a3li 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: Ruby Herd <ruby@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_unpack() - Does nothing.
15# gems_src_compile() - Does nothing.
16# gems_src_install() - installs a gem into ${D}
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
22inherit eutils ruby 21inherit eutils ruby
23 22
23#SRC_URI="mirror://rubyforge/gems/${P}.gem"
24SRC_URI="http://gems.rubyforge.org/gems/${P}.gem" 24SRC_URI="http://gems.rubyforge.org/gems/${P}.gem"
25 25
26IUSE="doc" 26IUSE="doc"
27 27
28DEPEND=" 28DEPEND="
29 >=dev-ruby/rubygems-0.9.4 29 || ( >=dev-ruby/rubygems-1.3.1 =dev-lang/ruby-1.9* )
30 !dev-ruby/rdoc 30 !<dev-ruby/rdoc-2
31" 31"
32RDEPEND="${DEPEND}" 32RDEPEND="${DEPEND}"
33 33
34# @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
34gems_location() { 39gems_location() {
35 local sitelibdir 40 local ruby_version
36 sitelibdir=$(ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]') 41 if [[ -z "$1" ]]; then
37 export GEMSDIR=${sitelibdir/site_ruby/gems} 42 ruby_version="gem"
38 43 else
44 ruby_version=${1/ruby/gem}
45 fi
46 export GEMSDIR=$(/usr/bin/${ruby_version} env gemdir)
39} 47}
40 48
49# @FUNCTION: gems_src_unpack
50# @DESCRIPTION:
51# does nothing
41gems_src_unpack() { 52gems_src_unpack() {
42 true 53 true
43} 54}
44 55
56# @FUNCTION: gems_src_compile
57# @DESCRIPTION:
58# does nothing
45gems_src_compile() { 59gems_src_compile() {
46 true 60 true
47} 61}
48 62
63# @FUNCTION: gems_src_install
64# @DESCRIPTION:
65# Installs the gem
49gems_src_install() { 66gems_src_install() {
50 gems_location
51
52 if [[ -z "${MY_P}" ]]; then
53 [[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${P}"
54 spec_path="${D}/${GEMSDIR}/specifications/${P}.gemspec"
55 else
56 [[ -z "${GEM_SRC}" ]] && GEM_SRC="${DISTDIR}/${MY_P}"
57 spec_path="${D}/${GEMSDIR}/specifications/${MY_P}.gemspec"
58 fi
59
60 local myconf 67 local myconf
61 if use doc; then 68 if use doc; then
62 myconf="--rdoc --ri" 69 myconf="--rdoc --ri"
63 else 70 else
64 myconf="--no-rdoc --no-ri" 71 myconf="--no-rdoc --no-ri"
65 fi 72 fi
66 73
67 dodir ${GEMSDIR} 74 # I'm not sure how many ebuilds have correctly set USE_RUBY - let's assume
68 gem install ${GEM_SRC} --version ${PV} ${myconf} \ 75 # ruby18 if they haven't, since even pure Ruby gems that have been written
69 --local --install-dir "${D}/${GEMSDIR}" || die "gem install failed" 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."
70 81
71 if [[ -d "${D}/${GEMSDIR}/bin" ]] ; then 82 USE_RUBY="ruby18"
72 exeinto /usr/bin 83 elif [[ "${USE_RUBY}" == "any" ]]; then
73 for exe in ${D}/${GEMSDIR}/bin/* ; do 84 eerror "USE_RUBY=\"any\" is no longer supported. Please use explicit versions instead."
74 doexe ${exe} 85 die "USE_RUBY=\"any\" is no longer supported."
75 done
76 fi 86 fi
87
88 local num_ruby_slots=$(echo "${USE_RUBY}" | wc -w)
89
90 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 /usr/bin/${ruby_version} /usr/bin/gem install ${GEM_SRC} \
110 --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
77} 125}
78 126
79EXPORT_FUNCTIONS src_unpack src_compile src_install 127EXPORT_FUNCTIONS src_unpack src_compile src_install

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.20