/[gentoo-x86]/eclass/ruby-ng.eclass
Gentoo

Diff of /eclass/ruby-ng.eclass

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

Revision 1.26 Revision 1.42
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2011 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/ruby-ng.eclass,v 1.26 2010/08/22 07:28:24 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.42 2011/10/22 10:08:44 scarabeus Exp $
4# 4
5# @ECLASS: ruby-ng.eclass 5# @ECLASS: ruby-ng.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ruby herd <ruby@gentoo.org> 7# Ruby herd <ruby@gentoo.org>
8# 8# @AUTHOR:
9# Author: Diego E. Pettenò <flameeyes@gentoo.org> 9# Author: Diego E. Pettenò <flameeyes@gentoo.org>
10#
11# Author: Alex Legler <a3li@gentoo.org> 10# Author: Alex Legler <a3li@gentoo.org>
12#
13# Author: Hans de Graaff <graaff@gentoo.org> 11# Author: Hans de Graaff <graaff@gentoo.org>
14#
15# @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots. 12# @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots.
16# @DESCRIPTION: 13# @DESCRIPTION:
17# The Ruby eclass is designed to allow an easier installation of Ruby packages 14# The Ruby eclass is designed to allow an easier installation of Ruby packages
18# and their incorporation into the Gentoo Linux system. 15# and their incorporation into the Gentoo Linux system.
19# 16#
20# Currently available targets are: 17# Currently available targets are:
21# * ruby18 - Ruby (MRI) 1.8.x 18# * ruby18 - Ruby (MRI) 1.8.x
22# * ruby19 - Ruby (MRI) 1.9.x 19# * ruby19 - Ruby (MRI) 1.9.x
23# * ree18 - Ruby Enterprise Edition 1.8.x 20# * ree18 - Ruby Enterprise Edition 1.8.x
24# * jruby - JRuby 21# * jruby - JRuby
22# * rbx - Rubinius
25# 23#
26# This eclass does not define the implementation of the configure, 24# This eclass does not define the implementation of the configure,
27# compile, test, or install phases. Instead, the default phases are 25# compile, test, or install phases. Instead, the default phases are
28# used. Specific implementations of these phases can be provided in 26# used. Specific implementations of these phases can be provided in
29# the ebuild either to be run for each Ruby implementation, or for all 27# the ebuild either to be run for each Ruby implementation, or for all
44# @DESCRIPTION: 42# @DESCRIPTION:
45# A String or Array of filenames of patches to apply to all implementations. 43# A String or Array of filenames of patches to apply to all implementations.
46 44
47# @ECLASS-VARIABLE: RUBY_OPTIONAL 45# @ECLASS-VARIABLE: RUBY_OPTIONAL
48# @DESCRIPTION: 46# @DESCRIPTION:
49# Set the value to "yes" to make the dependency on a Ruby interpreter optional. 47# Set the value to "yes" to make the dependency on a Ruby interpreter
48# optional and then ruby_implementations_depend() to help populate
49# DEPEND and RDEPEND.
50 50
51# @ECLASS-VARIABLE: RUBY_S
52# @DEFAULT_UNSET
53# @DESCRIPTION:
54# If defined this variable determines the source directory name after
55# unpacking. This defaults to the name of the package. Note that this
56# variable supports a wildcard mechanism to help with github tarballs
57# that contain the commit hash as part of the directory name.
58
59# @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS
60# @DEFAULT_UNSET
61# @DESCRIPTION:
62# If defined this variable contains a whitelist of shared objects that
63# are allowed to exist even if they don't link to libruby. This avoids
64# the QA check that makes this mandatory. This is most likely not what
65# you are looking for if you get the related "Missing links" QA warning,
66# since the proper fix is almost always to make sure the shared object
67# is linked against libruby. There are cases were this is not the case
68# and the shared object is generic code to be used in some other way
69# (e.g. selenium's firefox driver extension). When set this argument is
70# passed to "grep -E" to remove reporting of these shared objects.
71
51inherit eutils toolchain-funcs 72inherit eutils java-utils-2 toolchain-funcs
52 73
53EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup 74EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
54 75
55case ${EAPI} in 76case ${EAPI} in
56 0|1) 77 0|1)
57 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; 78 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
58 2|3) ;; 79 2|3) ;;
80 4)
81 # S is no longer automatically assigned when it doesn't exist.
82 S="${WORKDIR}"
83 ;;
59 *) 84 *)
60 die "Unknown EAPI=${EAPI} for ruby-ng.eclass" 85 die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
61esac 86esac
62 87
63# @FUNCTION: ruby_implementation_depend 88# @FUNCTION: ruby_implementation_depend
87 rubypn="dev-lang/ruby-enterprise" 112 rubypn="dev-lang/ruby-enterprise"
88 rubyslot=":1.8" 113 rubyslot=":1.8"
89 ;; 114 ;;
90 jruby) 115 jruby)
91 rubypn="dev-java/jruby" 116 rubypn="dev-java/jruby"
117 rubyslot=""
118 ;;
119 rbx)
120 rubypn="dev-lang/rubinius"
92 rubyslot="" 121 rubyslot=""
93 ;; 122 ;;
94 *) die "$1: unknown Ruby implementation" 123 *) die "$1: unknown Ruby implementation"
95 esac 124 esac
96 125
129 done 158 done
130 echo ")" 159 echo ")"
131 eshopts_pop 160 eshopts_pop
132} 161}
133 162
163# @FUNCTION: ruby_implementation_command
164# @RETURN: the path to the given ruby implementation
165# @DESCRIPTION:
166# Not all implementations have the same command basename as the
167# target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18
168# respectively. This function translate between the two
169ruby_implementation_command() {
170 local _ruby_name=$1
171
172 # Add all USE_RUBY values where the flag name diverts from the binary here
173 case $1 in
174 ree18)
175 _ruby_name=rubyee18
176 ;;
177 esac
178
179 echo $(type -p ${_ruby_name} 2>/dev/null)
180}
181
134_ruby_atoms_samelib() { 182_ruby_atoms_samelib() {
135 local atoms=$(_ruby_atoms_samelib_generic "$*") 183 local atoms=$(_ruby_atoms_samelib_generic "$*")
136 184
137 for _ruby_implementation in $USE_RUBY; do 185 for _ruby_implementation in $USE_RUBY; do
138 echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}" 186 echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
180 RDEPEND="${RDEPEND} $dependency" 228 RDEPEND="${RDEPEND} $dependency"
181 229
182 # Add the dependency as a test-dependency since we're going to 230 # Add the dependency as a test-dependency since we're going to
183 # execute the code during test phase. 231 # execute the code during test phase.
184 DEPEND="${DEPEND} test? ( ${dependency} )" 232 DEPEND="${DEPEND} test? ( ${dependency} )"
185 hasq test "$IUSE" || IUSE="${IUSE} test" 233 has test "$IUSE" || IUSE="${IUSE} test"
186} 234}
187 235
188# @FUNCTION: ruby_add_bdepend 236# @FUNCTION: ruby_add_bdepend
189# @USAGE: dependencies 237# @USAGE: dependencies
190# @DESCRIPTION: 238# @DESCRIPTION:
211 259
212 DEPEND="${DEPEND} $dependency" 260 DEPEND="${DEPEND} $dependency"
213 RDEPEND="${RDEPEND}" 261 RDEPEND="${RDEPEND}"
214} 262}
215 263
264# @FUNCTION: ruby_get_use_implementations
265# @DESCRIPTION:
266# Gets an array of ruby use targets enabled by the user
267ruby_get_use_implementations() {
268 local i implementation
269 for implementation in ${USE_RUBY}; do
270 use ruby_targets_${implementation} && i+=" ${implementation}"
271 done
272 echo $i
273}
274
275# @FUNCTION: ruby_get_use_targets
276# @DESCRIPTION:
277# Gets an array of ruby use targets that the ebuild sets
278ruby_get_use_targets() {
279 local t implementation
280 for implementation in ${USE_RUBY}; do
281 t+=" ruby_targets_${implementation}"
282 done
283 echo $t
284}
285
286if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then
287 REQUIRED_USE=" || ( $(ruby_get_use_targets) )"
288fi
289
290# @FUNCTION: ruby_implementations_depend
291# @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
292# @DESCRIPTION:
293# Produces the dependency string for the various implementations of ruby
294# which the package is being built against. This should not be used when
295# RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
296# confuse this function with ruby_implementation_depend().
297#
298# @EXAMPLE:
299# EAPI=4
300# RUBY_OPTIONAL=yes
301#
302# inherit ruby-ng
303# ...
304# DEPEND="ruby? ( $(ruby_implementations_depend) )"
305# RDEPEND="${DEPEND}"
306ruby_implementations_depend() {
307 local depend
308 for _ruby_implementation in ${USE_RUBY}; do
309 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
310 done
311 echo "${depend}"
312}
313
216for _ruby_implementation in $USE_RUBY; do 314for _ruby_implementation in ${USE_RUBY}; do
217 IUSE="${IUSE} ruby_targets_${_ruby_implementation}" 315 IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
218
219 # If you specify RUBY_OPTIONAL you also need to take care of
220 # ruby useflag and dependency.
221 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
222 DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
223 RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
224 fi
225done 316done
317# If you specify RUBY_OPTIONAL you also need to take care of
318# ruby useflag and dependency.
319if [[ ${RUBY_OPTIONAL} != yes ]]; then
320 DEPEND="${DEPEND} $(ruby_implementations_depend)"
321 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
322fi
226 323
227_ruby_invoke_environment() { 324_ruby_invoke_environment() {
228 old_S=${S} 325 old_S=${S}
326 case ${EAPI} in
327 4)
328 if [ -z ${RUBY_S} ]; then
329 sub_S=${P}
330 else
331 sub_S=${RUBY_S}
332 fi
333 ;;
334 *)
229 sub_S=${S#${WORKDIR}/} 335 sub_S=${S#${WORKDIR}/}
336 ;;
337 esac
230 338
231 # Special case, for the always-lovely GitHub fetches. With this, 339 # Special case, for the always-lovely GitHub fetches. With this,
232 # we allow the star glob to just expand to whatever directory it's 340 # we allow the star glob to just expand to whatever directory it's
233 # called. 341 # called.
234 if [[ ${sub_S} = *"*" ]]; then 342 if [[ ${sub_S} = *"*"* ]]; then
343 case ${EAPI} in
344 2|3)
345 #The old method of setting S depends on undefined package
346 # manager behaviour, so encourage upgrading to EAPI=4.
347 eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
348 ;;
349 esac
235 pushd "${WORKDIR}"/all &>/dev/null 350 pushd "${WORKDIR}"/all &>/dev/null
236 sub_S=$(eval ls -d ${sub_S} 2>/dev/null) 351 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
237 popd &>/dev/null 352 popd &>/dev/null
238 fi 353 fi
239 354
261 local invoked=no 376 local invoked=no
262 for _ruby_implementation in ${USE_RUBY}; do 377 for _ruby_implementation in ${USE_RUBY}; do
263 # only proceed if it's requested 378 # only proceed if it's requested
264 use ruby_targets_${_ruby_implementation} || continue 379 use ruby_targets_${_ruby_implementation} || continue
265 380
266 local _ruby_name=$_ruby_implementation 381 RUBY=$(ruby_implementation_command ${_ruby_implementation})
267
268 # Add all USE_RUBY values where the flag name diverts from the binary here
269 case $_ruby_implementation in
270 ree18)
271 _ruby_name=rubyee18
272 ;;
273 esac
274
275 RUBY=$(type -p $_ruby_name 2>/dev/null)
276 invoked=yes 382 invoked=yes
277 383
278 if [[ -n "$1" ]]; then 384 if [[ -n "$1" ]]; then
279 _ruby_invoke_environment $_ruby_implementation "$@" 385 _ruby_invoke_environment ${_ruby_implementation} "$@"
280 fi 386 fi
281 387
282 unset RUBY 388 unset RUBY
283 done 389 done
284 390
291ruby-ng_pkg_setup() { 397ruby-ng_pkg_setup() {
292 # This only checks that at least one implementation is present 398 # This only checks that at least one implementation is present
293 # before doing anything; by leaving the parameters empty we know 399 # before doing anything; by leaving the parameters empty we know
294 # it's a special case. 400 # it's a special case.
295 _ruby_each_implementation 401 _ruby_each_implementation
402
403 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
296} 404}
297 405
298# @FUNCTION: ruby-ng_src_unpack 406# @FUNCTION: ruby-ng_src_unpack
299# @DESCRIPTION: 407# @DESCRIPTION:
300# Unpack the source archive. 408# Unpack the source archive.
421 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since 529 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
422 # that's what changes between two implementations (otherwise you'd get false 530 # that's what changes between two implementations (otherwise you'd get false
423 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) 531 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
424 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ 532 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
425 | fgrep -v "${libruby_soname}" \ 533 | fgrep -v "${libruby_soname}" \
534 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
426 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log 535 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
427 536
428 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then 537 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
429 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}" 538 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
430 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) 539 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
505 echo "ree" 614 echo "ree"
506 ;; 615 ;;
507 *jruby*) 616 *jruby*)
508 echo "jruby" 617 echo "jruby"
509 ;; 618 ;;
619 *rubinius*)
620 echo "rbx"
621 ;;
510 *) 622 *)
511 echo "mri" 623 echo "mri"
512 ;; 624 ;;
513 esac 625 esac
514} 626}

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.42

  ViewVC Help
Powered by ViewVC 1.1.20