/[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.1 Revision 1.57
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2015 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.1 2009/12/05 09:35:48 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.57 2015/05/31 05:57:23 graaff 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
20# * ruby20 - Ruby (MRI) 2.0.x
21# * ruby21 - Ruby (MRI) 2.1.x
22# * ruby22 - Ruby (MRI) 2.2.x
23# * ree18 - Ruby Enterprise Edition 1.8.x 23# * ree18 - Ruby Enterprise Edition 1.8.x
24# * jruby - JRuby 24# * jruby - JRuby
25# * rbx - Rubinius
25# 26#
26# This eclass does not define the implementation of the configure, 27# This eclass does not define the implementation of the configure,
27# compile, test, or install phases. Instead, the default phases are 28# compile, test, or install phases. Instead, the default phases are
28# used. Specific implementations of these phases can be provided in 29# used. Specific implementations of these phases can be provided in
29# the ebuild either to be run for each Ruby implementation, or for all 30# the ebuild either to be run for each Ruby implementation, or for all
31# 32#
32# * each_ruby_configure 33# * each_ruby_configure
33# * all_ruby_configure 34# * all_ruby_configure
34 35
35# @ECLASS-VARIABLE: USE_RUBY 36# @ECLASS-VARIABLE: USE_RUBY
37# @DEFAULT_UNSET
38# @REQUIRED
36# @DESCRIPTION: 39# @DESCRIPTION:
37# This variable contains a space separated list of targets (see above) a package 40# 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 41# is compatible to. It must be set before the `inherit' call. There is no
39# default. All ebuilds are expected to set this variable. 42# default. All ebuilds are expected to set this variable.
40 43
41# @ECLASS-VARIABLE: RUBY_PATCHES 44# @ECLASS-VARIABLE: RUBY_PATCHES
45# @DEFAULT_UNSET
42# @DESCRIPTION: 46# @DESCRIPTION:
43# A String or Array of filenames of patches to apply to all implementations. 47# A String or Array of filenames of patches to apply to all implementations.
44 48
45# @ECLASS-VARIABLE: RUBY_OPTIONAL 49# @ECLASS-VARIABLE: RUBY_OPTIONAL
46# @DESCRIPTION: 50# @DESCRIPTION:
47# Set the value to "yes" to make the dependency on a Ruby interpreter optional. 51# Set the value to "yes" to make the dependency on a Ruby interpreter
52# optional and then ruby_implementations_depend() to help populate
53# DEPEND and RDEPEND.
48 54
49inherit eutils toolchain-funcs 55# @ECLASS-VARIABLE: RUBY_S
56# @DEFAULT_UNSET
57# @DESCRIPTION:
58# If defined this variable determines the source directory name after
59# unpacking. This defaults to the name of the package. Note that this
60# variable supports a wildcard mechanism to help with github tarballs
61# that contain the commit hash as part of the directory name.
62
63# @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS
64# @DEFAULT_UNSET
65# @DESCRIPTION:
66# If defined this variable contains a whitelist of shared objects that
67# are allowed to exist even if they don't link to libruby. This avoids
68# the QA check that makes this mandatory. This is most likely not what
69# you are looking for if you get the related "Missing links" QA warning,
70# since the proper fix is almost always to make sure the shared object
71# is linked against libruby. There are cases were this is not the case
72# and the shared object is generic code to be used in some other way
73# (e.g. selenium's firefox driver extension). When set this argument is
74# passed to "grep -E" to remove reporting of these shared objects.
75
76inherit eutils java-utils-2 multilib toolchain-funcs ruby-utils
50 77
51EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup 78EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
52 79
53case ${EAPI} in 80case ${EAPI} in
54 0|1) 81 0|1)
55 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; 82 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
56 2) ;; 83 2|3) ;;
84 4|5)
85 # S is no longer automatically assigned when it doesn't exist.
86 S="${WORKDIR}"
87 ;;
57 *) 88 *)
58 die "Unknown EAPI=${EAPI} for ruby-ng.eclass" 89 die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
59esac 90esac
60 91
61# @FUNCTION: ruby_implementation_depend 92# @FUNCTION: ruby_implementation_depend
67# `target' has to be one of the valid values for USE_RUBY (see above) 98# `target' has to be one of the valid values for USE_RUBY (see above)
68# 99#
69# Set `comparator' and `version' to include a comparator (=, >=, etc.) and a 100# Set `comparator' and `version' to include a comparator (=, >=, etc.) and a
70# version string to the returned string 101# version string to the returned string
71ruby_implementation_depend() { 102ruby_implementation_depend() {
72 local rubypn= 103 _ruby_implementation_depend $1
73 local rubyslot=
74
75 case $1 in
76 ruby18)
77 rubypn="dev-lang/ruby"
78 rubyslot=":1.8"
79 ;;
80 ruby19)
81 rubypn="dev-lang/ruby"
82 rubyslot=":1.9"
83 ;;
84 ree18)
85 rubypn="dev-lang/ruby-enterprise"
86 rubyslot=":1.8"
87 ;;
88 jruby)
89 rubypn="dev-java/jruby"
90 rubyslot=""
91 ;;
92 *) die "$1: unknown Ruby implementation"
93 esac
94
95 echo "$2${rubypn}$3${rubyslot}"
96} 104}
97 105
98# @FUNCTION: ruby_samelib 106# @FUNCTION: ruby_samelib
99# @RETURN: use flag string with current ruby implementations 107# @RETURN: use flag string with current ruby implementations
100# @DESCRIPTION: 108# @DESCRIPTION:
110 done 118 done
111 119
112 echo "[${res%,}]" 120 echo "[${res%,}]"
113} 121}
114 122
123_ruby_atoms_samelib_generic() {
124 eshopts_push -o noglob
125 echo "RUBYTARGET? ("
126 for token in $*; do
127 case "$token" in
128 "||" | "(" | ")" | *"?")
129 echo "${token}" ;;
130 *])
131 echo "${token%[*}[RUBYTARGET,${token/*[}" ;;
132 *)
133 echo "${token}[RUBYTARGET]" ;;
134 esac
135 done
136 echo ")"
137 eshopts_pop
138}
139
140# @FUNCTION: ruby_implementation_command
141# @RETURN: the path to the given ruby implementation
142# @DESCRIPTION:
143# Not all implementations have the same command basename as the
144# target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18
145# respectively. This function translate between the two
115_ruby_implementation_depend() { 146ruby_implementation_command() {
116 echo "ruby_targets_${1}? ( ${2}[ruby_targets_${1}] )" 147 local _ruby_name=$1
117}
118 148
119_ruby_add_bdepend() { 149 # Add all USE_RUBY values where the flag name diverts from the binary here
120 local atom=$1 150 case $1 in
151 ree18)
152 _ruby_name=rubyee18
153 ;;
154 esac
155
156 echo $(type -p ${_ruby_name} 2>/dev/null)
157}
158
159_ruby_atoms_samelib() {
160 local atoms=$(_ruby_atoms_samelib_generic "$*")
161
162 for _ruby_implementation in $USE_RUBY; do
163 echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
164 done
165}
166
167_ruby_wrap_conditions() {
121 local conditions=$2 168 local conditions="$1"
169 local atoms="$2"
122 170
123 for condition in $conditions; do 171 for condition in $conditions; do
124 atom="${condition}? ( ${atom} )" 172 atoms="${condition}? ( ${atoms} )"
125 done 173 done
126 174
127 DEPEND="${DEPEND} ${atom}" 175 echo "$atoms"
176}
177
178# @FUNCTION: ruby_add_rdepend
179# @USAGE: dependencies
180# @DESCRIPTION:
181# Adds the specified dependencies, with use condition(s) to RDEPEND,
182# taking the current set of ruby targets into account. This makes sure
183# that all ruby dependencies of the package are installed for the same
184# ruby targets. Use this function for all ruby dependencies instead of
185# setting RDEPEND yourself. The list of atoms uses the same syntax as
186# normal dependencies.
187#
188# Note: runtime dependencies are also added as build-time test
189# dependencies.
190ruby_add_rdepend() {
191 case $# in
192 1) ;;
193 2)
194 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF"
195 ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")"
196 return
197 ;;
198 *)
199 die "bad number of arguments to $0"
200 ;;
201 esac
202
203 local dependency=$(_ruby_atoms_samelib "$1")
204
205 RDEPEND="${RDEPEND} $dependency"
206
207 # Add the dependency as a test-dependency since we're going to
208 # execute the code during test phase.
209 DEPEND="${DEPEND} test? ( ${dependency} )"
210 has test "$IUSE" || IUSE="${IUSE} test"
211}
212
213# @FUNCTION: ruby_add_bdepend
214# @USAGE: dependencies
215# @DESCRIPTION:
216# Adds the specified dependencies, with use condition(s) to DEPEND,
217# taking the current set of ruby targets into account. This makes sure
218# that all ruby dependencies of the package are installed for the same
219# ruby targets. Use this function for all ruby dependencies instead of
220# setting DEPEND yourself. The list of atoms uses the same syntax as
221# normal dependencies.
222ruby_add_bdepend() {
223 case $# in
224 1) ;;
225 2)
226 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF"
227 ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")"
228 return
229 ;;
230 *)
231 die "bad number of arguments to $0"
232 ;;
233 esac
234
235 local dependency=$(_ruby_atoms_samelib "$1")
236
237 DEPEND="${DEPEND} $dependency"
128 RDEPEND="${RDEPEND}" 238 RDEPEND="${RDEPEND}"
129} 239}
130 240
131_ruby_add_rdepend() { 241# @FUNCTION: ruby_get_use_implementations
132 local atom=$1 242# @DESCRIPTION:
133 local conditions=$2 243# Gets an array of ruby use targets enabled by the user
134 244ruby_get_use_implementations() {
135 for condition in $conditions; do 245 local i implementation
136 atom="${condition}? ( ${atom} )" 246 for implementation in ${USE_RUBY}; do
247 use ruby_targets_${implementation} && i+=" ${implementation}"
137 done 248 done
249 echo $i
250}
138 251
252# @FUNCTION: ruby_get_use_targets
253# @DESCRIPTION:
254# Gets an array of ruby use targets that the ebuild sets
255ruby_get_use_targets() {
256 local t implementation
257 for implementation in ${USE_RUBY}; do
258 t+=" ruby_targets_${implementation}"
259 done
260 echo $t
261}
262
263# @FUNCTION: ruby_implementations_depend
264# @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
265# @DESCRIPTION:
266# Produces the dependency string for the various implementations of ruby
267# which the package is being built against. This should not be used when
268# RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
269# confuse this function with ruby_implementation_depend().
270#
271# @EXAMPLE:
272# EAPI=4
273# RUBY_OPTIONAL=yes
274#
275# inherit ruby-ng
276# ...
277# DEPEND="ruby? ( $(ruby_implementations_depend) )"
139 RDEPEND="${RDEPEND} ${atom}" 278# RDEPEND="${DEPEND}"
140 _ruby_add_bdepend "$atom" test 279ruby_implementations_depend() {
141} 280 local depend
142
143# @FUNCTION: ruby_add_rdepend
144# @USAGE: [conditions] atom
145# @DESCRIPTION:
146# Adds the specified atom(s) with optional use condition(s) to
147# RDEPEND, taking the current set of ruby targets into account. This
148# makes sure that all ruby dependencies of the package are installed
149# for the same ruby targets. Use this function for all ruby
150# dependencies instead of setting RDEPEND yourself. Both atom and
151# conditions can be a space-separated list of atoms or conditions.
152ruby_add_rdepend() {
153 local atoms=
154 local conditions=
155 case $# in
156 1)
157 atoms=$1
158 ;;
159 2)
160 conditions=$1
161 atoms=$2
162 ;;
163 *)
164 die "bad number of arguments to $0"
165 ;;
166 esac
167
168 for atom in $atoms; do
169 _ruby_add_rdepend "${atom}$(ruby_samelib)" "$conditions"
170 done
171}
172
173# @FUNCTION: ruby_add_bdepend
174# @USAGE: [conditions] atom
175# @DESCRIPTION:
176# Adds the specified atom(s) with optional use condition(s) to both
177# DEPEND and RDEPEND, taking the current set of ruby targets into
178# account. This makes sure that all ruby dependencies of the package
179# are installed for the same ruby targets. Use this function for all
180# ruby dependencies instead of setting DEPEND and RDEPEND
181# yourself. Both atom and conditions can be a space-separated list of
182# atoms or conditions.
183ruby_add_bdepend() {
184 local atoms=
185 local conditions=
186 case $# in
187 1)
188 atoms=$1
189 ;;
190 2)
191 conditions=$1
192 atoms=$2
193 ;;
194 *)
195 die "bad number of arguments to $0"
196 ;;
197 esac
198
199 for atom in $atoms; do
200 _ruby_add_bdepend "${atom}$(ruby_samelib)" "$conditions"
201 done
202}
203
204for _ruby_implementation in $USE_RUBY; do 281 for _ruby_implementation in ${USE_RUBY}; do
205 IUSE="${IUSE} ruby_targets_${_ruby_implementation}" 282 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
283 done
284 echo "${depend}"
285}
206 286
287IUSE+=" $(ruby_get_use_targets)"
207 # If you specify RUBY_OPTIONAL you also need to take care of 288# If you specify RUBY_OPTIONAL you also need to take care of
208 # ruby useflag and dependency. 289# ruby useflag and dependency.
209 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then 290if [[ ${RUBY_OPTIONAL} != yes ]]; then
210 DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" 291 DEPEND="${DEPEND} $(ruby_implementations_depend)"
211 RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" 292 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
293
294 case ${EAPI:-0} in
295 4|5)
296 REQUIRED_USE+=" || ( $(ruby_get_use_targets) )"
297 ;;
298 esac
212 fi 299fi
213done
214 300
215_ruby_invoke_environment() { 301_ruby_invoke_environment() {
216 old_S=${S} 302 old_S=${S}
303 case ${EAPI} in
304 4|5)
305 if [ -z ${RUBY_S} ]; then
306 sub_S=${P}
307 else
308 sub_S=${RUBY_S}
309 fi
310 ;;
311 *)
217 sub_S=${S#${WORKDIR}} 312 sub_S=${S#${WORKDIR}/}
313 ;;
314 esac
315
316 # Special case, for the always-lovely GitHub fetches. With this,
317 # we allow the star glob to just expand to whatever directory it's
318 # called.
319 if [[ ${sub_S} = *"*"* ]]; then
320 case ${EAPI} in
321 2|3)
322 #The old method of setting S depends on undefined package
323 # manager behaviour, so encourage upgrading to EAPI=4.
324 eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
325 ;;
326 esac
327 pushd "${WORKDIR}"/all &>/dev/null
328 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
329 popd &>/dev/null
330 fi
218 331
219 environment=$1; shift 332 environment=$1; shift
220 333
221 my_WORKDIR="${WORKDIR}"/${environment} 334 my_WORKDIR="${WORKDIR}"/${environment}
222 S="${my_WORKDIR}"/"${sub_S}" 335 S="${my_WORKDIR}"/"${sub_S}"
240 local invoked=no 353 local invoked=no
241 for _ruby_implementation in ${USE_RUBY}; do 354 for _ruby_implementation in ${USE_RUBY}; do
242 # only proceed if it's requested 355 # only proceed if it's requested
243 use ruby_targets_${_ruby_implementation} || continue 356 use ruby_targets_${_ruby_implementation} || continue
244 357
245 RUBY=$(type -p $_ruby_implementation 2>/dev/null) 358 RUBY=$(ruby_implementation_command ${_ruby_implementation})
246 invoked=yes 359 invoked=yes
247 360
248 if [[ -n "$1" ]]; then 361 if [[ -n "$1" ]]; then
249 _ruby_invoke_environment $_ruby_implementation "$@" 362 _ruby_invoke_environment ${_ruby_implementation} "$@"
250 fi 363 fi
251 364
252 unset RUBY 365 unset RUBY
253 done 366 done
254 367
255 [[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf." 368 if [[ ${invoked} == "no" ]]; then
369 eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf."
370 eerror "Compatible targets for this package are: ${USE_RUBY}"
371 eerror
372 eerror "See http://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information."
373 eerror
374 die "No compatible Ruby target selected."
375 fi
256} 376}
257 377
258# @FUNCTION: ruby-ng_pkg_setup 378# @FUNCTION: ruby-ng_pkg_setup
259# @DESCRIPTION: 379# @DESCRIPTION:
260# Check whether at least one ruby target implementation is present. 380# Check whether at least one ruby target implementation is present.
261ruby-ng_pkg_setup() { 381ruby-ng_pkg_setup() {
262 # This only checks that at least one implementation is present 382 # This only checks that at least one implementation is present
263 # before doing anything; by leaving the parameters empty we know 383 # before doing anything; by leaving the parameters empty we know
264 # it's a special case. 384 # it's a special case.
265 _ruby_each_implementation 385 _ruby_each_implementation
386
387 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
266} 388}
267 389
268# @FUNCTION: ruby-ng_src_unpack 390# @FUNCTION: ruby-ng_src_unpack
269# @DESCRIPTION: 391# @DESCRIPTION:
270# Unpack the source archive, including gems. 392# Unpack the source archive.
271ruby-ng_src_unpack() { 393ruby-ng_src_unpack() {
272 mkdir "${WORKDIR}"/all 394 mkdir "${WORKDIR}"/all
273 pushd "${WORKDIR}"/all &>/dev/null 395 pushd "${WORKDIR}"/all &>/dev/null
274 396
275 # We don't support an each-unpack, it's either all or nothing! 397 # We don't support an each-unpack, it's either all or nothing!
300} 422}
301 423
302_ruby_source_copy() { 424_ruby_source_copy() {
303 # Until we actually find a reason not to, we use hardlinks, this 425 # Until we actually find a reason not to, we use hardlinks, this
304 # should reduce the amount of disk space that is wasted by this. 426 # should reduce the amount of disk space that is wasted by this.
305 cp -prl all ${_ruby_implementation} \ 427 cp -prlP all ${_ruby_implementation} \
306 || die "Unable to copy ${_ruby_implementation} environment" 428 || die "Unable to copy ${_ruby_implementation} environment"
307} 429}
308 430
309# @FUNCTION: ruby-ng_src_prepare 431# @FUNCTION: ruby-ng_src_prepare
310# @DESCRIPTION: 432# @DESCRIPTION:
316 # almost every other ebuild. 438 # almost every other ebuild.
317 find . -name '._*' -delete 439 find . -name '._*' -delete
318 440
319 _ruby_invoke_environment all _ruby_apply_patches 441 _ruby_invoke_environment all _ruby_apply_patches
320 442
443 _PHASE="source copy" \
321 _ruby_each_implementation _ruby_source_copy 444 _ruby_each_implementation _ruby_source_copy
322 445
323 if type each_ruby_prepare &>/dev/null; then 446 if type each_ruby_prepare &>/dev/null; then
324 _ruby_each_implementation each_ruby_prepare 447 _ruby_each_implementation each_ruby_prepare
325 fi 448 fi
326} 449}
360 type all_ruby_test &>/dev/null && \ 483 type all_ruby_test &>/dev/null && \
361 _ruby_invoke_environment all all_ruby_test 484 _ruby_invoke_environment all all_ruby_test
362} 485}
363 486
364_each_ruby_check_install() { 487_each_ruby_check_install() {
488 local scancmd=scanelf
489 # we have a Mach-O object here
490 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
491
492 has "${EAPI}" 2 && ! use prefix && EPREFIX=
493
365 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') 494 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]')
366 local libruby_soname=$(scanelf -qS "/usr/$(get_libdir)/${libruby_basename}" | awk '{ print $1 }') 495 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
496 local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]')
497 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
498
499 # Look for wrong files in sitedir
500 # if [[ -d "${D}${sitedir}" ]]; then
501 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
502 # if [[ -n ${f} ]]; then
503 # eerror "Found files in sitedir, outsite sitelibdir:"
504 # eerror "${f}"
505 # die "Misplaced files in sitedir"
506 # fi
507 # fi
367 508
368 # The current implementation lacks libruby (i.e.: jruby) 509 # The current implementation lacks libruby (i.e.: jruby)
369 [[ -z ${libruby_soname} ]] && return 0 510 [[ -z ${libruby_soname} ]] && return 0
370 511
371 scanelf -qnR "${D}"/$(dirname $(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')) \ 512 # Check also the gems directory, since we could be installing compiled
513 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
514 # that's what changes between two implementations (otherwise you'd get false
515 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
516 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
372 | fgrep -v "${libruby_soname}" \ 517 | fgrep -v "${libruby_soname}" \
518 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
373 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log 519 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
374 520
375 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then 521 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
376 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}" 522 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
377 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) 523 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
378 die "Missing links to ${libruby}" 524 die "Missing links to ${libruby_soname}"
379 fi 525 fi
380} 526}
381 527
382# @FUNCTION: ruby-ng_src_install 528# @FUNCTION: ruby-ng_src_install
383# @DESCRIPTION: 529# @DESCRIPTION:
392 538
393 _PHASE="check install" \ 539 _PHASE="check install" \
394 _ruby_each_implementation _each_ruby_check_install 540 _ruby_each_implementation _each_ruby_check_install
395} 541}
396 542
543# @FUNCTION: ruby_rbconfig_value
544# @USAGE: rbconfig item
545# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
546ruby_rbconfig_value() {
547 echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']")
548}
549
397# @FUNCTION: doruby 550# @FUNCTION: doruby
398# @USAGE: file [file...] 551# @USAGE: file [file...]
399# @DESCRIPTION: 552# @DESCRIPTION:
400# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. 553# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}.
401doruby() { 554doruby() {
555 [[ -z ${RUBY} ]] && die "\$RUBY is not set"
556 has "${EAPI}" 2 && ! use prefix && EPREFIX=
402 ( # don't want to pollute calling env 557 ( # don't want to pollute calling env
403 insinto $(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]') 558 sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
559 insinto ${sitelibdir#${EPREFIX}}
404 insopts -m 0644 560 insopts -m 0644
405 doins "$@" 561 doins "$@"
406 ) || die "failed to install $@" 562 ) || die "failed to install $@"
407} 563}
408 564
409# @FUNCTION: ruby_get_libruby 565# @FUNCTION: ruby_get_libruby
410# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. 566# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
411ruby_get_libruby() { 567ruby_get_libruby() {
412 ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' 568 ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])'
413} 569}
414 570
415# @FUNCTION: ruby_get_hdrdir 571# @FUNCTION: ruby_get_hdrdir
416# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. 572# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
417ruby_get_hdrdir() { 573ruby_get_hdrdir() {
418 local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]') 574 local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
419 575
420 if [[ "${rubyhdrdir}" = "nil" ]] ; then 576 if [[ "${rubyhdrdir}" = "nil" ]] ; then
421 rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]') 577 rubyhdrdir=$(ruby_rbconfig_value 'archdir')
422 fi 578 fi
423 579
424 echo "${rubyhdrdir}" 580 echo "${rubyhdrdir}"
425} 581}
582
583# @FUNCTION: ruby_get_version
584# @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
585ruby_get_version() {
586 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
587
588 echo $(${ruby} -e 'puts RUBY_VERSION')
589}
590
591# @FUNCTION: ruby_get_implementation
592# @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
593ruby_get_implementation() {
594 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
595
596 case $(${ruby} --version) in
597 *Enterprise*)
598 echo "ree"
599 ;;
600 *jruby*)
601 echo "jruby"
602 ;;
603 *rubinius*)
604 echo "rbx"
605 ;;
606 *)
607 echo "mri"
608 ;;
609 esac
610}
611
612# @FUNCTION: ruby-ng_rspec <arguments>
613# @DESCRIPTION:
614# This is simply a wrapper around the rspec command (executed by $RUBY})
615# which also respects TEST_VERBOSE and NOCOLOR environment variables.
616# Optionally takes arguments to pass on to the rspec invocation. The
617# environment variable RSPEC_VERSION can be used to control the specific
618# rspec version that must be executed. It defaults to 2 for historical
619# compatibility.
620ruby-ng_rspec() {
621 local version=${RSPEC_VERSION-2}
622 local files="$@"
623
624 # Explicitly pass the expected spec directory since the versioned
625 # rspec wrappers don't handle this automatically.
626 if [ ${#@} -eq 0 ]; then
627 files="spec"
628 fi
629
630 if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
631 ewarn "Missing dev-ruby/rspec in \${DEPEND}"
632 fi
633
634 local rspec_params=
635 case ${NOCOLOR} in
636 1|yes|true)
637 rspec_params+=" --no-color"
638 ;;
639 *)
640 rspec_params+=" --color"
641 ;;
642 esac
643
644 case ${TEST_VERBOSE} in
645 1|yes|true)
646 rspec_params+=" --format documentation"
647 ;;
648 *)
649 rspec_params+=" --format progress"
650 ;;
651 esac
652
653 ${RUBY} -S rspec-${version} ${rspec_params} ${files} || die "rspec failed"
654}
655
656# @FUNCTION: ruby-ng_cucumber
657# @DESCRIPTION:
658# This is simply a wrapper around the cucumber command (executed by $RUBY})
659# which also respects TEST_VERBOSE and NOCOLOR environment variables.
660ruby-ng_cucumber() {
661 if [[ ${DEPEND} != *"dev-util/cucumber"* ]]; then
662 ewarn "Missing dev-util/cucumber in \${DEPEND}"
663 fi
664
665 local cucumber_params=
666 case ${NOCOLOR} in
667 1|yes|true)
668 cucumber_params+=" --no-color"
669 ;;
670 *)
671 cucumber_params+=" --color"
672 ;;
673 esac
674
675 case ${TEST_VERBOSE} in
676 1|yes|true)
677 cucumber_params+=" --format pretty"
678 ;;
679 *)
680 cucumber_params+=" --format progress"
681 ;;
682 esac
683
684 if [[ ${RUBY} == *jruby ]]; then
685 ewarn "Skipping cucumber tests on JRuby (unsupported)."
686 return 0
687 fi
688
689 ${RUBY} -S cucumber ${cucumber_params} "$@" || die "cucumber failed"
690}
691
692# @FUNCTION: ruby-ng_testrb-2
693# @DESCRIPTION:
694# This is simply a replacement for the testrb command that load the test
695# files and execute them, with test-unit 2.x. This actually requires
696# either an old test-unit-2 version or 2.5.1-r1 or later, as they remove
697# their script and we installed a broken wrapper for a while.
698# This also respects TEST_VERBOSE and NOCOLOR environment variables.
699ruby-ng_testrb-2() {
700 if [[ ${DEPEND} != *"dev-ruby/test-unit"* ]]; then
701 ewarn "Missing dev-ruby/test-unit in \${DEPEND}"
702 fi
703
704 local testrb_params=
705 case ${NOCOLOR} in
706 1|yes|true)
707 testrb_params+=" --no-use-color"
708 ;;
709 *)
710 testrb_params+=" --use-color=auto"
711 ;;
712 esac
713
714 case ${TEST_VERBOSE} in
715 1|yes|true)
716 testrb_params+=" --verbose=verbose"
717 ;;
718 *)
719 testrb_params+=" --verbose=normal"
720 ;;
721 esac
722
723 ${RUBY} -S testrb-2 ${testrb_params} "$@" || die "testrb-2 failed"
724}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.57

  ViewVC Help
Powered by ViewVC 1.1.20