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