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