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

Diff of /eclass/gems.eclass

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

Revision 1.1.1.1 Revision 1.36
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2014 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.1.1.1 2005/11/30 09:59:23 chriswhite Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/gems.eclass,v 1.36 2014/05/07 20:41:18 mrueg 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#
9# @DEAD
10# @ECLASS: gems.eclass
11# @MAINTAINER:
12# ruby@gentoo.org
13# @AUTHOR:
5# Author: Rob Cakebread <pythonhead@gentoo.org> 14# Original Author: Rob Cakebread <pythonhead@gentoo.org>
6# Current Maintainer: Rob Cakebread <pythonhead@gentoo.org> 15# @BLURB: Eclass helping with the installation of RubyGems
7# 16# @DESCRIPTION:
8# The gems eclass is designed to allow easier installation of
9# gems-based ruby packagess and their incorporation into
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_install() - installs a gem into ${D}
15# gems_src_unpack() - Does nothing.
16# gems_src_compile() - Does nothing.
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 ruby eutils 25inherit eutils ruby
23 26
27SRC_URI="mirror://rubygems/${P}.gem"
24 28
25DEPEND=">=dev-ruby/rubygems-0.8.4-r1 29IUSE="doc"
26 !dev-ruby/rdoc"
27 30
28S=${WORKDIR} 31DEPEND="
32 >=dev-ruby/rubygems-1.3.1
33 <=dev-ruby/rubygems-1.3.7-r1
34 !<dev-ruby/rdoc-2
35"
36RDEPEND="${DEPEND}"
29 37
30 38# @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
31gems_location() { 43gems_location() {
32 local sitelibdir 44 local ruby_version
33 sitelibdir=`ruby -r rbconfig -e 'print Config::CONFIG["sitelibdir"]'` 45 if [[ -z "$1" ]]; then
34 export GEMSDIR=${sitelibdir/site_ruby/gems} 46 ruby_version="gem"
35 47 else
48 ruby_version=${1/ruby/gem}
49 fi
50 export GEMSDIR=$(/usr/bin/${ruby_version} env gemdir)
36} 51}
37 52
53# @FUNCTION: gems_src_unpack
54# @DESCRIPTION:
55# does nothing
38gems_src_unpack() { 56gems_src_unpack() {
39 true 57 true
40} 58}
41 59
42gems_src_install() { 60# @FUNCTION: gems_src_compile
43 gems_location 61# @DESCRIPTION:
44 62# does nothing
45 if [ -z "${MY_P}" ]; then
46 GEM_SRC=${DISTDIR}/${P}
47 else
48 GEM_SRC=${DISTDIR}/${MY_P}
49 fi
50
51 dodir ${GEMSDIR}
52 gem install ${GEM_SRC} -v ${PV} -l -i ${D}/${GEMSDIR} || die "gem install failed"
53
54 if [ -d ${D}/${GEMSDIR}/bin ] ; then
55 exeinto /usr/bin
56 for exe in ${D}/${GEMSDIR}/bin/* ; do
57 doexe ${exe}
58 done
59 fi
60}
61
62gems_src_compile() { 63gems_src_compile() {
63 true 64 true
64} 65}
65 66
67# @FUNCTION: gems_src_install
68# @DESCRIPTION:
69# Installs the gem
70gems_src_install() {
71 local myconf
72 if use doc; then
73 myconf="--rdoc --ri"
74 else
75 myconf="--no-rdoc --no-ri"
76 fi
77
78 if [[ -n "${GEMS_FORCE_INSTALL}" ]]; then
79 myconf="${myconf} --force"
80 fi
81
82 # 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
90 USE_RUBY="ruby18"
91 elif [[ "${USE_RUBY}" == "any" ]]; then
92 eerror "USE_RUBY=\"any\" is no longer supported. Please use explicit versions instead."
93 die "USE_RUBY=\"any\" is no longer supported."
94 fi
95
96 local num_ruby_slots=$(echo "${USE_RUBY}" | wc -w)
97
98 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 /usr/bin/${ruby_version} /usr/bin/gem install ${GEM_SRC} \
118 --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}
134
66EXPORT_FUNCTIONS src_unpack src_compile src_install 135EXPORT_FUNCTIONS src_unpack src_compile src_install

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.36

  ViewVC Help
Powered by ViewVC 1.1.20