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

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

  ViewVC Help
Powered by ViewVC 1.1.20