/[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.11
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2009 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.11 2010/04/26 15:07:58 a3li 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#
119_ruby_add_bdepend() { 119_ruby_add_bdepend() {
120 local atom=$1 120 local atom=$1
121 local conditions=$2 121 local conditions=$2
122 122
123 for condition in $conditions; do 123 for condition in $conditions; do
124 hasq $condition "$IUSE" || IUSE="${IUSE} $condition"
124 atom="${condition}? ( ${atom} )" 125 atom="${condition}? ( ${atom} )"
125 done 126 done
126 127
127 DEPEND="${DEPEND} ${atom}" 128 DEPEND="${DEPEND} ${atom}"
128 RDEPEND="${RDEPEND}" 129 RDEPEND="${RDEPEND}"
131_ruby_add_rdepend() { 132_ruby_add_rdepend() {
132 local atom=$1 133 local atom=$1
133 local conditions=$2 134 local conditions=$2
134 135
135 for condition in $conditions; do 136 for condition in $conditions; do
137 hasq $condition "$IUSE" || IUSE="${IUSE} $condition"
136 atom="${condition}? ( ${atom} )" 138 atom="${condition}? ( ${atom} )"
137 done 139 done
138 140
139 RDEPEND="${RDEPEND} ${atom}" 141 RDEPEND="${RDEPEND} ${atom}"
140 _ruby_add_bdepend "$atom" test 142 _ruby_add_bdepend "$atom" test
240 local invoked=no 242 local invoked=no
241 for _ruby_implementation in ${USE_RUBY}; do 243 for _ruby_implementation in ${USE_RUBY}; do
242 # only proceed if it's requested 244 # only proceed if it's requested
243 use ruby_targets_${_ruby_implementation} || continue 245 use ruby_targets_${_ruby_implementation} || continue
244 246
247 local _ruby_name=$_ruby_implementation
248
249 # Add all USE_RUBY values where the flag name diverts from the binary here
250 case $_ruby_implementation in
251 ree18)
252 _ruby_name=rubyee18
253 ;;
254 esac
255
245 RUBY=$(type -p $_ruby_implementation 2>/dev/null) 256 RUBY=$(type -p $_ruby_name 2>/dev/null)
246 invoked=yes 257 invoked=yes
247 258
248 if [[ -n "$1" ]]; then 259 if [[ -n "$1" ]]; then
249 _ruby_invoke_environment $_ruby_implementation "$@" 260 _ruby_invoke_environment $_ruby_implementation "$@"
250 fi 261 fi
265 _ruby_each_implementation 276 _ruby_each_implementation
266} 277}
267 278
268# @FUNCTION: ruby-ng_src_unpack 279# @FUNCTION: ruby-ng_src_unpack
269# @DESCRIPTION: 280# @DESCRIPTION:
270# Unpack the source archive, including gems. 281# Unpack the source archive.
271ruby-ng_src_unpack() { 282ruby-ng_src_unpack() {
272 mkdir "${WORKDIR}"/all 283 mkdir "${WORKDIR}"/all
273 pushd "${WORKDIR}"/all &>/dev/null 284 pushd "${WORKDIR}"/all &>/dev/null
274 285
275 # We don't support an each-unpack, it's either all or nothing! 286 # We don't support an each-unpack, it's either all or nothing!
316 # almost every other ebuild. 327 # almost every other ebuild.
317 find . -name '._*' -delete 328 find . -name '._*' -delete
318 329
319 _ruby_invoke_environment all _ruby_apply_patches 330 _ruby_invoke_environment all _ruby_apply_patches
320 331
332 _PHASE="source copy" \
321 _ruby_each_implementation _ruby_source_copy 333 _ruby_each_implementation _ruby_source_copy
322 334
323 if type each_ruby_prepare &>/dev/null; then 335 if type each_ruby_prepare &>/dev/null; then
324 _ruby_each_implementation each_ruby_prepare 336 _ruby_each_implementation each_ruby_prepare
325 fi 337 fi
326} 338}
362} 374}
363 375
364_each_ruby_check_install() { 376_each_ruby_check_install() {
365 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') 377 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]')
366 local libruby_soname=$(scanelf -qS "/usr/$(get_libdir)/${libruby_basename}" | awk '{ print $1 }') 378 local libruby_soname=$(scanelf -qS "/usr/$(get_libdir)/${libruby_basename}" | awk '{ print $1 }')
379 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')
380 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')
381
382 # Look for wrong files in sitedir
383 if [[ -d "${D}${sitedir}" ]]; then
384 local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
385 if [[ -n ${f} ]]; then
386 eerror "Found files in sitedir, outsite sitelibdir:"
387 eerror "${f}"
388 die "Misplaced files in sitedir"
389 fi
390 fi
367 391
368 # The current implementation lacks libruby (i.e.: jruby) 392 # The current implementation lacks libruby (i.e.: jruby)
369 [[ -z ${libruby_soname} ]] && return 0 393 [[ -z ${libruby_soname} ]] && return 0
370 394
371 scanelf -qnR "${D}"/$(dirname $(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')) \ 395 scanelf -qnR "${D}${sitedir}" \
372 | fgrep -v "${libruby_soname}" \ 396 | fgrep -v "${libruby_soname}" \
373 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log 397 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
374 398
375 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then 399 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
376 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}" 400 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}"
392 416
393 _PHASE="check install" \ 417 _PHASE="check install" \
394 _ruby_each_implementation _each_ruby_check_install 418 _ruby_each_implementation _each_ruby_check_install
395} 419}
396 420
421# @FUNCTION: ruby_rbconfig_value
422# @USAGE: rbconfig item
423# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
424ruby_rbconfig_value() {
425 echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']")
426}
427
397# @FUNCTION: doruby 428# @FUNCTION: doruby
398# @USAGE: file [file...] 429# @USAGE: file [file...]
399# @DESCRIPTION: 430# @DESCRIPTION:
400# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. 431# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}.
401doruby() { 432doruby() {
433 [[ -z ${RUBY} ]] && die "\$RUBY is not set"
402 ( # don't want to pollute calling env 434 ( # don't want to pollute calling env
403 insinto $(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]') 435 insinto $(ruby_rbconfig_value 'sitelibdir')
404 insopts -m 0644 436 insopts -m 0644
405 doins "$@" 437 doins "$@"
406 ) || die "failed to install $@" 438 ) || die "failed to install $@"
407} 439}
408 440
413} 445}
414 446
415# @FUNCTION: ruby_get_hdrdir 447# @FUNCTION: ruby_get_hdrdir
416# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. 448# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
417ruby_get_hdrdir() { 449ruby_get_hdrdir() {
418 local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]') 450 local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
419 451
420 if [[ "${rubyhdrdir}" = "nil" ]] ; then 452 if [[ "${rubyhdrdir}" = "nil" ]] ; then
421 rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]') 453 rubyhdrdir=$(ruby_rbconfig_value 'archdir')
422 fi 454 fi
423 455
424 echo "${rubyhdrdir}" 456 echo "${rubyhdrdir}"
425} 457}
458
459# @FUNCTION: ruby_get_version
460# @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
461ruby_get_version() {
462 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
463
464 echo $(${ruby} -e 'puts RUBY_VERSION')
465}
466
467# @FUNCTION: ruby_get_implementation
468# @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
469ruby_get_implementation() {
470 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
471
472 case $(${ruby} --version) in
473 *Enterprise*)
474 echo "ree"
475 ;;
476 *jruby*)
477 echo "jruby"
478 ;;
479 *)
480 echo "mri"
481 ;;
482 esac
483}

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

  ViewVC Help
Powered by ViewVC 1.1.20