/[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.24 Revision 1.39
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.24 2010/07/30 16:56:21 flameeyes Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.39 2011/08/22 04:46:32 vapier 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#
31# 28#
32# * each_ruby_configure 29# * each_ruby_configure
33# * all_ruby_configure 30# * all_ruby_configure
34 31
35# @ECLASS-VARIABLE: USE_RUBY 32# @ECLASS-VARIABLE: USE_RUBY
33# @REQUIRED
36# @DESCRIPTION: 34# @DESCRIPTION:
37# This variable contains a space separated list of targets (see above) a package 35# This variable contains a space separated list of targets (see above) a package
38# is compatible to. It must be set before the `inherit' call. There is no 36# is compatible to. It must be set before the `inherit' call. There is no
39# default. All ebuilds are expected to set this variable. 37# default. All ebuilds are expected to set this variable.
40 38
41# @ECLASS-VARIABLE: RUBY_PATCHES 39# @ECLASS-VARIABLE: RUBY_PATCHES
40# @DEFAULT_UNSET
42# @DESCRIPTION: 41# @DESCRIPTION:
43# A String or Array of filenames of patches to apply to all implementations. 42# A String or Array of filenames of patches to apply to all implementations.
44 43
45# @ECLASS-VARIABLE: RUBY_OPTIONAL 44# @ECLASS-VARIABLE: RUBY_OPTIONAL
46# @DESCRIPTION: 45# @DESCRIPTION:
47# Set the value to "yes" to make the dependency on a Ruby interpreter optional. 46# Set the value to "yes" to make the dependency on a Ruby interpreter
47# optional and then ruby_implementations_depend() to help populate
48# DEPEND and RDEPEND.
49
50# @ECLASS-VARIABLE: RUBY_S
51# @DEFAULT_UNSET
52# @DESCRIPTION:
53# If defined this variable determines the source directory name after
54# unpacking. This defaults to the name of the package. Note that this
55# variable supports a wildcard mechanism to help with github tarballs
56# that contain the commit hash as part of the directory name.
57
58# @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS
59# @DEFAULT_UNSET
60# @DESCRIPTION:
61# If defined this variable contains a whitelist of shared objects that
62# are allowed to exist even if they don't link to libruby. This avoids
63# the QA check that makes this mandatory. This is most likely not what
64# you are looking for if you get the related "Missing links" QA warning,
65# since the proper fix is almost always to make sure the shared object
66# is linked against libruby. There are cases were this is not the case
67# and the shared object is generic code to be used in some other way
68# (e.g. selenium's firefox driver extension). When set this argument is
69# passed to "grep -E" to remove reporting of these shared objects.
48 70
49inherit eutils toolchain-funcs 71inherit eutils toolchain-funcs
50 72
51EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup 73EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
52 74
53case ${EAPI} in 75case ${EAPI} in
54 0|1) 76 0|1)
55 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; 77 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
56 2|3) ;; 78 2|3) ;;
79 4)
80 # S is no longer automatically assigned when it doesn't exist.
81 S="${WORKDIR}"
82 ;;
57 *) 83 *)
58 die "Unknown EAPI=${EAPI} for ruby-ng.eclass" 84 die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
59esac 85esac
60 86
61# @FUNCTION: ruby_implementation_depend 87# @FUNCTION: ruby_implementation_depend
127 done 153 done
128 echo ")" 154 echo ")"
129 eshopts_pop 155 eshopts_pop
130} 156}
131 157
158# @FUNCTION: ruby_implementation_command
159# @RETURN: the path to the given ruby implementation
160# @DESCRIPTION:
161# Not all implementations have the same command basename as the
162# target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18
163# respectively. This function translate between the two
164ruby_implementation_command() {
165 local _ruby_name=$1
166
167 # Add all USE_RUBY values where the flag name diverts from the binary here
168 case $1 in
169 ree18)
170 _ruby_name=rubyee18
171 ;;
172 esac
173
174 echo $(type -p ${_ruby_name} 2>/dev/null)
175}
176
132_ruby_atoms_samelib() { 177_ruby_atoms_samelib() {
133 local atoms=$(_ruby_atoms_samelib_generic "$*") 178 local atoms=$(_ruby_atoms_samelib_generic "$*")
134 179
135 for _ruby_implementation in $USE_RUBY; do 180 for _ruby_implementation in $USE_RUBY; do
136 echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}" 181 echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
178 RDEPEND="${RDEPEND} $dependency" 223 RDEPEND="${RDEPEND} $dependency"
179 224
180 # Add the dependency as a test-dependency since we're going to 225 # Add the dependency as a test-dependency since we're going to
181 # execute the code during test phase. 226 # execute the code during test phase.
182 DEPEND="${DEPEND} test? ( ${dependency} )" 227 DEPEND="${DEPEND} test? ( ${dependency} )"
183 hasq test "$IUSE" || IUSE="${IUSE} test" 228 has test "$IUSE" || IUSE="${IUSE} test"
184} 229}
185 230
186# @FUNCTION: ruby_add_bdepend 231# @FUNCTION: ruby_add_bdepend
187# @USAGE: dependencies 232# @USAGE: dependencies
188# @DESCRIPTION: 233# @DESCRIPTION:
209 254
210 DEPEND="${DEPEND} $dependency" 255 DEPEND="${DEPEND} $dependency"
211 RDEPEND="${RDEPEND}" 256 RDEPEND="${RDEPEND}"
212} 257}
213 258
259# @FUNCTION: ruby_get_use_implementations
260# @DESCRIPTION:
261# Gets an array of ruby use targets enabled by the user
262ruby_get_use_implementations() {
263 local i implementation
264 for implementation in ${USE_RUBY}; do
265 use ruby_targets_${implementation} && i+=" ${implementation}"
266 done
267 echo $i
268}
269
270# @FUNCTION: ruby_get_use_targets
271# @DESCRIPTION:
272# Gets an array of ruby use targets that the ebuild sets
273ruby_get_use_targets() {
274 local t implementation
275 for implementation in ${USE_RUBY}; do
276 t+=" ruby_targets_${implementation}"
277 done
278 echo $t
279}
280
281if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then
282 REQUIRED_USE=" || ( $(ruby_get_use_targets) )"
283fi
284
285# @FUNCTION: ruby_implementations_depend
286# @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
287# @DESCRIPTION:
288# Produces the dependency string for the various implementations of ruby
289# which the package is being built against. This should not be used when
290# RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
291# confuse this function with ruby_implementation_depend().
292#
293# @EXAMPLE:
294# EAPI=4
295# RUBY_OPTIONAL=yes
296#
297# inherit ruby-ng
298# ...
299# DEPEND="ruby? ( $(ruby_implementations_depend) )"
300# RDEPEND="${DEPEND}"
301ruby_implementations_depend() {
302 local depend
303 for _ruby_implementation in ${USE_RUBY}; do
304 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
305 done
306 echo "${depend}"
307}
308
214for _ruby_implementation in $USE_RUBY; do 309for _ruby_implementation in ${USE_RUBY}; do
215 IUSE="${IUSE} ruby_targets_${_ruby_implementation}" 310 IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
216
217 # If you specify RUBY_OPTIONAL you also need to take care of
218 # ruby useflag and dependency.
219 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
220 DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
221 RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
222 fi
223done 311done
312# If you specify RUBY_OPTIONAL you also need to take care of
313# ruby useflag and dependency.
314if [[ ${RUBY_OPTIONAL} != yes ]]; then
315 DEPEND="${DEPEND} $(ruby_implementations_depend)"
316 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
317fi
224 318
225_ruby_invoke_environment() { 319_ruby_invoke_environment() {
226 old_S=${S} 320 old_S=${S}
321 case ${EAPI} in
322 4)
323 if [ -z ${RUBY_S} ]; then
324 sub_S=${P}
325 else
326 sub_S=${RUBY_S}
327 fi
328 ;;
329 *)
227 sub_S=${S#${WORKDIR}/} 330 sub_S=${S#${WORKDIR}/}
331 ;;
332 esac
228 333
229 # Special case, for the always-lovely GitHub fetches. With this, 334 # Special case, for the always-lovely GitHub fetches. With this,
230 # we allow the star glob to just expand to whatever directory it's 335 # we allow the star glob to just expand to whatever directory it's
231 # called. 336 # called.
232 if [[ ${sub_S} = *"*" ]]; then 337 if [[ ${sub_S} = *"*"* ]]; then
338 case ${EAPI} in
339 2|3)
340 #The old method of setting S depends on undefined package
341 # manager behaviour, so encourage upgrading to EAPI=4.
342 eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
343 ;;
344 esac
233 pushd "${WORKDIR}"/all &>/dev/null 345 pushd "${WORKDIR}"/all &>/dev/null
234 sub_S=$(eval ls -d ${sub_S} 2>/dev/null) 346 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
235 popd &>/dev/null 347 popd &>/dev/null
236 fi 348 fi
237 349
259 local invoked=no 371 local invoked=no
260 for _ruby_implementation in ${USE_RUBY}; do 372 for _ruby_implementation in ${USE_RUBY}; do
261 # only proceed if it's requested 373 # only proceed if it's requested
262 use ruby_targets_${_ruby_implementation} || continue 374 use ruby_targets_${_ruby_implementation} || continue
263 375
264 local _ruby_name=$_ruby_implementation 376 RUBY=$(ruby_implementation_command ${_ruby_implementation})
265
266 # Add all USE_RUBY values where the flag name diverts from the binary here
267 case $_ruby_implementation in
268 ree18)
269 _ruby_name=rubyee18
270 ;;
271 esac
272
273 RUBY=$(type -p $_ruby_name 2>/dev/null)
274 invoked=yes 377 invoked=yes
275 378
276 if [[ -n "$1" ]]; then 379 if [[ -n "$1" ]]; then
277 _ruby_invoke_environment $_ruby_implementation "$@" 380 _ruby_invoke_environment ${_ruby_implementation} "$@"
278 fi 381 fi
279 382
280 unset RUBY 383 unset RUBY
281 done 384 done
282 385
396 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho 499 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
397 500
398 has "${EAPI}" 2 && ! use prefix && EPREFIX= 501 has "${EAPI}" 2 && ! use prefix && EPREFIX=
399 502
400 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') 503 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]')
401 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}")) 504 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
402 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') 505 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')
403 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') 506 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')
404 507
405 # Look for wrong files in sitedir 508 # Look for wrong files in sitedir
406 # if [[ -d "${D}${sitedir}" ]]; then 509 # if [[ -d "${D}${sitedir}" ]]; then
419 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since 522 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
420 # that's what changes between two implementations (otherwise you'd get false 523 # that's what changes between two implementations (otherwise you'd get false
421 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) 524 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
422 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ 525 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
423 | fgrep -v "${libruby_soname}" \ 526 | fgrep -v "${libruby_soname}" \
527 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
424 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log 528 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
425 529
426 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then 530 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
427 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}" 531 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
428 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) 532 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.39

  ViewVC Help
Powered by ViewVC 1.1.20