| 1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2012 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.8 2010/01/15 12:58:20 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.51 2012/09/27 16:35:41 axs 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 | |
| 49 | inherit eutils toolchain-funcs |
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 | |
|
|
72 | inherit eutils java-utils-2 multilib 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|5) |
|
|
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 |
| … | |
… | |
| 87 | ;; |
114 | ;; |
| 88 | jruby) |
115 | jruby) |
| 89 | rubypn="dev-java/jruby" |
116 | rubypn="dev-java/jruby" |
| 90 | rubyslot="" |
117 | rubyslot="" |
| 91 | ;; |
118 | ;; |
|
|
119 | rbx) |
|
|
120 | rubypn="dev-lang/rubinius" |
|
|
121 | rubyslot="" |
|
|
122 | ;; |
| 92 | *) die "$1: unknown Ruby implementation" |
123 | *) die "$1: unknown Ruby implementation" |
| 93 | esac |
124 | esac |
| 94 | |
125 | |
| 95 | echo "$2${rubypn}$3${rubyslot}" |
126 | echo "$2${rubypn}$3${rubyslot}" |
| 96 | } |
127 | } |
| … | |
… | |
| 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 | hasq $condition "$IUSE" || IUSE="${IUSE} $condition" |
|
|
| 125 | atom="${condition}? ( ${atom} )" |
195 | atoms="${condition}? ( ${atoms} )" |
| 126 | done |
196 | done |
| 127 | |
197 | |
| 128 | DEPEND="${DEPEND} ${atom}" |
198 | echo "$atoms" |
|
|
199 | } |
|
|
200 | |
|
|
201 | # @FUNCTION: ruby_add_rdepend |
|
|
202 | # @USAGE: dependencies |
|
|
203 | # @DESCRIPTION: |
|
|
204 | # Adds the specified dependencies, with use condition(s) to RDEPEND, |
|
|
205 | # taking the current set of ruby targets into account. This makes sure |
|
|
206 | # that all ruby dependencies of the package are installed for the same |
|
|
207 | # ruby targets. Use this function for all ruby dependencies instead of |
|
|
208 | # setting RDEPEND yourself. The list of atoms uses the same syntax as |
|
|
209 | # normal dependencies. |
|
|
210 | # |
|
|
211 | # Note: runtime dependencies are also added as build-time test |
|
|
212 | # dependencies. |
|
|
213 | ruby_add_rdepend() { |
|
|
214 | case $# in |
|
|
215 | 1) ;; |
|
|
216 | 2) |
|
|
217 | [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF" |
|
|
218 | ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")" |
|
|
219 | return |
|
|
220 | ;; |
|
|
221 | *) |
|
|
222 | die "bad number of arguments to $0" |
|
|
223 | ;; |
|
|
224 | esac |
|
|
225 | |
|
|
226 | local dependency=$(_ruby_atoms_samelib "$1") |
|
|
227 | |
|
|
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" |
|
|
234 | } |
|
|
235 | |
|
|
236 | # @FUNCTION: ruby_add_bdepend |
|
|
237 | # @USAGE: dependencies |
|
|
238 | # @DESCRIPTION: |
|
|
239 | # Adds the specified dependencies, with use condition(s) to DEPEND, |
|
|
240 | # taking the current set of ruby targets into account. This makes sure |
|
|
241 | # that all ruby dependencies of the package are installed for the same |
|
|
242 | # ruby targets. Use this function for all ruby dependencies instead of |
|
|
243 | # setting DEPEND yourself. The list of atoms uses the same syntax as |
|
|
244 | # normal dependencies. |
|
|
245 | ruby_add_bdepend() { |
|
|
246 | case $# in |
|
|
247 | 1) ;; |
|
|
248 | 2) |
|
|
249 | [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF" |
|
|
250 | ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")" |
|
|
251 | return |
|
|
252 | ;; |
|
|
253 | *) |
|
|
254 | die "bad number of arguments to $0" |
|
|
255 | ;; |
|
|
256 | esac |
|
|
257 | |
|
|
258 | local dependency=$(_ruby_atoms_samelib "$1") |
|
|
259 | |
|
|
260 | DEPEND="${DEPEND} $dependency" |
| 129 | RDEPEND="${RDEPEND}" |
261 | RDEPEND="${RDEPEND}" |
| 130 | } |
262 | } |
| 131 | |
263 | |
| 132 | _ruby_add_rdepend() { |
264 | # @FUNCTION: ruby_get_use_implementations |
| 133 | local atom=$1 |
265 | # @DESCRIPTION: |
| 134 | local conditions=$2 |
266 | # Gets an array of ruby use targets enabled by the user |
| 135 | |
267 | ruby_get_use_implementations() { |
| 136 | for condition in $conditions; do |
268 | local i implementation |
| 137 | hasq $condition "$IUSE" || IUSE="${IUSE} $condition" |
269 | for implementation in ${USE_RUBY}; do |
| 138 | atom="${condition}? ( ${atom} )" |
270 | use ruby_targets_${implementation} && i+=" ${implementation}" |
| 139 | done |
271 | done |
|
|
272 | echo $i |
|
|
273 | } |
| 140 | |
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 | # @FUNCTION: ruby_implementations_depend |
|
|
287 | # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND. |
|
|
288 | # @DESCRIPTION: |
|
|
289 | # Produces the dependency string for the various implementations of ruby |
|
|
290 | # which the package is being built against. This should not be used when |
|
|
291 | # RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not |
|
|
292 | # confuse this function with ruby_implementation_depend(). |
|
|
293 | # |
|
|
294 | # @EXAMPLE: |
|
|
295 | # EAPI=4 |
|
|
296 | # RUBY_OPTIONAL=yes |
|
|
297 | # |
|
|
298 | # inherit ruby-ng |
|
|
299 | # ... |
|
|
300 | # DEPEND="ruby? ( $(ruby_implementations_depend) )" |
| 141 | RDEPEND="${RDEPEND} ${atom}" |
301 | # RDEPEND="${DEPEND}" |
| 142 | _ruby_add_bdepend "$atom" test |
302 | ruby_implementations_depend() { |
| 143 | } |
303 | local depend |
| 144 | |
|
|
| 145 | # @FUNCTION: ruby_add_rdepend |
|
|
| 146 | # @USAGE: [conditions] atom |
|
|
| 147 | # @DESCRIPTION: |
|
|
| 148 | # Adds the specified atom(s) with optional use condition(s) to |
|
|
| 149 | # RDEPEND, taking the current set of ruby targets into account. This |
|
|
| 150 | # makes sure that all ruby dependencies of the package are installed |
|
|
| 151 | # for the same ruby targets. Use this function for all ruby |
|
|
| 152 | # dependencies instead of setting RDEPEND yourself. Both atom and |
|
|
| 153 | # conditions can be a space-separated list of atoms or conditions. |
|
|
| 154 | ruby_add_rdepend() { |
|
|
| 155 | local atoms= |
|
|
| 156 | local conditions= |
|
|
| 157 | case $# in |
|
|
| 158 | 1) |
|
|
| 159 | atoms=$1 |
|
|
| 160 | ;; |
|
|
| 161 | 2) |
|
|
| 162 | conditions=$1 |
|
|
| 163 | atoms=$2 |
|
|
| 164 | ;; |
|
|
| 165 | *) |
|
|
| 166 | die "bad number of arguments to $0" |
|
|
| 167 | ;; |
|
|
| 168 | esac |
|
|
| 169 | |
|
|
| 170 | for atom in $atoms; do |
|
|
| 171 | _ruby_add_rdepend "${atom}$(ruby_samelib)" "$conditions" |
|
|
| 172 | done |
|
|
| 173 | } |
|
|
| 174 | |
|
|
| 175 | # @FUNCTION: ruby_add_bdepend |
|
|
| 176 | # @USAGE: [conditions] atom |
|
|
| 177 | # @DESCRIPTION: |
|
|
| 178 | # Adds the specified atom(s) with optional use condition(s) to both |
|
|
| 179 | # DEPEND and RDEPEND, taking the current set of ruby targets into |
|
|
| 180 | # account. This makes sure that all ruby dependencies of the package |
|
|
| 181 | # are installed for the same ruby targets. Use this function for all |
|
|
| 182 | # ruby dependencies instead of setting DEPEND and RDEPEND |
|
|
| 183 | # yourself. Both atom and conditions can be a space-separated list of |
|
|
| 184 | # atoms or conditions. |
|
|
| 185 | ruby_add_bdepend() { |
|
|
| 186 | local atoms= |
|
|
| 187 | local conditions= |
|
|
| 188 | case $# in |
|
|
| 189 | 1) |
|
|
| 190 | atoms=$1 |
|
|
| 191 | ;; |
|
|
| 192 | 2) |
|
|
| 193 | conditions=$1 |
|
|
| 194 | atoms=$2 |
|
|
| 195 | ;; |
|
|
| 196 | *) |
|
|
| 197 | die "bad number of arguments to $0" |
|
|
| 198 | ;; |
|
|
| 199 | esac |
|
|
| 200 | |
|
|
| 201 | for atom in $atoms; do |
|
|
| 202 | _ruby_add_bdepend "${atom}$(ruby_samelib)" "$conditions" |
|
|
| 203 | done |
|
|
| 204 | } |
|
|
| 205 | |
|
|
| 206 | for _ruby_implementation in $USE_RUBY; do |
304 | for _ruby_implementation in ${USE_RUBY}; do |
| 207 | IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
305 | depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
|
|
306 | done |
|
|
307 | echo "${depend}" |
|
|
308 | } |
| 208 | |
309 | |
|
|
310 | IUSE+=" $(ruby_get_use_targets)" |
| 209 | # If you specify RUBY_OPTIONAL you also need to take care of |
311 | # If you specify RUBY_OPTIONAL you also need to take care of |
| 210 | # ruby useflag and dependency. |
312 | # ruby useflag and dependency. |
| 211 | if [[ ${RUBY_OPTIONAL} != "yes" ]]; then |
313 | if [[ ${RUBY_OPTIONAL} != yes ]]; then |
| 212 | DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
314 | DEPEND="${DEPEND} $(ruby_implementations_depend)" |
| 213 | RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
315 | RDEPEND="${RDEPEND} $(ruby_implementations_depend)" |
|
|
316 | |
|
|
317 | case ${EAPI:-0} in |
|
|
318 | 4|5) |
|
|
319 | REQUIRED_USE+=" || ( $(ruby_get_use_targets) )" |
|
|
320 | ;; |
|
|
321 | esac |
| 214 | fi |
322 | fi |
| 215 | done |
|
|
| 216 | |
323 | |
| 217 | _ruby_invoke_environment() { |
324 | _ruby_invoke_environment() { |
| 218 | old_S=${S} |
325 | old_S=${S} |
|
|
326 | case ${EAPI} in |
|
|
327 | 4|5) |
|
|
328 | if [ -z ${RUBY_S} ]; then |
|
|
329 | sub_S=${P} |
|
|
330 | else |
|
|
331 | sub_S=${RUBY_S} |
|
|
332 | fi |
|
|
333 | ;; |
|
|
334 | *) |
| 219 | 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 |
| 220 | |
354 | |
| 221 | environment=$1; shift |
355 | environment=$1; shift |
| 222 | |
356 | |
| 223 | my_WORKDIR="${WORKDIR}"/${environment} |
357 | my_WORKDIR="${WORKDIR}"/${environment} |
| 224 | S="${my_WORKDIR}"/"${sub_S}" |
358 | S="${my_WORKDIR}"/"${sub_S}" |
| … | |
… | |
| 242 | local invoked=no |
376 | local invoked=no |
| 243 | for _ruby_implementation in ${USE_RUBY}; do |
377 | for _ruby_implementation in ${USE_RUBY}; do |
| 244 | # only proceed if it's requested |
378 | # only proceed if it's requested |
| 245 | use ruby_targets_${_ruby_implementation} || continue |
379 | use ruby_targets_${_ruby_implementation} || continue |
| 246 | |
380 | |
| 247 | RUBY=$(type -p $_ruby_implementation 2>/dev/null) |
381 | RUBY=$(ruby_implementation_command ${_ruby_implementation}) |
| 248 | invoked=yes |
382 | invoked=yes |
| 249 | |
383 | |
| 250 | if [[ -n "$1" ]]; then |
384 | if [[ -n "$1" ]]; then |
| 251 | _ruby_invoke_environment $_ruby_implementation "$@" |
385 | _ruby_invoke_environment ${_ruby_implementation} "$@" |
| 252 | fi |
386 | fi |
| 253 | |
387 | |
| 254 | unset RUBY |
388 | unset RUBY |
| 255 | done |
389 | done |
| 256 | |
390 | |
| 257 | [[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf." |
391 | if [[ ${invoked} == "no" ]]; then |
|
|
392 | eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf." |
|
|
393 | eerror "Compatible targets for this package are: ${USE_RUBY}" |
|
|
394 | eerror |
|
|
395 | eerror "See http://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information." |
|
|
396 | eerror |
|
|
397 | die "No compatible Ruby target selected." |
|
|
398 | fi |
| 258 | } |
399 | } |
| 259 | |
400 | |
| 260 | # @FUNCTION: ruby-ng_pkg_setup |
401 | # @FUNCTION: ruby-ng_pkg_setup |
| 261 | # @DESCRIPTION: |
402 | # @DESCRIPTION: |
| 262 | # Check whether at least one ruby target implementation is present. |
403 | # Check whether at least one ruby target implementation is present. |
| 263 | ruby-ng_pkg_setup() { |
404 | ruby-ng_pkg_setup() { |
| 264 | # This only checks that at least one implementation is present |
405 | # This only checks that at least one implementation is present |
| 265 | # before doing anything; by leaving the parameters empty we know |
406 | # before doing anything; by leaving the parameters empty we know |
| 266 | # it's a special case. |
407 | # it's a special case. |
| 267 | _ruby_each_implementation |
408 | _ruby_each_implementation |
|
|
409 | |
|
|
410 | has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm |
| 268 | } |
411 | } |
| 269 | |
412 | |
| 270 | # @FUNCTION: ruby-ng_src_unpack |
413 | # @FUNCTION: ruby-ng_src_unpack |
| 271 | # @DESCRIPTION: |
414 | # @DESCRIPTION: |
| 272 | # Unpack the source archive. |
415 | # Unpack the source archive. |
| … | |
… | |
| 363 | type all_ruby_test &>/dev/null && \ |
506 | type all_ruby_test &>/dev/null && \ |
| 364 | _ruby_invoke_environment all all_ruby_test |
507 | _ruby_invoke_environment all all_ruby_test |
| 365 | } |
508 | } |
| 366 | |
509 | |
| 367 | _each_ruby_check_install() { |
510 | _each_ruby_check_install() { |
|
|
511 | local scancmd=scanelf |
|
|
512 | # we have a Mach-O object here |
|
|
513 | [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho |
|
|
514 | |
|
|
515 | has "${EAPI}" 2 && ! use prefix && EPREFIX= |
|
|
516 | |
| 368 | local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') |
517 | local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]') |
| 369 | local libruby_soname=$(scanelf -qS "/usr/$(get_libdir)/${libruby_basename}" | awk '{ print $1 }') |
518 | local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null) |
| 370 | local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') |
519 | local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]') |
| 371 | local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') |
520 | local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]') |
| 372 | |
521 | |
| 373 | # Look for wrong files in sitedir |
522 | # Look for wrong files in sitedir |
| 374 | if [[ -d "${D}${sitedir}" ]]; then |
523 | # if [[ -d "${D}${sitedir}" ]]; then |
| 375 | local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") |
524 | # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") |
| 376 | if [[ -n ${f} ]]; then |
525 | # if [[ -n ${f} ]]; then |
| 377 | eerror "Found files in sitedir, outsite sitelibdir:" |
526 | # eerror "Found files in sitedir, outsite sitelibdir:" |
| 378 | eerror "${f}" |
527 | # eerror "${f}" |
| 379 | die "Misplaced files in sitedir" |
528 | # die "Misplaced files in sitedir" |
| 380 | fi |
529 | # fi |
| 381 | fi |
530 | # fi |
| 382 | |
531 | |
| 383 | # The current implementation lacks libruby (i.e.: jruby) |
532 | # The current implementation lacks libruby (i.e.: jruby) |
| 384 | [[ -z ${libruby_soname} ]] && return 0 |
533 | [[ -z ${libruby_soname} ]] && return 0 |
| 385 | |
534 | |
| 386 | scanelf -qnR "${D}${sitedir}" \ |
535 | # Check also the gems directory, since we could be installing compiled |
|
|
536 | # extensions via ruby-fakegem; make sure to check only in sitelibdir, since |
|
|
537 | # that's what changes between two implementations (otherwise you'd get false |
|
|
538 | # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) |
|
|
539 | ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ |
| 387 | | fgrep -v "${libruby_soname}" \ |
540 | | fgrep -v "${libruby_soname}" \ |
|
|
541 | | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \ |
| 388 | > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log |
542 | > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log |
| 389 | |
543 | |
| 390 | if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then |
544 | if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then |
| 391 | ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}" |
545 | ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}" |
| 392 | ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) |
546 | ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) |
| 393 | die "Missing links to ${libruby}" |
547 | die "Missing links to ${libruby_soname}" |
| 394 | fi |
548 | fi |
| 395 | } |
549 | } |
| 396 | |
550 | |
| 397 | # @FUNCTION: ruby-ng_src_install |
551 | # @FUNCTION: ruby-ng_src_install |
| 398 | # @DESCRIPTION: |
552 | # @DESCRIPTION: |
| … | |
… | |
| 407 | |
561 | |
| 408 | _PHASE="check install" \ |
562 | _PHASE="check install" \ |
| 409 | _ruby_each_implementation _each_ruby_check_install |
563 | _ruby_each_implementation _each_ruby_check_install |
| 410 | } |
564 | } |
| 411 | |
565 | |
|
|
566 | # @FUNCTION: ruby_rbconfig_value |
|
|
567 | # @USAGE: rbconfig item |
|
|
568 | # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. |
|
|
569 | ruby_rbconfig_value() { |
|
|
570 | echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']") |
|
|
571 | } |
|
|
572 | |
| 412 | # @FUNCTION: doruby |
573 | # @FUNCTION: doruby |
| 413 | # @USAGE: file [file...] |
574 | # @USAGE: file [file...] |
| 414 | # @DESCRIPTION: |
575 | # @DESCRIPTION: |
| 415 | # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. |
576 | # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. |
| 416 | doruby() { |
577 | doruby() { |
| 417 | [[ -z ${RUBY} ]] && die "\$RUBY is not set" |
578 | [[ -z ${RUBY} ]] && die "\$RUBY is not set" |
|
|
579 | has "${EAPI}" 2 && ! use prefix && EPREFIX= |
| 418 | ( # don't want to pollute calling env |
580 | ( # don't want to pollute calling env |
| 419 | insinto $(${RUBY} -rrbconfig -e 'print Config::CONFIG["sitelibdir"]') |
581 | sitelibdir=$(ruby_rbconfig_value 'sitelibdir') |
|
|
582 | insinto ${sitelibdir#${EPREFIX}} |
| 420 | insopts -m 0644 |
583 | insopts -m 0644 |
| 421 | doins "$@" |
584 | doins "$@" |
| 422 | ) || die "failed to install $@" |
585 | ) || die "failed to install $@" |
| 423 | } |
586 | } |
| 424 | |
587 | |
| 425 | # @FUNCTION: ruby_get_libruby |
588 | # @FUNCTION: ruby_get_libruby |
| 426 | # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. |
589 | # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. |
| 427 | ruby_get_libruby() { |
590 | ruby_get_libruby() { |
| 428 | ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' |
591 | ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])' |
| 429 | } |
592 | } |
| 430 | |
593 | |
| 431 | # @FUNCTION: ruby_get_hdrdir |
594 | # @FUNCTION: ruby_get_hdrdir |
| 432 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
595 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
| 433 | ruby_get_hdrdir() { |
596 | ruby_get_hdrdir() { |
| 434 | local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]') |
597 | local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir') |
| 435 | |
598 | |
| 436 | if [[ "${rubyhdrdir}" = "nil" ]] ; then |
599 | if [[ "${rubyhdrdir}" = "nil" ]] ; then |
| 437 | rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]') |
600 | rubyhdrdir=$(ruby_rbconfig_value 'archdir') |
| 438 | fi |
601 | fi |
| 439 | |
602 | |
| 440 | echo "${rubyhdrdir}" |
603 | echo "${rubyhdrdir}" |
| 441 | } |
604 | } |
|
|
605 | |
|
|
606 | # @FUNCTION: ruby_get_version |
|
|
607 | # @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
|
|
608 | ruby_get_version() { |
|
|
609 | local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
|
|
610 | |
|
|
611 | echo $(${ruby} -e 'puts RUBY_VERSION') |
|
|
612 | } |
|
|
613 | |
|
|
614 | # @FUNCTION: ruby_get_implementation |
|
|
615 | # @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
|
|
616 | ruby_get_implementation() { |
|
|
617 | local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
|
|
618 | |
|
|
619 | case $(${ruby} --version) in |
|
|
620 | *Enterprise*) |
|
|
621 | echo "ree" |
|
|
622 | ;; |
|
|
623 | *jruby*) |
|
|
624 | echo "jruby" |
|
|
625 | ;; |
|
|
626 | *rubinius*) |
|
|
627 | echo "rbx" |
|
|
628 | ;; |
|
|
629 | *) |
|
|
630 | echo "mri" |
|
|
631 | ;; |
|
|
632 | esac |
|
|
633 | } |
|
|
634 | |
|
|
635 | # @FUNCTION: ruby-ng_rspec |
|
|
636 | # @DESCRIPTION: |
|
|
637 | # This is simply a wrapper around the rspec command (executed by $RUBY}) |
|
|
638 | # which also respects TEST_VERBOSE and NOCOLOR environment variables. |
|
|
639 | ruby-ng_rspec() { |
|
|
640 | if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then |
|
|
641 | ewarn "Missing dev-ruby/rspec in \${DEPEND}" |
|
|
642 | fi |
|
|
643 | |
|
|
644 | local rspec_params= |
|
|
645 | case ${NOCOLOR} in |
|
|
646 | 1|yes|true) |
|
|
647 | rspec_params+=" --no-color" |
|
|
648 | ;; |
|
|
649 | *) |
|
|
650 | rspec_params+=" --color" |
|
|
651 | ;; |
|
|
652 | esac |
|
|
653 | |
|
|
654 | case ${TEST_VERBOSE} in |
|
|
655 | 1|yes|true) |
|
|
656 | rspec_params+=" --format documentation" |
|
|
657 | ;; |
|
|
658 | *) |
|
|
659 | rspec_params+=" --format progress" |
|
|
660 | ;; |
|
|
661 | esac |
|
|
662 | |
|
|
663 | ${RUBY} -S rspec ${rspec_params} "$@" || die "rspec failed" |
|
|
664 | } |
|
|
665 | |
|
|
666 | # @FUNCTION: ruby-ng_cucumber |
|
|
667 | # @DESCRIPTION: |
|
|
668 | # This is simply a wrapper around the cucumber command (executed by $RUBY}) |
|
|
669 | # which also respects TEST_VERBOSE and NOCOLOR environment variables. |
|
|
670 | ruby-ng_cucumber() { |
|
|
671 | if [[ ${DEPEND} != *"dev-util/cucumber"* ]]; then |
|
|
672 | ewarn "Missing dev-util/cucumber in \${DEPEND}" |
|
|
673 | fi |
|
|
674 | |
|
|
675 | local cucumber_params= |
|
|
676 | case ${NOCOLOR} in |
|
|
677 | 1|yes|true) |
|
|
678 | cucumber_params+=" --no-color" |
|
|
679 | ;; |
|
|
680 | *) |
|
|
681 | cucumber_params+=" --color" |
|
|
682 | ;; |
|
|
683 | esac |
|
|
684 | |
|
|
685 | case ${TEST_VERBOSE} in |
|
|
686 | 1|yes|true) |
|
|
687 | cucumber_params+=" --format pretty" |
|
|
688 | ;; |
|
|
689 | *) |
|
|
690 | cucumber_params+=" --format progress" |
|
|
691 | ;; |
|
|
692 | esac |
|
|
693 | |
|
|
694 | if [[ ${RUBY} == *jruby ]]; then |
|
|
695 | ewarn "Skipping cucumber tests on JRuby (unsupported)." |
|
|
696 | return 0 |
|
|
697 | fi |
|
|
698 | |
|
|
699 | ${RUBY} -S cucumber ${cucumber_params} "$@" || die "cucumber failed" |
|
|
700 | } |
|
|
701 | |
|
|
702 | # @FUNCTION: ruby-ng_testrb-2 |
|
|
703 | # @DESCRIPTION: |
|
|
704 | # This is simply a replacement for the testrb command that load the test |
|
|
705 | # files and execute them, with test-unit 2.x. This actually requires |
|
|
706 | # either an old test-unit-2 version or 2.5.1-r1 or later, as they remove |
|
|
707 | # their script and we installed a broken wrapper for a while. |
|
|
708 | # This also respects TEST_VERBOSE and NOCOLOR environment variables. |
|
|
709 | ruby-ng_testrb-2() { |
|
|
710 | if [[ ${DEPEND} != *"dev-ruby/test-unit"* ]]; then |
|
|
711 | ewarn "Missing dev-ruby/test-unit in \${DEPEND}" |
|
|
712 | fi |
|
|
713 | |
|
|
714 | local testrb_params= |
|
|
715 | case ${NOCOLOR} in |
|
|
716 | 1|yes|true) |
|
|
717 | testrb_params+=" --no-use-color" |
|
|
718 | ;; |
|
|
719 | *) |
|
|
720 | testrb_params+=" --use-color=auto" |
|
|
721 | ;; |
|
|
722 | esac |
|
|
723 | |
|
|
724 | case ${TEST_VERBOSE} in |
|
|
725 | 1|yes|true) |
|
|
726 | testrb_params+=" --verbose=verbose" |
|
|
727 | ;; |
|
|
728 | *) |
|
|
729 | testrb_params+=" --verbose=normal" |
|
|
730 | ;; |
|
|
731 | esac |
|
|
732 | |
|
|
733 | ${RUBY} -S testrb-2 ${testrb_params} "$@" || die "testrb-2 failed" |
|
|
734 | } |