| 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.28 2010/09/10 13:03:39 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.40 2011/10/05 17:46:20 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 | # |
| … | |
… | |
| 44 | # @DESCRIPTION: |
41 | # @DESCRIPTION: |
| 45 | # 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. |
| 46 | |
43 | |
| 47 | # @ECLASS-VARIABLE: RUBY_OPTIONAL |
44 | # @ECLASS-VARIABLE: RUBY_OPTIONAL |
| 48 | # @DESCRIPTION: |
45 | # @DESCRIPTION: |
| 49 | # 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. |
| 50 | |
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. |
|
|
70 | |
| 51 | inherit eutils toolchain-funcs |
71 | inherit eutils java-utils-2 toolchain-funcs |
| 52 | |
72 | |
| 53 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup |
73 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup |
| 54 | |
74 | |
| 55 | case ${EAPI} in |
75 | case ${EAPI} in |
| 56 | 0|1) |
76 | 0|1) |
| 57 | die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; |
77 | die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; |
| 58 | 2|3) ;; |
78 | 2|3) ;; |
|
|
79 | 4) |
|
|
80 | # S is no longer automatically assigned when it doesn't exist. |
|
|
81 | S="${WORKDIR}" |
|
|
82 | ;; |
| 59 | *) |
83 | *) |
| 60 | die "Unknown EAPI=${EAPI} for ruby-ng.eclass" |
84 | die "Unknown EAPI=${EAPI} for ruby-ng.eclass" |
| 61 | esac |
85 | esac |
| 62 | |
86 | |
| 63 | # @FUNCTION: ruby_implementation_depend |
87 | # @FUNCTION: ruby_implementation_depend |
| … | |
… | |
| 199 | RDEPEND="${RDEPEND} $dependency" |
223 | RDEPEND="${RDEPEND} $dependency" |
| 200 | |
224 | |
| 201 | # 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 |
| 202 | # execute the code during test phase. |
226 | # execute the code during test phase. |
| 203 | DEPEND="${DEPEND} test? ( ${dependency} )" |
227 | DEPEND="${DEPEND} test? ( ${dependency} )" |
| 204 | hasq test "$IUSE" || IUSE="${IUSE} test" |
228 | has test "$IUSE" || IUSE="${IUSE} test" |
| 205 | } |
229 | } |
| 206 | |
230 | |
| 207 | # @FUNCTION: ruby_add_bdepend |
231 | # @FUNCTION: ruby_add_bdepend |
| 208 | # @USAGE: dependencies |
232 | # @USAGE: dependencies |
| 209 | # @DESCRIPTION: |
233 | # @DESCRIPTION: |
| … | |
… | |
| 230 | |
254 | |
| 231 | DEPEND="${DEPEND} $dependency" |
255 | DEPEND="${DEPEND} $dependency" |
| 232 | RDEPEND="${RDEPEND}" |
256 | RDEPEND="${RDEPEND}" |
| 233 | } |
257 | } |
| 234 | |
258 | |
|
|
259 | # @FUNCTION: ruby_get_use_implementations |
|
|
260 | # @DESCRIPTION: |
|
|
261 | # Gets an array of ruby use targets enabled by the user |
|
|
262 | ruby_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 |
|
|
273 | ruby_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 | |
|
|
281 | if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then |
|
|
282 | REQUIRED_USE=" || ( $(ruby_get_use_targets) )" |
|
|
283 | fi |
|
|
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}" |
|
|
301 | ruby_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 | |
| 235 | for _ruby_implementation in $USE_RUBY; do |
309 | for _ruby_implementation in ${USE_RUBY}; do |
| 236 | IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
310 | IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
| 237 | |
|
|
| 238 | # If you specify RUBY_OPTIONAL you also need to take care of |
|
|
| 239 | # ruby useflag and dependency. |
|
|
| 240 | if [[ ${RUBY_OPTIONAL} != "yes" ]]; then |
|
|
| 241 | DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
|
|
| 242 | RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
|
|
| 243 | fi |
|
|
| 244 | done |
311 | done |
|
|
312 | # If you specify RUBY_OPTIONAL you also need to take care of |
|
|
313 | # ruby useflag and dependency. |
|
|
314 | if [[ ${RUBY_OPTIONAL} != yes ]]; then |
|
|
315 | DEPEND="${DEPEND} $(ruby_implementations_depend)" |
|
|
316 | RDEPEND="${RDEPEND} $(ruby_implementations_depend)" |
|
|
317 | fi |
| 245 | |
318 | |
| 246 | _ruby_invoke_environment() { |
319 | _ruby_invoke_environment() { |
| 247 | 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 | *) |
| 248 | sub_S=${S#${WORKDIR}/} |
330 | sub_S=${S#${WORKDIR}/} |
|
|
331 | ;; |
|
|
332 | esac |
| 249 | |
333 | |
| 250 | # Special case, for the always-lovely GitHub fetches. With this, |
334 | # Special case, for the always-lovely GitHub fetches. With this, |
| 251 | # 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 |
| 252 | # called. |
336 | # called. |
| 253 | 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 |
| 254 | pushd "${WORKDIR}"/all &>/dev/null |
345 | pushd "${WORKDIR}"/all &>/dev/null |
| 255 | sub_S=$(eval ls -d ${sub_S} 2>/dev/null) |
346 | sub_S=$(eval ls -d ${sub_S} 2>/dev/null) |
| 256 | popd &>/dev/null |
347 | popd &>/dev/null |
| 257 | fi |
348 | fi |
| 258 | |
349 | |
| … | |
… | |
| 301 | ruby-ng_pkg_setup() { |
392 | ruby-ng_pkg_setup() { |
| 302 | # This only checks that at least one implementation is present |
393 | # This only checks that at least one implementation is present |
| 303 | # before doing anything; by leaving the parameters empty we know |
394 | # before doing anything; by leaving the parameters empty we know |
| 304 | # it's a special case. |
395 | # it's a special case. |
| 305 | _ruby_each_implementation |
396 | _ruby_each_implementation |
|
|
397 | |
|
|
398 | use ruby_targets_jruby && java-pkg_setup-vm |
| 306 | } |
399 | } |
| 307 | |
400 | |
| 308 | # @FUNCTION: ruby-ng_src_unpack |
401 | # @FUNCTION: ruby-ng_src_unpack |
| 309 | # @DESCRIPTION: |
402 | # @DESCRIPTION: |
| 310 | # Unpack the source archive. |
403 | # Unpack the source archive. |
| … | |
… | |
| 431 | # extensions via ruby-fakegem; make sure to check only in sitelibdir, since |
524 | # extensions via ruby-fakegem; make sure to check only in sitelibdir, since |
| 432 | # that's what changes between two implementations (otherwise you'd get false |
525 | # that's what changes between two implementations (otherwise you'd get false |
| 433 | # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) |
526 | # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) |
| 434 | ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ |
527 | ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ |
| 435 | | fgrep -v "${libruby_soname}" \ |
528 | | fgrep -v "${libruby_soname}" \ |
|
|
529 | | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \ |
| 436 | > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log |
530 | > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log |
| 437 | |
531 | |
| 438 | if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then |
532 | if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then |
| 439 | ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}" |
533 | ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}" |
| 440 | ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) |
534 | ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) |