| 1 |
a3li |
1.6 |
# Copyright 1999-2009 Gentoo Foundation |
| 2 |
graaff |
1.1 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
flameeyes |
1.14 |
# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.13 2010/05/01 16:05:45 flameeyes Exp $ |
| 4 |
graaff |
1.1 |
# |
| 5 |
|
|
# @ECLASS: ruby-ng.eclass |
| 6 |
|
|
# @MAINTAINER: |
| 7 |
|
|
# Ruby herd <ruby@gentoo.org> |
| 8 |
|
|
# |
| 9 |
|
|
# Author: Diego E. Pettenò <flameeyes@gentoo.org> |
| 10 |
|
|
# |
| 11 |
|
|
# Author: Alex Legler <a3li@gentoo.org> |
| 12 |
|
|
# |
| 13 |
|
|
# Author: Hans de Graaff <graaff@gentoo.org> |
| 14 |
|
|
# |
| 15 |
|
|
# @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots. |
| 16 |
|
|
# @DESCRIPTION: |
| 17 |
|
|
# The Ruby eclass is designed to allow an easier installation of Ruby packages |
| 18 |
|
|
# and their incorporation into the Gentoo Linux system. |
| 19 |
|
|
# |
| 20 |
|
|
# Currently available targets are: |
| 21 |
|
|
# * ruby18 - Ruby (MRI) 1.8.x |
| 22 |
|
|
# * ruby19 - Ruby (MRI) 1.9.x |
| 23 |
|
|
# * ree18 - Ruby Enterprise Edition 1.8.x |
| 24 |
|
|
# * jruby - JRuby |
| 25 |
|
|
# |
| 26 |
|
|
# This eclass does not define the implementation of the configure, |
| 27 |
|
|
# compile, test, or install phases. Instead, the default phases are |
| 28 |
|
|
# 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 |
|
|
# Ruby implementations, as follows: |
| 31 |
|
|
# |
| 32 |
|
|
# * each_ruby_configure |
| 33 |
|
|
# * all_ruby_configure |
| 34 |
|
|
|
| 35 |
|
|
# @ECLASS-VARIABLE: USE_RUBY |
| 36 |
|
|
# @DESCRIPTION: |
| 37 |
|
|
# 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 |
| 39 |
|
|
# default. All ebuilds are expected to set this variable. |
| 40 |
|
|
|
| 41 |
|
|
# @ECLASS-VARIABLE: RUBY_PATCHES |
| 42 |
|
|
# @DESCRIPTION: |
| 43 |
|
|
# A String or Array of filenames of patches to apply to all implementations. |
| 44 |
|
|
|
| 45 |
|
|
# @ECLASS-VARIABLE: RUBY_OPTIONAL |
| 46 |
|
|
# @DESCRIPTION: |
| 47 |
|
|
# Set the value to "yes" to make the dependency on a Ruby interpreter optional. |
| 48 |
|
|
|
| 49 |
|
|
inherit eutils toolchain-funcs |
| 50 |
|
|
|
| 51 |
|
|
EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup |
| 52 |
|
|
|
| 53 |
|
|
case ${EAPI} in |
| 54 |
|
|
0|1) |
| 55 |
|
|
die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; |
| 56 |
|
|
2) ;; |
| 57 |
|
|
*) |
| 58 |
|
|
die "Unknown EAPI=${EAPI} for ruby-ng.eclass" |
| 59 |
|
|
esac |
| 60 |
|
|
|
| 61 |
|
|
# @FUNCTION: ruby_implementation_depend |
| 62 |
|
|
# @USAGE: target [comparator [version]] |
| 63 |
|
|
# @RETURN: Package atom of a Ruby implementation to be used in dependencies. |
| 64 |
|
|
# @DESCRIPTION: |
| 65 |
|
|
# This function returns the formal package atom for a Ruby implementation. |
| 66 |
|
|
# |
| 67 |
|
|
# `target' has to be one of the valid values for USE_RUBY (see above) |
| 68 |
|
|
# |
| 69 |
|
|
# Set `comparator' and `version' to include a comparator (=, >=, etc.) and a |
| 70 |
|
|
# version string to the returned string |
| 71 |
|
|
ruby_implementation_depend() { |
| 72 |
|
|
local rubypn= |
| 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 |
|
|
} |
| 97 |
|
|
|
| 98 |
|
|
# @FUNCTION: ruby_samelib |
| 99 |
|
|
# @RETURN: use flag string with current ruby implementations |
| 100 |
|
|
# @DESCRIPTION: |
| 101 |
|
|
# Convenience function to output the use dependency part of a |
| 102 |
|
|
# dependency. Used as a building block for ruby_add_rdepend() and |
| 103 |
|
|
# ruby_add_bdepend(), but may also be useful in an ebuild to specify |
| 104 |
|
|
# more complex dependencies. |
| 105 |
|
|
ruby_samelib() { |
| 106 |
|
|
local res= |
| 107 |
|
|
for _ruby_implementation in $USE_RUBY; do |
| 108 |
|
|
has -${_ruby_implementation} $@ || \ |
| 109 |
|
|
res="${res}ruby_targets_${_ruby_implementation}?," |
| 110 |
|
|
done |
| 111 |
|
|
|
| 112 |
|
|
echo "[${res%,}]" |
| 113 |
|
|
} |
| 114 |
|
|
|
| 115 |
|
|
_ruby_implementation_depend() { |
| 116 |
|
|
echo "ruby_targets_${1}? ( ${2}[ruby_targets_${1}] )" |
| 117 |
|
|
} |
| 118 |
|
|
|
| 119 |
|
|
_ruby_add_bdepend() { |
| 120 |
|
|
local atom=$1 |
| 121 |
|
|
local conditions=$2 |
| 122 |
|
|
|
| 123 |
|
|
for condition in $conditions; do |
| 124 |
flameeyes |
1.8 |
hasq $condition "$IUSE" || IUSE="${IUSE} $condition" |
| 125 |
graaff |
1.1 |
atom="${condition}? ( ${atom} )" |
| 126 |
|
|
done |
| 127 |
|
|
|
| 128 |
|
|
DEPEND="${DEPEND} ${atom}" |
| 129 |
|
|
RDEPEND="${RDEPEND}" |
| 130 |
|
|
} |
| 131 |
|
|
|
| 132 |
|
|
_ruby_add_rdepend() { |
| 133 |
|
|
local atom=$1 |
| 134 |
|
|
local conditions=$2 |
| 135 |
|
|
|
| 136 |
|
|
for condition in $conditions; do |
| 137 |
flameeyes |
1.8 |
hasq $condition "$IUSE" || IUSE="${IUSE} $condition" |
| 138 |
graaff |
1.1 |
atom="${condition}? ( ${atom} )" |
| 139 |
|
|
done |
| 140 |
|
|
|
| 141 |
|
|
RDEPEND="${RDEPEND} ${atom}" |
| 142 |
|
|
_ruby_add_bdepend "$atom" test |
| 143 |
|
|
} |
| 144 |
|
|
|
| 145 |
flameeyes |
1.14 |
_ruby_atoms_samelib() { |
| 146 |
|
|
local samelib=$(ruby_samelib) |
| 147 |
|
|
|
| 148 |
|
|
for token in $*; do |
| 149 |
|
|
case "$token" in |
| 150 |
|
|
"||" | "(" | ")" ) |
| 151 |
|
|
echo "${token}" ;; |
| 152 |
|
|
*) |
| 153 |
|
|
echo "${token}${samelib}" ;; |
| 154 |
|
|
esac |
| 155 |
|
|
done |
| 156 |
|
|
} |
| 157 |
|
|
|
| 158 |
graaff |
1.1 |
# @FUNCTION: ruby_add_rdepend |
| 159 |
|
|
# @USAGE: [conditions] atom |
| 160 |
|
|
# @DESCRIPTION: |
| 161 |
|
|
# Adds the specified atom(s) with optional use condition(s) to |
| 162 |
|
|
# RDEPEND, taking the current set of ruby targets into account. This |
| 163 |
|
|
# makes sure that all ruby dependencies of the package are installed |
| 164 |
|
|
# for the same ruby targets. Use this function for all ruby |
| 165 |
|
|
# dependencies instead of setting RDEPEND yourself. Both atom and |
| 166 |
|
|
# conditions can be a space-separated list of atoms or conditions. |
| 167 |
|
|
ruby_add_rdepend() { |
| 168 |
|
|
local atoms= |
| 169 |
|
|
local conditions= |
| 170 |
|
|
case $# in |
| 171 |
|
|
1) |
| 172 |
|
|
atoms=$1 |
| 173 |
|
|
;; |
| 174 |
|
|
2) |
| 175 |
|
|
conditions=$1 |
| 176 |
|
|
atoms=$2 |
| 177 |
|
|
;; |
| 178 |
|
|
*) |
| 179 |
|
|
die "bad number of arguments to $0" |
| 180 |
|
|
;; |
| 181 |
|
|
esac |
| 182 |
|
|
|
| 183 |
flameeyes |
1.14 |
_ruby_add_rdepend "$(_ruby_atoms_samelib "${atoms}")" "$conditions" |
| 184 |
graaff |
1.1 |
} |
| 185 |
|
|
|
| 186 |
|
|
# @FUNCTION: ruby_add_bdepend |
| 187 |
|
|
# @USAGE: [conditions] atom |
| 188 |
|
|
# @DESCRIPTION: |
| 189 |
|
|
# Adds the specified atom(s) with optional use condition(s) to both |
| 190 |
|
|
# DEPEND and RDEPEND, taking the current set of ruby targets into |
| 191 |
|
|
# account. This makes sure that all ruby dependencies of the package |
| 192 |
|
|
# are installed for the same ruby targets. Use this function for all |
| 193 |
|
|
# ruby dependencies instead of setting DEPEND and RDEPEND |
| 194 |
|
|
# yourself. Both atom and conditions can be a space-separated list of |
| 195 |
|
|
# atoms or conditions. |
| 196 |
|
|
ruby_add_bdepend() { |
| 197 |
|
|
local atoms= |
| 198 |
|
|
local conditions= |
| 199 |
|
|
case $# in |
| 200 |
|
|
1) |
| 201 |
|
|
atoms=$1 |
| 202 |
|
|
;; |
| 203 |
|
|
2) |
| 204 |
|
|
conditions=$1 |
| 205 |
|
|
atoms=$2 |
| 206 |
|
|
;; |
| 207 |
|
|
*) |
| 208 |
|
|
die "bad number of arguments to $0" |
| 209 |
|
|
;; |
| 210 |
|
|
esac |
| 211 |
|
|
|
| 212 |
flameeyes |
1.14 |
_ruby_add_bdepend "$(_ruby_atoms_samelib "${atoms}")" "$conditions" |
| 213 |
graaff |
1.1 |
} |
| 214 |
|
|
|
| 215 |
|
|
for _ruby_implementation in $USE_RUBY; do |
| 216 |
|
|
IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
| 217 |
|
|
|
| 218 |
|
|
# If you specify RUBY_OPTIONAL you also need to take care of |
| 219 |
|
|
# ruby useflag and dependency. |
| 220 |
|
|
if [[ ${RUBY_OPTIONAL} != "yes" ]]; then |
| 221 |
|
|
DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
| 222 |
|
|
RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
| 223 |
|
|
fi |
| 224 |
|
|
done |
| 225 |
|
|
|
| 226 |
|
|
_ruby_invoke_environment() { |
| 227 |
|
|
old_S=${S} |
| 228 |
flameeyes |
1.12 |
sub_S=${S#${WORKDIR}/} |
| 229 |
|
|
|
| 230 |
|
|
# Special case, for the always-lovely GitHub fetches. With this, |
| 231 |
|
|
# we allow the star glob to just expand to whatever directory it's |
| 232 |
|
|
# called. |
| 233 |
|
|
if [[ ${sub_S} = *"*" ]]; then |
| 234 |
|
|
pushd "${WORKDIR}"/all &>/dev/null |
| 235 |
flameeyes |
1.13 |
sub_S=$(eval ls -d ${sub_S} 2>/dev/null) |
| 236 |
flameeyes |
1.12 |
popd &>/dev/null |
| 237 |
|
|
fi |
| 238 |
graaff |
1.1 |
|
| 239 |
|
|
environment=$1; shift |
| 240 |
|
|
|
| 241 |
|
|
my_WORKDIR="${WORKDIR}"/${environment} |
| 242 |
|
|
S="${my_WORKDIR}"/"${sub_S}" |
| 243 |
|
|
|
| 244 |
|
|
if [[ -d "${S}" ]]; then |
| 245 |
|
|
pushd "$S" &>/dev/null |
| 246 |
|
|
elif [[ -d "${my_WORKDIR}" ]]; then |
| 247 |
|
|
pushd "${my_WORKDIR}" &>/dev/null |
| 248 |
|
|
else |
| 249 |
|
|
pushd "${WORKDIR}" &>/dev/null |
| 250 |
|
|
fi |
| 251 |
|
|
|
| 252 |
|
|
ebegin "Running ${_PHASE:-${EBUILD_PHASE}} phase for $environment" |
| 253 |
|
|
"$@" |
| 254 |
|
|
popd &>/dev/null |
| 255 |
|
|
|
| 256 |
|
|
S=${old_S} |
| 257 |
|
|
} |
| 258 |
|
|
|
| 259 |
|
|
_ruby_each_implementation() { |
| 260 |
|
|
local invoked=no |
| 261 |
|
|
for _ruby_implementation in ${USE_RUBY}; do |
| 262 |
|
|
# only proceed if it's requested |
| 263 |
|
|
use ruby_targets_${_ruby_implementation} || continue |
| 264 |
|
|
|
| 265 |
a3li |
1.9 |
local _ruby_name=$_ruby_implementation |
| 266 |
|
|
|
| 267 |
|
|
# Add all USE_RUBY values where the flag name diverts from the binary here |
| 268 |
|
|
case $_ruby_implementation in |
| 269 |
|
|
ree18) |
| 270 |
|
|
_ruby_name=rubyee18 |
| 271 |
|
|
;; |
| 272 |
|
|
esac |
| 273 |
|
|
|
| 274 |
|
|
RUBY=$(type -p $_ruby_name 2>/dev/null) |
| 275 |
graaff |
1.1 |
invoked=yes |
| 276 |
|
|
|
| 277 |
|
|
if [[ -n "$1" ]]; then |
| 278 |
|
|
_ruby_invoke_environment $_ruby_implementation "$@" |
| 279 |
|
|
fi |
| 280 |
|
|
|
| 281 |
|
|
unset RUBY |
| 282 |
|
|
done |
| 283 |
|
|
|
| 284 |
|
|
[[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf." |
| 285 |
|
|
} |
| 286 |
|
|
|
| 287 |
|
|
# @FUNCTION: ruby-ng_pkg_setup |
| 288 |
|
|
# @DESCRIPTION: |
| 289 |
|
|
# Check whether at least one ruby target implementation is present. |
| 290 |
|
|
ruby-ng_pkg_setup() { |
| 291 |
|
|
# This only checks that at least one implementation is present |
| 292 |
|
|
# before doing anything; by leaving the parameters empty we know |
| 293 |
|
|
# it's a special case. |
| 294 |
|
|
_ruby_each_implementation |
| 295 |
|
|
} |
| 296 |
|
|
|
| 297 |
|
|
# @FUNCTION: ruby-ng_src_unpack |
| 298 |
|
|
# @DESCRIPTION: |
| 299 |
graaff |
1.5 |
# Unpack the source archive. |
| 300 |
graaff |
1.1 |
ruby-ng_src_unpack() { |
| 301 |
|
|
mkdir "${WORKDIR}"/all |
| 302 |
|
|
pushd "${WORKDIR}"/all &>/dev/null |
| 303 |
|
|
|
| 304 |
|
|
# We don't support an each-unpack, it's either all or nothing! |
| 305 |
|
|
if type all_ruby_unpack &>/dev/null; then |
| 306 |
|
|
_ruby_invoke_environment all all_ruby_unpack |
| 307 |
|
|
else |
| 308 |
|
|
[[ -n ${A} ]] && unpack ${A} |
| 309 |
|
|
fi |
| 310 |
|
|
|
| 311 |
|
|
popd &>/dev/null |
| 312 |
|
|
} |
| 313 |
|
|
|
| 314 |
|
|
_ruby_apply_patches() { |
| 315 |
|
|
for patch in "${RUBY_PATCHES[@]}"; do |
| 316 |
|
|
if [ -f "${patch}" ]; then |
| 317 |
|
|
epatch "${patch}" |
| 318 |
|
|
elif [ -f "${FILESDIR}/${patch}" ]; then |
| 319 |
|
|
epatch "${FILESDIR}/${patch}" |
| 320 |
|
|
else |
| 321 |
|
|
die "Cannot find patch ${patch}" |
| 322 |
|
|
fi |
| 323 |
|
|
done |
| 324 |
|
|
|
| 325 |
|
|
# This is a special case: instead of executing just in the special |
| 326 |
|
|
# "all" environment, this will actually copy the effects on _all_ |
| 327 |
|
|
# the other environments, and is thus executed before the copy |
| 328 |
|
|
type all_ruby_prepare &>/dev/null && all_ruby_prepare |
| 329 |
|
|
} |
| 330 |
|
|
|
| 331 |
|
|
_ruby_source_copy() { |
| 332 |
|
|
# Until we actually find a reason not to, we use hardlinks, this |
| 333 |
|
|
# should reduce the amount of disk space that is wasted by this. |
| 334 |
|
|
cp -prl all ${_ruby_implementation} \ |
| 335 |
|
|
|| die "Unable to copy ${_ruby_implementation} environment" |
| 336 |
|
|
} |
| 337 |
|
|
|
| 338 |
|
|
# @FUNCTION: ruby-ng_src_prepare |
| 339 |
|
|
# @DESCRIPTION: |
| 340 |
|
|
# Apply patches and prepare versions for each ruby target |
| 341 |
|
|
# implementation. Also carry out common clean up tasks. |
| 342 |
|
|
ruby-ng_src_prepare() { |
| 343 |
|
|
# Way too many Ruby packages are prepared on OSX without removing |
| 344 |
|
|
# the extra data forks, we do it here to avoid repeating it for |
| 345 |
|
|
# almost every other ebuild. |
| 346 |
|
|
find . -name '._*' -delete |
| 347 |
|
|
|
| 348 |
|
|
_ruby_invoke_environment all _ruby_apply_patches |
| 349 |
|
|
|
| 350 |
flameeyes |
1.7 |
_PHASE="source copy" \ |
| 351 |
|
|
_ruby_each_implementation _ruby_source_copy |
| 352 |
graaff |
1.1 |
|
| 353 |
|
|
if type each_ruby_prepare &>/dev/null; then |
| 354 |
|
|
_ruby_each_implementation each_ruby_prepare |
| 355 |
|
|
fi |
| 356 |
|
|
} |
| 357 |
|
|
|
| 358 |
|
|
# @FUNCTION: ruby-ng_src_configure |
| 359 |
|
|
# @DESCRIPTION: |
| 360 |
|
|
# Configure the package. |
| 361 |
|
|
ruby-ng_src_configure() { |
| 362 |
|
|
if type each_ruby_configure &>/dev/null; then |
| 363 |
|
|
_ruby_each_implementation each_ruby_configure |
| 364 |
|
|
fi |
| 365 |
|
|
|
| 366 |
|
|
type all_ruby_configure &>/dev/null && \ |
| 367 |
|
|
_ruby_invoke_environment all all_ruby_configure |
| 368 |
|
|
} |
| 369 |
|
|
|
| 370 |
|
|
# @FUNCTION: ruby-ng_src_compile |
| 371 |
|
|
# @DESCRIPTION: |
| 372 |
|
|
# Compile the package. |
| 373 |
|
|
ruby-ng_src_compile() { |
| 374 |
|
|
if type each_ruby_compile &>/dev/null; then |
| 375 |
|
|
_ruby_each_implementation each_ruby_compile |
| 376 |
|
|
fi |
| 377 |
|
|
|
| 378 |
|
|
type all_ruby_compile &>/dev/null && \ |
| 379 |
|
|
_ruby_invoke_environment all all_ruby_compile |
| 380 |
|
|
} |
| 381 |
|
|
|
| 382 |
|
|
# @FUNCTION: ruby-ng_src_test |
| 383 |
|
|
# @DESCRIPTION: |
| 384 |
|
|
# Run tests for the package. |
| 385 |
|
|
ruby-ng_src_test() { |
| 386 |
|
|
if type each_ruby_test &>/dev/null; then |
| 387 |
|
|
_ruby_each_implementation each_ruby_test |
| 388 |
|
|
fi |
| 389 |
|
|
|
| 390 |
|
|
type all_ruby_test &>/dev/null && \ |
| 391 |
|
|
_ruby_invoke_environment all all_ruby_test |
| 392 |
|
|
} |
| 393 |
|
|
|
| 394 |
|
|
_each_ruby_check_install() { |
| 395 |
|
|
local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') |
| 396 |
|
|
local libruby_soname=$(scanelf -qS "/usr/$(get_libdir)/${libruby_basename}" | awk '{ print $1 }') |
| 397 |
flameeyes |
1.2 |
local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') |
| 398 |
|
|
local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') |
| 399 |
|
|
|
| 400 |
|
|
# Look for wrong files in sitedir |
| 401 |
|
|
if [[ -d "${D}${sitedir}" ]]; then |
| 402 |
|
|
local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") |
| 403 |
|
|
if [[ -n ${f} ]]; then |
| 404 |
|
|
eerror "Found files in sitedir, outsite sitelibdir:" |
| 405 |
|
|
eerror "${f}" |
| 406 |
|
|
die "Misplaced files in sitedir" |
| 407 |
|
|
fi |
| 408 |
|
|
fi |
| 409 |
graaff |
1.1 |
|
| 410 |
|
|
# The current implementation lacks libruby (i.e.: jruby) |
| 411 |
|
|
[[ -z ${libruby_soname} ]] && return 0 |
| 412 |
|
|
|
| 413 |
flameeyes |
1.3 |
scanelf -qnR "${D}${sitedir}" \ |
| 414 |
graaff |
1.1 |
| fgrep -v "${libruby_soname}" \ |
| 415 |
|
|
> "${T}"/ruby-ng-${_ruby_implementation}-mislink.log |
| 416 |
|
|
|
| 417 |
|
|
if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then |
| 418 |
|
|
ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}" |
| 419 |
|
|
ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) |
| 420 |
|
|
die "Missing links to ${libruby}" |
| 421 |
|
|
fi |
| 422 |
|
|
} |
| 423 |
|
|
|
| 424 |
|
|
# @FUNCTION: ruby-ng_src_install |
| 425 |
|
|
# @DESCRIPTION: |
| 426 |
|
|
# Install the package for each ruby target implementation. |
| 427 |
|
|
ruby-ng_src_install() { |
| 428 |
|
|
if type each_ruby_install &>/dev/null; then |
| 429 |
|
|
_ruby_each_implementation each_ruby_install |
| 430 |
|
|
fi |
| 431 |
|
|
|
| 432 |
|
|
type all_ruby_install &>/dev/null && \ |
| 433 |
|
|
_ruby_invoke_environment all all_ruby_install |
| 434 |
|
|
|
| 435 |
|
|
_PHASE="check install" \ |
| 436 |
|
|
_ruby_each_implementation _each_ruby_check_install |
| 437 |
|
|
} |
| 438 |
|
|
|
| 439 |
a3li |
1.11 |
# @FUNCTION: ruby_rbconfig_value |
| 440 |
|
|
# @USAGE: rbconfig item |
| 441 |
|
|
# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. |
| 442 |
|
|
ruby_rbconfig_value() { |
| 443 |
|
|
echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']") |
| 444 |
|
|
} |
| 445 |
|
|
|
| 446 |
graaff |
1.1 |
# @FUNCTION: doruby |
| 447 |
|
|
# @USAGE: file [file...] |
| 448 |
|
|
# @DESCRIPTION: |
| 449 |
|
|
# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. |
| 450 |
|
|
doruby() { |
| 451 |
flameeyes |
1.4 |
[[ -z ${RUBY} ]] && die "\$RUBY is not set" |
| 452 |
graaff |
1.1 |
( # don't want to pollute calling env |
| 453 |
a3li |
1.11 |
insinto $(ruby_rbconfig_value 'sitelibdir') |
| 454 |
graaff |
1.1 |
insopts -m 0644 |
| 455 |
|
|
doins "$@" |
| 456 |
|
|
) || die "failed to install $@" |
| 457 |
|
|
} |
| 458 |
|
|
|
| 459 |
|
|
# @FUNCTION: ruby_get_libruby |
| 460 |
|
|
# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. |
| 461 |
|
|
ruby_get_libruby() { |
| 462 |
|
|
${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' |
| 463 |
|
|
} |
| 464 |
|
|
|
| 465 |
|
|
# @FUNCTION: ruby_get_hdrdir |
| 466 |
|
|
# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
| 467 |
|
|
ruby_get_hdrdir() { |
| 468 |
a3li |
1.11 |
local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir') |
| 469 |
graaff |
1.1 |
|
| 470 |
|
|
if [[ "${rubyhdrdir}" = "nil" ]] ; then |
| 471 |
a3li |
1.11 |
rubyhdrdir=$(ruby_rbconfig_value 'archdir') |
| 472 |
graaff |
1.1 |
fi |
| 473 |
|
|
|
| 474 |
|
|
echo "${rubyhdrdir}" |
| 475 |
|
|
} |
| 476 |
a3li |
1.10 |
|
| 477 |
|
|
# @FUNCTION: ruby_get_version |
| 478 |
|
|
# @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
| 479 |
|
|
ruby_get_version() { |
| 480 |
|
|
local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
| 481 |
|
|
|
| 482 |
|
|
echo $(${ruby} -e 'puts RUBY_VERSION') |
| 483 |
|
|
} |
| 484 |
|
|
|
| 485 |
|
|
# @FUNCTION: ruby_get_implementation |
| 486 |
|
|
# @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
| 487 |
|
|
ruby_get_implementation() { |
| 488 |
|
|
local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
| 489 |
|
|
|
| 490 |
|
|
case $(${ruby} --version) in |
| 491 |
|
|
*Enterprise*) |
| 492 |
|
|
echo "ree" |
| 493 |
|
|
;; |
| 494 |
|
|
*jruby*) |
| 495 |
|
|
echo "jruby" |
| 496 |
|
|
;; |
| 497 |
|
|
*) |
| 498 |
|
|
echo "mri" |
| 499 |
|
|
;; |
| 500 |
|
|
esac |
| 501 |
|
|
} |