| 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.7 2009/12/25 18:01:34 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.43 2011/10/24 18:20:05 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 |
| 23 | # * ree18 - Ruby Enterprise Edition 1.8.x |
20 | # * ree18 - Ruby Enterprise Edition 1.8.x |
| 24 | # * jruby - JRuby |
21 | # * jruby - JRuby |
|
|
22 | # * rbx - Rubinius |
| 25 | # |
23 | # |
| 26 | # This eclass does not define the implementation of the configure, |
24 | # This eclass does not define the implementation of the configure, |
| 27 | # compile, test, or install phases. Instead, the default phases are |
25 | # compile, test, or install phases. Instead, the default phases are |
| 28 | # used. Specific implementations of these phases can be provided in |
26 | # used. Specific implementations of these phases can be provided in |
| 29 | # the ebuild either to be run for each Ruby implementation, or for all |
27 | # the ebuild either to be run for each Ruby implementation, or for all |
| … | |
… | |
| 31 | # |
29 | # |
| 32 | # * each_ruby_configure |
30 | # * each_ruby_configure |
| 33 | # * all_ruby_configure |
31 | # * all_ruby_configure |
| 34 | |
32 | |
| 35 | # @ECLASS-VARIABLE: USE_RUBY |
33 | # @ECLASS-VARIABLE: USE_RUBY |
|
|
34 | # @REQUIRED |
| 36 | # @DESCRIPTION: |
35 | # @DESCRIPTION: |
| 37 | # This variable contains a space separated list of targets (see above) a package |
36 | # 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 |
37 | # is compatible to. It must be set before the `inherit' call. There is no |
| 39 | # default. All ebuilds are expected to set this variable. |
38 | # default. All ebuilds are expected to set this variable. |
| 40 | |
39 | |
| 41 | # @ECLASS-VARIABLE: RUBY_PATCHES |
40 | # @ECLASS-VARIABLE: RUBY_PATCHES |
|
|
41 | # @DEFAULT_UNSET |
| 42 | # @DESCRIPTION: |
42 | # @DESCRIPTION: |
| 43 | # A String or Array of filenames of patches to apply to all implementations. |
43 | # A String or Array of filenames of patches to apply to all implementations. |
| 44 | |
44 | |
| 45 | # @ECLASS-VARIABLE: RUBY_OPTIONAL |
45 | # @ECLASS-VARIABLE: RUBY_OPTIONAL |
| 46 | # @DESCRIPTION: |
46 | # @DESCRIPTION: |
| 47 | # Set the value to "yes" to make the dependency on a Ruby interpreter optional. |
47 | # Set the value to "yes" to make the dependency on a Ruby interpreter |
|
|
48 | # optional and then ruby_implementations_depend() to help populate |
|
|
49 | # DEPEND and RDEPEND. |
| 48 | |
50 | |
|
|
51 | # @ECLASS-VARIABLE: RUBY_S |
|
|
52 | # @DEFAULT_UNSET |
|
|
53 | # @DESCRIPTION: |
|
|
54 | # If defined this variable determines the source directory name after |
|
|
55 | # unpacking. This defaults to the name of the package. Note that this |
|
|
56 | # variable supports a wildcard mechanism to help with github tarballs |
|
|
57 | # that contain the commit hash as part of the directory name. |
|
|
58 | |
|
|
59 | # @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS |
|
|
60 | # @DEFAULT_UNSET |
|
|
61 | # @DESCRIPTION: |
|
|
62 | # If defined this variable contains a whitelist of shared objects that |
|
|
63 | # are allowed to exist even if they don't link to libruby. This avoids |
|
|
64 | # the QA check that makes this mandatory. This is most likely not what |
|
|
65 | # you are looking for if you get the related "Missing links" QA warning, |
|
|
66 | # since the proper fix is almost always to make sure the shared object |
|
|
67 | # is linked against libruby. There are cases were this is not the case |
|
|
68 | # and the shared object is generic code to be used in some other way |
|
|
69 | # (e.g. selenium's firefox driver extension). When set this argument is |
|
|
70 | # passed to "grep -E" to remove reporting of these shared objects. |
|
|
71 | |
| 49 | inherit eutils toolchain-funcs |
72 | inherit eutils java-utils-2 toolchain-funcs |
| 50 | |
73 | |
| 51 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup |
74 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup |
| 52 | |
75 | |
| 53 | case ${EAPI} in |
76 | case ${EAPI} in |
| 54 | 0|1) |
77 | 0|1) |
| 55 | die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; |
78 | die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; |
| 56 | 2) ;; |
79 | 2|3) ;; |
|
|
80 | 4) |
|
|
81 | # S is no longer automatically assigned when it doesn't exist. |
|
|
82 | S="${WORKDIR}" |
|
|
83 | ;; |
| 57 | *) |
84 | *) |
| 58 | die "Unknown EAPI=${EAPI} for ruby-ng.eclass" |
85 | die "Unknown EAPI=${EAPI} for ruby-ng.eclass" |
| 59 | esac |
86 | esac |
| 60 | |
87 | |
| 61 | # @FUNCTION: ruby_implementation_depend |
88 | # @FUNCTION: ruby_implementation_depend |
| … | |
… | |
| 85 | rubypn="dev-lang/ruby-enterprise" |
112 | rubypn="dev-lang/ruby-enterprise" |
| 86 | rubyslot=":1.8" |
113 | rubyslot=":1.8" |
| 87 | ;; |
114 | ;; |
| 88 | jruby) |
115 | jruby) |
| 89 | rubypn="dev-java/jruby" |
116 | rubypn="dev-java/jruby" |
|
|
117 | rubyslot="" |
|
|
118 | ;; |
|
|
119 | rbx) |
|
|
120 | rubypn="dev-lang/rubinius" |
| 90 | rubyslot="" |
121 | rubyslot="" |
| 91 | ;; |
122 | ;; |
| 92 | *) die "$1: unknown Ruby implementation" |
123 | *) die "$1: unknown Ruby implementation" |
| 93 | esac |
124 | esac |
| 94 | |
125 | |
| … | |
… | |
| 110 | done |
141 | done |
| 111 | |
142 | |
| 112 | echo "[${res%,}]" |
143 | echo "[${res%,}]" |
| 113 | } |
144 | } |
| 114 | |
145 | |
|
|
146 | _ruby_atoms_samelib_generic() { |
|
|
147 | eshopts_push -o noglob |
|
|
148 | echo "RUBYTARGET? (" |
|
|
149 | for token in $*; do |
|
|
150 | case "$token" in |
|
|
151 | "||" | "(" | ")" | *"?") |
|
|
152 | echo "${token}" ;; |
|
|
153 | *]) |
|
|
154 | echo "${token%[*}[RUBYTARGET,${token/*[}" ;; |
|
|
155 | *) |
|
|
156 | echo "${token}[RUBYTARGET]" ;; |
|
|
157 | esac |
|
|
158 | done |
|
|
159 | echo ")" |
|
|
160 | eshopts_pop |
|
|
161 | } |
|
|
162 | |
|
|
163 | # @FUNCTION: ruby_implementation_command |
|
|
164 | # @RETURN: the path to the given ruby implementation |
|
|
165 | # @DESCRIPTION: |
|
|
166 | # Not all implementations have the same command basename as the |
|
|
167 | # target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18 |
|
|
168 | # respectively. This function translate between the two |
| 115 | _ruby_implementation_depend() { |
169 | ruby_implementation_command() { |
| 116 | echo "ruby_targets_${1}? ( ${2}[ruby_targets_${1}] )" |
170 | local _ruby_name=$1 |
| 117 | } |
|
|
| 118 | |
171 | |
| 119 | _ruby_add_bdepend() { |
172 | # Add all USE_RUBY values where the flag name diverts from the binary here |
| 120 | local atom=$1 |
173 | case $1 in |
|
|
174 | ree18) |
|
|
175 | _ruby_name=rubyee18 |
|
|
176 | ;; |
|
|
177 | esac |
|
|
178 | |
|
|
179 | echo $(type -p ${_ruby_name} 2>/dev/null) |
|
|
180 | } |
|
|
181 | |
|
|
182 | _ruby_atoms_samelib() { |
|
|
183 | local atoms=$(_ruby_atoms_samelib_generic "$*") |
|
|
184 | |
|
|
185 | for _ruby_implementation in $USE_RUBY; do |
|
|
186 | echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}" |
|
|
187 | done |
|
|
188 | } |
|
|
189 | |
|
|
190 | _ruby_wrap_conditions() { |
| 121 | local conditions=$2 |
191 | local conditions="$1" |
|
|
192 | local atoms="$2" |
| 122 | |
193 | |
| 123 | for condition in $conditions; do |
194 | for condition in $conditions; do |
| 124 | atom="${condition}? ( ${atom} )" |
195 | atoms="${condition}? ( ${atoms} )" |
| 125 | done |
196 | done |
| 126 | |
197 | |
| 127 | DEPEND="${DEPEND} ${atom}" |
198 | echo "$atoms" |
| 128 | RDEPEND="${RDEPEND}" |
|
|
| 129 | } |
|
|
| 130 | |
|
|
| 131 | _ruby_add_rdepend() { |
|
|
| 132 | local atom=$1 |
|
|
| 133 | local conditions=$2 |
|
|
| 134 | |
|
|
| 135 | for condition in $conditions; do |
|
|
| 136 | atom="${condition}? ( ${atom} )" |
|
|
| 137 | done |
|
|
| 138 | |
|
|
| 139 | RDEPEND="${RDEPEND} ${atom}" |
|
|
| 140 | _ruby_add_bdepend "$atom" test |
|
|
| 141 | } |
199 | } |
| 142 | |
200 | |
| 143 | # @FUNCTION: ruby_add_rdepend |
201 | # @FUNCTION: ruby_add_rdepend |
| 144 | # @USAGE: [conditions] atom |
202 | # @USAGE: dependencies |
| 145 | # @DESCRIPTION: |
203 | # @DESCRIPTION: |
| 146 | # Adds the specified atom(s) with optional use condition(s) to |
204 | # Adds the specified dependencies, with use condition(s) to RDEPEND, |
| 147 | # RDEPEND, taking the current set of ruby targets into account. This |
205 | # taking the current set of ruby targets into account. This makes sure |
| 148 | # makes sure that all ruby dependencies of the package are installed |
206 | # that all ruby dependencies of the package are installed for the same |
| 149 | # for the same ruby targets. Use this function for all ruby |
207 | # ruby targets. Use this function for all ruby dependencies instead of |
| 150 | # dependencies instead of setting RDEPEND yourself. Both atom and |
208 | # setting RDEPEND yourself. The list of atoms uses the same syntax as |
| 151 | # conditions can be a space-separated list of atoms or conditions. |
209 | # normal dependencies. |
|
|
210 | # |
|
|
211 | # Note: runtime dependencies are also added as build-time test |
|
|
212 | # dependencies. |
| 152 | ruby_add_rdepend() { |
213 | ruby_add_rdepend() { |
| 153 | local atoms= |
|
|
| 154 | local conditions= |
|
|
| 155 | case $# in |
214 | case $# in |
| 156 | 1) |
215 | 1) ;; |
| 157 | atoms=$1 |
|
|
| 158 | ;; |
|
|
| 159 | 2) |
216 | 2) |
| 160 | conditions=$1 |
217 | [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF" |
| 161 | atoms=$2 |
218 | ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")" |
|
|
219 | return |
| 162 | ;; |
220 | ;; |
| 163 | *) |
221 | *) |
| 164 | die "bad number of arguments to $0" |
222 | die "bad number of arguments to $0" |
| 165 | ;; |
223 | ;; |
| 166 | esac |
224 | esac |
| 167 | |
225 | |
| 168 | for atom in $atoms; do |
226 | local dependency=$(_ruby_atoms_samelib "$1") |
| 169 | _ruby_add_rdepend "${atom}$(ruby_samelib)" "$conditions" |
227 | |
| 170 | done |
228 | RDEPEND="${RDEPEND} $dependency" |
|
|
229 | |
|
|
230 | # Add the dependency as a test-dependency since we're going to |
|
|
231 | # execute the code during test phase. |
|
|
232 | DEPEND="${DEPEND} test? ( ${dependency} )" |
|
|
233 | has test "$IUSE" || IUSE="${IUSE} test" |
| 171 | } |
234 | } |
| 172 | |
235 | |
| 173 | # @FUNCTION: ruby_add_bdepend |
236 | # @FUNCTION: ruby_add_bdepend |
| 174 | # @USAGE: [conditions] atom |
237 | # @USAGE: dependencies |
| 175 | # @DESCRIPTION: |
238 | # @DESCRIPTION: |
| 176 | # Adds the specified atom(s) with optional use condition(s) to both |
239 | # Adds the specified dependencies, with use condition(s) to DEPEND, |
| 177 | # DEPEND and RDEPEND, taking the current set of ruby targets into |
240 | # taking the current set of ruby targets into account. This makes sure |
| 178 | # account. This makes sure that all ruby dependencies of the package |
241 | # that all ruby dependencies of the package are installed for the same |
| 179 | # are installed for the same ruby targets. Use this function for all |
242 | # ruby targets. Use this function for all ruby dependencies instead of |
| 180 | # ruby dependencies instead of setting DEPEND and RDEPEND |
243 | # setting DEPEND yourself. The list of atoms uses the same syntax as |
| 181 | # yourself. Both atom and conditions can be a space-separated list of |
244 | # normal dependencies. |
| 182 | # atoms or conditions. |
|
|
| 183 | ruby_add_bdepend() { |
245 | ruby_add_bdepend() { |
| 184 | local atoms= |
|
|
| 185 | local conditions= |
|
|
| 186 | case $# in |
246 | case $# in |
| 187 | 1) |
247 | 1) ;; |
| 188 | atoms=$1 |
|
|
| 189 | ;; |
|
|
| 190 | 2) |
248 | 2) |
| 191 | conditions=$1 |
249 | [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF" |
| 192 | atoms=$2 |
250 | ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")" |
|
|
251 | return |
| 193 | ;; |
252 | ;; |
| 194 | *) |
253 | *) |
| 195 | die "bad number of arguments to $0" |
254 | die "bad number of arguments to $0" |
| 196 | ;; |
255 | ;; |
| 197 | esac |
256 | esac |
| 198 | |
257 | |
| 199 | for atom in $atoms; do |
258 | local dependency=$(_ruby_atoms_samelib "$1") |
| 200 | _ruby_add_bdepend "${atom}$(ruby_samelib)" "$conditions" |
|
|
| 201 | done |
|
|
| 202 | } |
|
|
| 203 | |
259 | |
|
|
260 | DEPEND="${DEPEND} $dependency" |
|
|
261 | RDEPEND="${RDEPEND}" |
|
|
262 | } |
|
|
263 | |
|
|
264 | # @FUNCTION: ruby_get_use_implementations |
|
|
265 | # @DESCRIPTION: |
|
|
266 | # Gets an array of ruby use targets enabled by the user |
|
|
267 | ruby_get_use_implementations() { |
|
|
268 | local i implementation |
|
|
269 | for implementation in ${USE_RUBY}; do |
|
|
270 | use ruby_targets_${implementation} && i+=" ${implementation}" |
|
|
271 | done |
|
|
272 | echo $i |
|
|
273 | } |
|
|
274 | |
|
|
275 | # @FUNCTION: ruby_get_use_targets |
|
|
276 | # @DESCRIPTION: |
|
|
277 | # Gets an array of ruby use targets that the ebuild sets |
|
|
278 | ruby_get_use_targets() { |
|
|
279 | local t implementation |
|
|
280 | for implementation in ${USE_RUBY}; do |
|
|
281 | t+=" ruby_targets_${implementation}" |
|
|
282 | done |
|
|
283 | echo $t |
|
|
284 | } |
|
|
285 | |
|
|
286 | if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then |
|
|
287 | REQUIRED_USE=" || ( $(ruby_get_use_targets) )" |
|
|
288 | fi |
|
|
289 | |
|
|
290 | # @FUNCTION: ruby_implementations_depend |
|
|
291 | # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND. |
|
|
292 | # @DESCRIPTION: |
|
|
293 | # Produces the dependency string for the various implementations of ruby |
|
|
294 | # which the package is being built against. This should not be used when |
|
|
295 | # RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not |
|
|
296 | # confuse this function with ruby_implementation_depend(). |
|
|
297 | # |
|
|
298 | # @EXAMPLE: |
|
|
299 | # EAPI=4 |
|
|
300 | # RUBY_OPTIONAL=yes |
|
|
301 | # |
|
|
302 | # inherit ruby-ng |
|
|
303 | # ... |
|
|
304 | # DEPEND="ruby? ( $(ruby_implementations_depend) )" |
|
|
305 | # RDEPEND="${DEPEND}" |
|
|
306 | ruby_implementations_depend() { |
|
|
307 | local depend |
|
|
308 | for _ruby_implementation in ${USE_RUBY}; do |
|
|
309 | depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
|
|
310 | done |
|
|
311 | echo "${depend}" |
|
|
312 | } |
|
|
313 | |
| 204 | for _ruby_implementation in $USE_RUBY; do |
314 | for _ruby_implementation in ${USE_RUBY}; do |
| 205 | IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
315 | IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
| 206 | |
|
|
| 207 | # If you specify RUBY_OPTIONAL you also need to take care of |
|
|
| 208 | # ruby useflag and dependency. |
|
|
| 209 | if [[ ${RUBY_OPTIONAL} != "yes" ]]; then |
|
|
| 210 | DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
|
|
| 211 | RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
|
|
| 212 | fi |
|
|
| 213 | done |
316 | done |
|
|
317 | # If you specify RUBY_OPTIONAL you also need to take care of |
|
|
318 | # ruby useflag and dependency. |
|
|
319 | if [[ ${RUBY_OPTIONAL} != yes ]]; then |
|
|
320 | DEPEND="${DEPEND} $(ruby_implementations_depend)" |
|
|
321 | RDEPEND="${RDEPEND} $(ruby_implementations_depend)" |
|
|
322 | fi |
| 214 | |
323 | |
| 215 | _ruby_invoke_environment() { |
324 | _ruby_invoke_environment() { |
| 216 | old_S=${S} |
325 | old_S=${S} |
|
|
326 | case ${EAPI} in |
|
|
327 | 4) |
|
|
328 | if [ -z ${RUBY_S} ]; then |
|
|
329 | sub_S=${P} |
|
|
330 | else |
|
|
331 | sub_S=${RUBY_S} |
|
|
332 | fi |
|
|
333 | ;; |
|
|
334 | *) |
| 217 | sub_S=${S#${WORKDIR}} |
335 | sub_S=${S#${WORKDIR}/} |
|
|
336 | ;; |
|
|
337 | esac |
|
|
338 | |
|
|
339 | # Special case, for the always-lovely GitHub fetches. With this, |
|
|
340 | # we allow the star glob to just expand to whatever directory it's |
|
|
341 | # called. |
|
|
342 | if [[ ${sub_S} = *"*"* ]]; then |
|
|
343 | case ${EAPI} in |
|
|
344 | 2|3) |
|
|
345 | #The old method of setting S depends on undefined package |
|
|
346 | # manager behaviour, so encourage upgrading to EAPI=4. |
|
|
347 | eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead." |
|
|
348 | ;; |
|
|
349 | esac |
|
|
350 | pushd "${WORKDIR}"/all &>/dev/null |
|
|
351 | sub_S=$(eval ls -d ${sub_S} 2>/dev/null) |
|
|
352 | popd &>/dev/null |
|
|
353 | fi |
| 218 | |
354 | |
| 219 | environment=$1; shift |
355 | environment=$1; shift |
| 220 | |
356 | |
| 221 | my_WORKDIR="${WORKDIR}"/${environment} |
357 | my_WORKDIR="${WORKDIR}"/${environment} |
| 222 | S="${my_WORKDIR}"/"${sub_S}" |
358 | S="${my_WORKDIR}"/"${sub_S}" |
| … | |
… | |
| 240 | local invoked=no |
376 | local invoked=no |
| 241 | for _ruby_implementation in ${USE_RUBY}; do |
377 | for _ruby_implementation in ${USE_RUBY}; do |
| 242 | # only proceed if it's requested |
378 | # only proceed if it's requested |
| 243 | use ruby_targets_${_ruby_implementation} || continue |
379 | use ruby_targets_${_ruby_implementation} || continue |
| 244 | |
380 | |
| 245 | RUBY=$(type -p $_ruby_implementation 2>/dev/null) |
381 | RUBY=$(ruby_implementation_command ${_ruby_implementation}) |
| 246 | invoked=yes |
382 | invoked=yes |
| 247 | |
383 | |
| 248 | if [[ -n "$1" ]]; then |
384 | if [[ -n "$1" ]]; then |
| 249 | _ruby_invoke_environment $_ruby_implementation "$@" |
385 | _ruby_invoke_environment ${_ruby_implementation} "$@" |
| 250 | fi |
386 | fi |
| 251 | |
387 | |
| 252 | unset RUBY |
388 | unset RUBY |
| 253 | done |
389 | done |
| 254 | |
390 | |
| … | |
… | |
| 261 | ruby-ng_pkg_setup() { |
397 | ruby-ng_pkg_setup() { |
| 262 | # This only checks that at least one implementation is present |
398 | # This only checks that at least one implementation is present |
| 263 | # before doing anything; by leaving the parameters empty we know |
399 | # before doing anything; by leaving the parameters empty we know |
| 264 | # it's a special case. |
400 | # it's a special case. |
| 265 | _ruby_each_implementation |
401 | _ruby_each_implementation |
|
|
402 | |
|
|
403 | has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm |
| 266 | } |
404 | } |
| 267 | |
405 | |
| 268 | # @FUNCTION: ruby-ng_src_unpack |
406 | # @FUNCTION: ruby-ng_src_unpack |
| 269 | # @DESCRIPTION: |
407 | # @DESCRIPTION: |
| 270 | # Unpack the source archive. |
408 | # Unpack the source archive. |
| … | |
… | |
| 361 | type all_ruby_test &>/dev/null && \ |
499 | type all_ruby_test &>/dev/null && \ |
| 362 | _ruby_invoke_environment all all_ruby_test |
500 | _ruby_invoke_environment all all_ruby_test |
| 363 | } |
501 | } |
| 364 | |
502 | |
| 365 | _each_ruby_check_install() { |
503 | _each_ruby_check_install() { |
|
|
504 | local scancmd=scanelf |
|
|
505 | # we have a Mach-O object here |
|
|
506 | [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho |
|
|
507 | |
|
|
508 | has "${EAPI}" 2 && ! use prefix && EPREFIX= |
|
|
509 | |
| 366 | local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') |
510 | local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]') |
| 367 | local libruby_soname=$(scanelf -qS "/usr/$(get_libdir)/${libruby_basename}" | awk '{ print $1 }') |
511 | local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null) |
| 368 | local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') |
512 | local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]') |
| 369 | local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') |
513 | local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]') |
| 370 | |
514 | |
| 371 | # Look for wrong files in sitedir |
515 | # Look for wrong files in sitedir |
| 372 | if [[ -d "${D}${sitedir}" ]]; then |
516 | # if [[ -d "${D}${sitedir}" ]]; then |
| 373 | local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") |
517 | # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") |
| 374 | if [[ -n ${f} ]]; then |
518 | # if [[ -n ${f} ]]; then |
| 375 | eerror "Found files in sitedir, outsite sitelibdir:" |
519 | # eerror "Found files in sitedir, outsite sitelibdir:" |
| 376 | eerror "${f}" |
520 | # eerror "${f}" |
| 377 | die "Misplaced files in sitedir" |
521 | # die "Misplaced files in sitedir" |
| 378 | fi |
522 | # fi |
| 379 | fi |
523 | # fi |
| 380 | |
524 | |
| 381 | # The current implementation lacks libruby (i.e.: jruby) |
525 | # The current implementation lacks libruby (i.e.: jruby) |
| 382 | [[ -z ${libruby_soname} ]] && return 0 |
526 | [[ -z ${libruby_soname} ]] && return 0 |
| 383 | |
527 | |
| 384 | scanelf -qnR "${D}${sitedir}" \ |
528 | # Check also the gems directory, since we could be installing compiled |
|
|
529 | # extensions via ruby-fakegem; make sure to check only in sitelibdir, since |
|
|
530 | # that's what changes between two implementations (otherwise you'd get false |
|
|
531 | # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) |
|
|
532 | ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ |
| 385 | | fgrep -v "${libruby_soname}" \ |
533 | | fgrep -v "${libruby_soname}" \ |
|
|
534 | | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \ |
| 386 | > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log |
535 | > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log |
| 387 | |
536 | |
| 388 | if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then |
537 | if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then |
| 389 | ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}" |
538 | ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}" |
| 390 | ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) |
539 | ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) |
| 391 | die "Missing links to ${libruby}" |
540 | die "Missing links to ${libruby_soname}" |
| 392 | fi |
541 | fi |
| 393 | } |
542 | } |
| 394 | |
543 | |
| 395 | # @FUNCTION: ruby-ng_src_install |
544 | # @FUNCTION: ruby-ng_src_install |
| 396 | # @DESCRIPTION: |
545 | # @DESCRIPTION: |
| … | |
… | |
| 405 | |
554 | |
| 406 | _PHASE="check install" \ |
555 | _PHASE="check install" \ |
| 407 | _ruby_each_implementation _each_ruby_check_install |
556 | _ruby_each_implementation _each_ruby_check_install |
| 408 | } |
557 | } |
| 409 | |
558 | |
|
|
559 | # @FUNCTION: ruby_rbconfig_value |
|
|
560 | # @USAGE: rbconfig item |
|
|
561 | # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. |
|
|
562 | ruby_rbconfig_value() { |
|
|
563 | echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']") |
|
|
564 | } |
|
|
565 | |
| 410 | # @FUNCTION: doruby |
566 | # @FUNCTION: doruby |
| 411 | # @USAGE: file [file...] |
567 | # @USAGE: file [file...] |
| 412 | # @DESCRIPTION: |
568 | # @DESCRIPTION: |
| 413 | # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. |
569 | # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. |
| 414 | doruby() { |
570 | doruby() { |
| 415 | [[ -z ${RUBY} ]] && die "\$RUBY is not set" |
571 | [[ -z ${RUBY} ]] && die "\$RUBY is not set" |
|
|
572 | has "${EAPI}" 2 && ! use prefix && EPREFIX= |
| 416 | ( # don't want to pollute calling env |
573 | ( # don't want to pollute calling env |
| 417 | insinto $(${RUBY} -rrbconfig -e 'print Config::CONFIG["sitelibdir"]') |
574 | sitelibdir=$(ruby_rbconfig_value 'sitelibdir') |
|
|
575 | insinto ${sitelibdir#${EPREFIX}} |
| 418 | insopts -m 0644 |
576 | insopts -m 0644 |
| 419 | doins "$@" |
577 | doins "$@" |
| 420 | ) || die "failed to install $@" |
578 | ) || die "failed to install $@" |
| 421 | } |
579 | } |
| 422 | |
580 | |
| 423 | # @FUNCTION: ruby_get_libruby |
581 | # @FUNCTION: ruby_get_libruby |
| 424 | # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. |
582 | # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. |
| 425 | ruby_get_libruby() { |
583 | ruby_get_libruby() { |
| 426 | ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' |
584 | ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])' |
| 427 | } |
585 | } |
| 428 | |
586 | |
| 429 | # @FUNCTION: ruby_get_hdrdir |
587 | # @FUNCTION: ruby_get_hdrdir |
| 430 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
588 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
| 431 | ruby_get_hdrdir() { |
589 | ruby_get_hdrdir() { |
| 432 | local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]') |
590 | local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir') |
| 433 | |
591 | |
| 434 | if [[ "${rubyhdrdir}" = "nil" ]] ; then |
592 | if [[ "${rubyhdrdir}" = "nil" ]] ; then |
| 435 | rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]') |
593 | rubyhdrdir=$(ruby_rbconfig_value 'archdir') |
| 436 | fi |
594 | fi |
| 437 | |
595 | |
| 438 | echo "${rubyhdrdir}" |
596 | echo "${rubyhdrdir}" |
| 439 | } |
597 | } |
|
|
598 | |
|
|
599 | # @FUNCTION: ruby_get_version |
|
|
600 | # @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
|
|
601 | ruby_get_version() { |
|
|
602 | local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
|
|
603 | |
|
|
604 | echo $(${ruby} -e 'puts RUBY_VERSION') |
|
|
605 | } |
|
|
606 | |
|
|
607 | # @FUNCTION: ruby_get_implementation |
|
|
608 | # @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
|
|
609 | ruby_get_implementation() { |
|
|
610 | local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
|
|
611 | |
|
|
612 | case $(${ruby} --version) in |
|
|
613 | *Enterprise*) |
|
|
614 | echo "ree" |
|
|
615 | ;; |
|
|
616 | *jruby*) |
|
|
617 | echo "jruby" |
|
|
618 | ;; |
|
|
619 | *rubinius*) |
|
|
620 | echo "rbx" |
|
|
621 | ;; |
|
|
622 | *) |
|
|
623 | echo "mri" |
|
|
624 | ;; |
|
|
625 | esac |
|
|
626 | } |