Gentoo Archives: gentoo-commits

From: Hans de Graaff <graaff@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/ruby/
Date: Sun, 10 May 2020 07:16:59
Message-Id: 1589095001.2dd5aa88a02df8e64485ee7d5e3e245c8e5f045a.graaff@gentoo
1 commit: 2dd5aa88a02df8e64485ee7d5e3e245c8e5f045a
2 Author: Hans de Graaff <graaff <AT> gentoo <DOT> org>
3 AuthorDate: Sun May 10 07:13:52 2020 +0000
4 Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org>
5 CommitDate: Sun May 10 07:16:41 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2dd5aa88
7
8 dev-lang/ruby: add USE=systemtap
9
10 This fixes an automagic dependency on dtrace.
11
12 Closes: https://bugs.gentoo.org/636644
13
14 Package-Manager: Portage-2.3.99, Repoman-2.3.22
15 Signed-off-by: Hans de Graaff <graaff <AT> gentoo.org>
16
17 dev-lang/ruby/metadata.xml | 17 +--
18 dev-lang/ruby/ruby-2.5.8-r1.ebuild | 222 ++++++++++++++++++++++++++++++++++
19 dev-lang/ruby/ruby-2.6.6-r2.ebuild | 234 ++++++++++++++++++++++++++++++++++++
20 dev-lang/ruby/ruby-2.7.1-r2.ebuild | 237 +++++++++++++++++++++++++++++++++++++
21 4 files changed, 702 insertions(+), 8 deletions(-)
22
23 diff --git a/dev-lang/ruby/metadata.xml b/dev-lang/ruby/metadata.xml
24 index ad18c95606a..3a5415201c6 100644
25 --- a/dev-lang/ruby/metadata.xml
26 +++ b/dev-lang/ruby/metadata.xml
27 @@ -1,12 +1,13 @@
28 <?xml version="1.0" encoding="UTF-8"?>
29 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
30 <pkgmetadata>
31 - <maintainer type="project">
32 - <email>ruby@g.o</email>
33 - <name>Gentoo Ruby Project</name>
34 - </maintainer>
35 - <use>
36 - <flag name="rubytests">Install ruby tests that can only be run after ruby is installed</flag>
37 - <flag name="rdoc">Install <pkg>dev-ruby/rdoc</pkg> after installing Ruby.</flag>
38 - </use>
39 + <maintainer type="project">
40 + <email>ruby@g.o</email>
41 + <name>Gentoo Ruby Project</name>
42 + </maintainer>
43 + <use>
44 + <flag name="rubytests">Install ruby tests that can only be run after ruby is installed</flag>
45 + <flag name="rdoc">Install <pkg>dev-ruby/rdoc</pkg> after installing Ruby.</flag>
46 + <flag name="systemtap">Enable SystemTAP/DTrace tracing</flag>
47 + </use>
48 </pkgmetadata>
49
50 diff --git a/dev-lang/ruby/ruby-2.5.8-r1.ebuild b/dev-lang/ruby/ruby-2.5.8-r1.ebuild
51 new file mode 100644
52 index 00000000000..ab80427fda6
53 --- /dev/null
54 +++ b/dev-lang/ruby/ruby-2.5.8-r1.ebuild
55 @@ -0,0 +1,222 @@
56 +# Copyright 1999-2020 Gentoo Authors
57 +# Distributed under the terms of the GNU General Public License v2
58 +
59 +EAPI=7
60 +
61 +inherit autotools flag-o-matic multilib
62 +
63 +MY_P="${PN}-$(ver_cut 1-3)"
64 +S=${WORKDIR}/${MY_P}
65 +
66 +SLOT=$(ver_cut 1-2)
67 +MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
68 +RUBYVERSION=${SLOT}.0
69 +
70 +DESCRIPTION="An object-oriented scripting language"
71 +HOMEPAGE="https://www.ruby-lang.org/"
72 +SRC_URI="https://cache.ruby-lang.org/pub/ruby/${SLOT}/${MY_P}.tar.xz"
73 +
74 +LICENSE="|| ( Ruby-BSD BSD-2 )"
75 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
76 +IUSE="berkdb debug doc examples gdbm ipv6 jemalloc libressl +rdoc rubytests socks5 +ssl static-libs systemtap tk xemacs"
77 +
78 +RDEPEND="
79 + berkdb? ( sys-libs/db:= )
80 + gdbm? ( sys-libs/gdbm:= )
81 + jemalloc? ( dev-libs/jemalloc )
82 + ssl? (
83 + !libressl? ( dev-libs/openssl:0= )
84 + libressl? ( dev-libs/libressl )
85 + )
86 + socks5? ( >=net-proxy/dante-1.1.13 )
87 + systemtap? ( dev-util/systemtap )
88 + tk? (
89 + dev-lang/tcl:0=[threads]
90 + dev-lang/tk:0=[threads]
91 + )
92 + dev-libs/libyaml
93 + dev-libs/libffi:=
94 + sys-libs/readline:0=
95 + sys-libs/zlib
96 + >=app-eselect/eselect-ruby-20171225
97 +"
98 +
99 +DEPEND="${RDEPEND}"
100 +
101 +BUNDLED_GEMS="
102 + >=dev-ruby/did_you_mean-1.2.0:2.5[ruby_targets_ruby25]
103 + >=dev-ruby/minitest-5.10.3[ruby_targets_ruby25]
104 + >=dev-ruby/net-telnet-0.1.1[ruby_targets_ruby25]
105 + >=dev-ruby/power_assert-1.1.1[ruby_targets_ruby25]
106 + >=dev-ruby/rake-12.3.0[ruby_targets_ruby25]
107 + >=dev-ruby/test-unit-3.2.7[ruby_targets_ruby25]
108 + >=dev-ruby/xmlrpc-0.3.0[ruby_targets_ruby25]
109 +"
110 +
111 +PDEPEND="
112 + ${BUNDLED_GEMS}
113 + virtual/rubygems[ruby_targets_ruby25]
114 + >=dev-ruby/json-2.0.2[ruby_targets_ruby25]
115 + rdoc? ( >=dev-ruby/rdoc-6.1.2[ruby_targets_ruby25] )
116 + xemacs? ( app-xemacs/ruby-modes )"
117 +
118 +src_prepare() {
119 + eapply "${FILESDIR}"/${SLOT}/{001,005,011}*.patch
120 +
121 + einfo "Unbundling gems..."
122 + cd "$S"
123 + # Remove bundled gems that we will install via PDEPEND, bug
124 + # 539700. Use explicit version numbers to ensure rm fails when they
125 + # change so we can update dependencies accordingly.
126 + rm -f gems/{did_you_mean-1.2.0,minitest-5.10.3,net-telnet-0.1.1,power_assert-1.1.1,rake-12.3.0,test-unit-3.2.7,xmlrpc-0.3.0}.gem || die
127 +
128 + einfo "Removing bundled libraries..."
129 + rm -fr ext/fiddle/libffi-3.2.1 || die
130 +
131 + eapply_user
132 +
133 + eautoreconf
134 +}
135 +
136 +src_configure() {
137 + local modules= myconf=
138 +
139 + # -fomit-frame-pointer makes ruby segfault, see bug #150413.
140 + filter-flags -fomit-frame-pointer
141 + # In many places aliasing rules are broken; play it safe
142 + # as it's risky with newer compilers to leave it as it is.
143 + append-flags -fno-strict-aliasing
144 +
145 + # Socks support via dante
146 + if use socks5 ; then
147 + # Socks support can't be disabled as long as SOCKS_SERVER is
148 + # set and socks library is present, so need to unset
149 + # SOCKS_SERVER in that case.
150 + unset SOCKS_SERVER
151 + fi
152 +
153 + # Increase GC_MALLOC_LIMIT if set (default is 8000000)
154 + if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
155 + append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
156 + fi
157 +
158 + # ipv6 hack, bug 168939. Needs --enable-ipv6.
159 + use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
160 +
161 + # Determine which modules *not* to build depending in the USE flags.
162 + if ! use berkdb ; then
163 + modules="${modules},dbm"
164 + fi
165 + if ! use gdbm ; then
166 + modules="${modules},gdbm"
167 + fi
168 + if ! use ssl ; then
169 + modules="${modules},openssl"
170 + fi
171 + if ! use tk ; then
172 + modules="${modules},tk"
173 + fi
174 +
175 + # Provide an empty LIBPATHENV because we disable rpath but we do not
176 + # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
177 + # #564272
178 + INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
179 + --program-suffix=${MY_SUFFIX} \
180 + --with-soname=ruby${MY_SUFFIX} \
181 + --enable-shared \
182 + --enable-pthread \
183 + --disable-rpath \
184 + --with-out-ext="${modules}" \
185 + $(use_with jemalloc jemalloc) \
186 + $(use_enable socks5 socks) \
187 + $(use_enable systemtap dtrace) \
188 + $(use_enable doc install-doc) \
189 + --enable-ipv6 \
190 + $(use_enable static-libs static) \
191 + $(use_enable static-libs install-static-library) \
192 + $(use_with static-libs static-linked-ext) \
193 + $(use_enable debug) \
194 + ${myconf} \
195 + --enable-option-checking=no
196 +}
197 +
198 +src_compile() {
199 + emake V=1 EXTLDFLAGS="${LDFLAGS}"
200 +}
201 +
202 +src_test() {
203 + emake -j1 V=1 test
204 +
205 + elog "Ruby's make test has been run. Ruby also ships with a make check"
206 + elog "that cannot be run until after ruby has been installed."
207 + elog
208 + if use rubytests; then
209 + elog "You have enabled rubytests, so they will be installed to"
210 + elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
211 + elog "than root, and you must place them into a writeable directory."
212 + elog "Then call: "
213 + elog
214 + elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
215 + else
216 + elog "Enable the rubytests USE flag to install the make check tests"
217 + fi
218 +}
219 +
220 +src_install() {
221 + # Remove the remaining bundled gems. We do this late in the process
222 + # since they are used during the build to e.g. create the
223 + # documentation.
224 + rm -rf ext/json || die
225 +
226 + # Ruby is involved in the install process, we don't want interference here.
227 + unset RUBYOPT
228 +
229 + local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
230 +
231 + LD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
232 + RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
233 + for d in $(find "${S}/ext" -type d) ; do
234 + RUBYLIB="${RUBYLIB}:$d"
235 + done
236 + export LD_LIBRARY_PATH RUBYLIB
237 +
238 + emake V=1 DESTDIR="${D}" install
239 +
240 + # Remove installed rubygems and rdoc copy
241 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
242 + rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
243 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
244 + rm -rf "${ED}/usr/bin/"{ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
245 +
246 + if use doc; then
247 + make DESTDIR="${D}" install-doc || die "make install-doc failed"
248 + fi
249 +
250 + if use examples; then
251 + dodoc -r sample
252 + fi
253 +
254 + dodoc ChangeLog NEWS doc/NEWS* README*
255 +
256 + if use rubytests; then
257 + pushd test
258 + insinto /usr/share/${PN}-${SLOT}/test
259 + doins -r .
260 + popd
261 + fi
262 +}
263 +
264 +pkg_postinst() {
265 + if [[ ! -n $(readlink "${EROOT}"/usr/bin/ruby) ]] ; then
266 + eselect ruby set ruby${MY_SUFFIX}
267 + fi
268 +
269 + elog
270 + elog "To switch between available Ruby profiles, execute as root:"
271 + elog "\teselect ruby set ruby(23|24|...)"
272 + elog
273 +}
274 +
275 +pkg_postrm() {
276 + eselect ruby cleanup
277 +}
278
279 diff --git a/dev-lang/ruby/ruby-2.6.6-r2.ebuild b/dev-lang/ruby/ruby-2.6.6-r2.ebuild
280 new file mode 100644
281 index 00000000000..68311ff8543
282 --- /dev/null
283 +++ b/dev-lang/ruby/ruby-2.6.6-r2.ebuild
284 @@ -0,0 +1,234 @@
285 +# Copyright 1999-2020 Gentoo Authors
286 +# Distributed under the terms of the GNU General Public License v2
287 +
288 +EAPI=7
289 +
290 +inherit autotools flag-o-matic multilib
291 +
292 +MY_P="${PN}-$(ver_cut 1-3)"
293 +S=${WORKDIR}/${MY_P}
294 +
295 +SLOT=$(ver_cut 1-2)
296 +MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
297 +RUBYVERSION=${SLOT}.0
298 +
299 +DESCRIPTION="An object-oriented scripting language"
300 +HOMEPAGE="https://www.ruby-lang.org/"
301 +SRC_URI="https://cache.ruby-lang.org/pub/ruby/${SLOT}/${MY_P}.tar.xz"
302 +
303 +LICENSE="|| ( Ruby-BSD BSD-2 )"
304 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
305 +IUSE="berkdb debug doc examples gdbm ipv6 jemalloc jit libressl +rdoc rubytests socks5 +ssl static-libs systemtap tk xemacs"
306 +
307 +RDEPEND="
308 + berkdb? ( sys-libs/db:= )
309 + gdbm? ( sys-libs/gdbm:= )
310 + jemalloc? ( dev-libs/jemalloc )
311 + jit? ( || ( sys-devel/gcc:* sys-devel/clang:* ) )
312 + ssl? (
313 + !libressl? ( dev-libs/openssl:0= )
314 + libressl? ( dev-libs/libressl )
315 + )
316 + socks5? ( >=net-proxy/dante-1.1.13 )
317 + systemtap? ( dev-util/systemtap )
318 + tk? (
319 + dev-lang/tcl:0=[threads]
320 + dev-lang/tk:0=[threads]
321 + )
322 + dev-libs/libyaml
323 + dev-libs/libffi:=
324 + sys-libs/readline:0=
325 + sys-libs/zlib
326 + >=app-eselect/eselect-ruby-20181225
327 +"
328 +
329 +DEPEND="${RDEPEND}"
330 +
331 +BUNDLED_GEMS="
332 + >=dev-ruby/did_you_mean-1.2.1[ruby_targets_ruby26]
333 + >=dev-ruby/minitest-5.11.3[ruby_targets_ruby26]
334 + >=dev-ruby/net-telnet-0.2.0[ruby_targets_ruby26]
335 + >=dev-ruby/power_assert-1.1.3[ruby_targets_ruby26]
336 + >=dev-ruby/rake-12.3.2[ruby_targets_ruby26]
337 + >=dev-ruby/test-unit-3.2.9[ruby_targets_ruby26]
338 + >=dev-ruby/xmlrpc-0.3.0[ruby_targets_ruby26]
339 +"
340 +
341 +PDEPEND="
342 + ${BUNDLED_GEMS}
343 + virtual/rubygems[ruby_targets_ruby26]
344 + >=dev-ruby/bundler-1.17.2[ruby_targets_ruby26]
345 + >=dev-ruby/json-2.0.2[ruby_targets_ruby26]
346 + rdoc? ( >=dev-ruby/rdoc-6.1.2[ruby_targets_ruby26] )
347 + xemacs? ( app-xemacs/ruby-modes )"
348 +
349 +src_prepare() {
350 + # 005 does not compile bigdecimal and is questionable because it
351 + # compiles ruby in a non-standard way, may be dropped
352 + eapply "${FILESDIR}"/2.6/010*.patch
353 +
354 + einfo "Unbundling gems..."
355 + cd "$S"
356 + # Remove bundled gems that we will install via PDEPEND, bug
357 + # 539700.
358 + rm -fr gems/* || die
359 +
360 + einfo "Removing bundled libraries..."
361 + rm -fr ext/fiddle/libffi-3.2.1 || die
362 +
363 + eapply_user
364 +
365 + eautoreconf
366 +}
367 +
368 +src_configure() {
369 + local modules= myconf=
370 +
371 + # -fomit-frame-pointer makes ruby segfault, see bug #150413.
372 + filter-flags -fomit-frame-pointer
373 + # In many places aliasing rules are broken; play it safe
374 + # as it's risky with newer compilers to leave it as it is.
375 + append-flags -fno-strict-aliasing
376 +
377 + # Socks support via dante
378 + if use socks5 ; then
379 + # Socks support can't be disabled as long as SOCKS_SERVER is
380 + # set and socks library is present, so need to unset
381 + # SOCKS_SERVER in that case.
382 + unset SOCKS_SERVER
383 + fi
384 +
385 + # Increase GC_MALLOC_LIMIT if set (default is 8000000)
386 + if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
387 + append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
388 + fi
389 +
390 + # ipv6 hack, bug 168939. Needs --enable-ipv6.
391 + use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
392 +
393 + # Determine which modules *not* to build depending in the USE flags.
394 + if ! use berkdb ; then
395 + modules="${modules},dbm"
396 + fi
397 + if ! use gdbm ; then
398 + modules="${modules},gdbm"
399 + fi
400 + if ! use ssl ; then
401 + modules="${modules},openssl"
402 + fi
403 + if ! use tk ; then
404 + modules="${modules},tk"
405 + fi
406 +
407 + # Provide an empty LIBPATHENV because we disable rpath but we do not
408 + # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
409 + # #564272
410 + INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
411 + --program-suffix=${MY_SUFFIX} \
412 + --with-soname=ruby${MY_SUFFIX} \
413 + --enable-shared \
414 + --enable-pthread \
415 + --disable-rpath \
416 + --with-out-ext="${modules}" \
417 + $(use_with jemalloc jemalloc) \
418 + $(use_enable jit jit-support ) \
419 + $(use_enable socks5 socks) \
420 + $(use_enable systemtap dtrace) \
421 + $(use_enable doc install-doc) \
422 + --enable-ipv6 \
423 + $(use_enable static-libs static) \
424 + $(use_enable static-libs install-static-library) \
425 + $(use_with static-libs static-linked-ext) \
426 + $(use_enable debug) \
427 + ${myconf} \
428 + --enable-option-checking=no
429 +
430 + # Makefile is broken because it lacks -ldl
431 + rm -rf ext/-test-/popen_deadlock || die
432 +}
433 +
434 +src_compile() {
435 + emake V=1 EXTLDFLAGS="${LDFLAGS}" MJIT_CFLAGS="${CFLAGS}" MJIT_OPTFLAGS="" MJIT_DEBUGFLAGS=""
436 +}
437 +
438 +src_test() {
439 + emake -j1 V=1 test
440 +
441 + elog "Ruby's make test has been run. Ruby also ships with a make check"
442 + elog "that cannot be run until after ruby has been installed."
443 + elog
444 + if use rubytests; then
445 + elog "You have enabled rubytests, so they will be installed to"
446 + elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
447 + elog "than root, and you must place them into a writeable directory."
448 + elog "Then call: "
449 + elog
450 + elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
451 + else
452 + elog "Enable the rubytests USE flag to install the make check tests"
453 + fi
454 +}
455 +
456 +src_install() {
457 + # Remove the remaining bundled gems. We do this late in the process
458 + # since they are used during the build to e.g. create the
459 + # documentation.
460 + rm -rf ext/json || die
461 + rm -rf lib/bundler* lib/rdoc/rdoc.gemspec || die
462 +
463 + # Ruby is involved in the install process, we don't want interference here.
464 + unset RUBYOPT
465 +
466 + local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
467 +
468 + LD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
469 + RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
470 + for d in $(find "${S}/ext" -type d) ; do
471 + RUBYLIB="${RUBYLIB}:$d"
472 + done
473 + export LD_LIBRARY_PATH RUBYLIB
474 +
475 + # Create directory for the default gems
476 + local gem_home="${EPREFIX}/usr/$(get_libdir)/ruby/gems/${RUBYVERSION}"
477 + mkdir -p "${D}/${gem_home}" || die "mkdir gem home failed"
478 +
479 + emake V=1 DESTDIR="${D}" GEM_DESTDIR=${gem_home} install
480 +
481 + # Remove installed rubygems and rdoc copy
482 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
483 + rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
484 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
485 + rm -rf "${ED}/usr/bin/"{bundle,bundler,ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
486 +
487 + if use doc; then
488 + emake DESTDIR="${D}" GEM_DESTDIR=${gem_home} install-doc
489 + fi
490 +
491 + if use examples; then
492 + dodoc -r sample
493 + fi
494 +
495 + dodoc ChangeLog NEWS doc/NEWS* README*
496 +
497 + if use rubytests; then
498 + pushd test
499 + insinto /usr/share/${PN}-${SLOT}/test
500 + doins -r .
501 + popd
502 + fi
503 +}
504 +
505 +pkg_postinst() {
506 + if [[ ! -n $(readlink "${EROOT}"/usr/bin/ruby) ]] ; then
507 + eselect ruby set ruby${MY_SUFFIX}
508 + fi
509 +
510 + elog
511 + elog "To switch between available Ruby profiles, execute as root:"
512 + elog "\teselect ruby set ruby(23|24|...)"
513 + elog
514 +}
515 +
516 +pkg_postrm() {
517 + eselect ruby cleanup
518 +}
519
520 diff --git a/dev-lang/ruby/ruby-2.7.1-r2.ebuild b/dev-lang/ruby/ruby-2.7.1-r2.ebuild
521 new file mode 100644
522 index 00000000000..e4e8048e083
523 --- /dev/null
524 +++ b/dev-lang/ruby/ruby-2.7.1-r2.ebuild
525 @@ -0,0 +1,237 @@
526 +# Copyright 1999-2020 Gentoo Authors
527 +# Distributed under the terms of the GNU General Public License v2
528 +
529 +EAPI=7
530 +
531 +inherit autotools flag-o-matic multilib
532 +
533 +MY_P="${PN}-$(ver_cut 1-3)"
534 +S=${WORKDIR}/${MY_P}
535 +
536 +SLOT=$(ver_cut 1-2)
537 +MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
538 +RUBYVERSION=${SLOT}.0
539 +
540 +DESCRIPTION="An object-oriented scripting language"
541 +HOMEPAGE="https://www.ruby-lang.org/"
542 +SRC_URI="https://cache.ruby-lang.org/pub/ruby/${SLOT}/${MY_P}.tar.xz"
543 +
544 +LICENSE="|| ( Ruby-BSD BSD-2 )"
545 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
546 +IUSE="berkdb debug doc examples gdbm ipv6 jemalloc jit libressl +rdoc rubytests socks5 +ssl static-libs systemtap tk xemacs"
547 +
548 +RDEPEND="
549 + berkdb? ( sys-libs/db:= )
550 + gdbm? ( sys-libs/gdbm:= )
551 + jemalloc? ( dev-libs/jemalloc )
552 + jit? ( || ( sys-devel/gcc:* sys-devel/clang:* ) )
553 + ssl? (
554 + !libressl? ( dev-libs/openssl:0= )
555 + libressl? ( dev-libs/libressl )
556 + )
557 + socks5? ( >=net-proxy/dante-1.1.13 )
558 + systemtap? ( dev-util/systemtap )
559 + tk? (
560 + dev-lang/tcl:0=[threads]
561 + dev-lang/tk:0=[threads]
562 + )
563 + dev-libs/libyaml
564 + dev-libs/libffi:=
565 + sys-libs/readline:0=
566 + sys-libs/zlib
567 + >=app-eselect/eselect-ruby-20191222
568 +"
569 +
570 +DEPEND="${RDEPEND}"
571 +
572 +BUNDLED_GEMS="
573 + >=dev-ruby/minitest-5.13.0[ruby_targets_ruby27]
574 + >=dev-ruby/net-telnet-0.2.0[ruby_targets_ruby27]
575 + >=dev-ruby/power_assert-1.1.7[ruby_targets_ruby27]
576 + >=dev-ruby/rake-13.0.1[ruby_targets_ruby27]
577 + >=dev-ruby/test-unit-3.3.4[ruby_targets_ruby27]
578 + >=dev-ruby/xmlrpc-0.3.0[ruby_targets_ruby27]
579 +"
580 +
581 +PDEPEND="
582 + ${BUNDLED_GEMS}
583 + virtual/rubygems[ruby_targets_ruby27]
584 + >=dev-ruby/bundler-2.1.4[ruby_targets_ruby27]
585 + >=dev-ruby/did_you_mean-1.3.1[ruby_targets_ruby27]
586 + >=dev-ruby/json-2.0.2[ruby_targets_ruby27]
587 + rdoc? ( >=dev-ruby/rdoc-6.1.2[ruby_targets_ruby27] )
588 + xemacs? ( app-xemacs/ruby-modes )"
589 +
590 +src_prepare() {
591 + # 005 does not compile bigdecimal and is questionable because it
592 + # compiles ruby in a non-standard way, may be dropped
593 + eapply "${FILESDIR}"/2.7/010*.patch
594 +
595 + einfo "Unbundling gems..."
596 + cd "$S"
597 + # Remove bundled gems that we will install via PDEPEND, bug
598 + # 539700.
599 + rm -fr gems/* || die
600 + # Don't install CLI tools since they will clash with the gem
601 + rm -f bin/{racc,racc2y,y2racc} || die
602 + sed -i -e '/executables/ s:^:#:' lib/racc/racc.gemspec || die
603 +
604 + einfo "Removing bundled libraries..."
605 + rm -fr ext/fiddle/libffi-3.2.1 || die
606 +
607 + eapply_user
608 +
609 + eautoreconf
610 +}
611 +
612 +src_configure() {
613 + local modules= myconf=
614 +
615 + # -fomit-frame-pointer makes ruby segfault, see bug #150413.
616 + filter-flags -fomit-frame-pointer
617 + # In many places aliasing rules are broken; play it safe
618 + # as it's risky with newer compilers to leave it as it is.
619 + append-flags -fno-strict-aliasing
620 +
621 + # Socks support via dante
622 + if use socks5 ; then
623 + # Socks support can't be disabled as long as SOCKS_SERVER is
624 + # set and socks library is present, so need to unset
625 + # SOCKS_SERVER in that case.
626 + unset SOCKS_SERVER
627 + fi
628 +
629 + # Increase GC_MALLOC_LIMIT if set (default is 8000000)
630 + if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
631 + append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
632 + fi
633 +
634 + # ipv6 hack, bug 168939. Needs --enable-ipv6.
635 + use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
636 +
637 + # Determine which modules *not* to build depending in the USE flags.
638 + if ! use berkdb ; then
639 + modules="${modules},dbm"
640 + fi
641 + if ! use gdbm ; then
642 + modules="${modules},gdbm"
643 + fi
644 + if ! use ssl ; then
645 + modules="${modules},openssl"
646 + fi
647 + if ! use tk ; then
648 + modules="${modules},tk"
649 + fi
650 +
651 + # Provide an empty LIBPATHENV because we disable rpath but we do not
652 + # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
653 + # #564272
654 + INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
655 + --program-suffix=${MY_SUFFIX} \
656 + --with-soname=ruby${MY_SUFFIX} \
657 + --enable-shared \
658 + --enable-pthread \
659 + --disable-rpath \
660 + --with-out-ext="${modules}" \
661 + $(use_with jemalloc jemalloc) \
662 + $(use_enable jit jit-support ) \
663 + $(use_enable socks5 socks) \
664 + $(use_enable systemtap dtrace) \
665 + $(use_enable doc install-doc) \
666 + --enable-ipv6 \
667 + $(use_enable static-libs static) \
668 + $(use_enable static-libs install-static-library) \
669 + $(use_with static-libs static-linked-ext) \
670 + $(use_enable debug) \
671 + ${myconf} \
672 + --enable-option-checking=no
673 +
674 + # Makefile is broken because it lacks -ldl
675 + rm -rf ext/-test-/popen_deadlock || die
676 +}
677 +
678 +src_compile() {
679 + emake V=1 EXTLDFLAGS="${LDFLAGS}" MJIT_CFLAGS="${CFLAGS}" MJIT_OPTFLAGS="" MJIT_DEBUGFLAGS=""
680 +}
681 +
682 +src_test() {
683 + emake -j1 V=1 test
684 +
685 + elog "Ruby's make test has been run. Ruby also ships with a make check"
686 + elog "that cannot be run until after ruby has been installed."
687 + elog
688 + if use rubytests; then
689 + elog "You have enabled rubytests, so they will be installed to"
690 + elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
691 + elog "than root, and you must place them into a writeable directory."
692 + elog "Then call: "
693 + elog
694 + elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
695 + else
696 + elog "Enable the rubytests USE flag to install the make check tests"
697 + fi
698 +}
699 +
700 +src_install() {
701 + # Remove the remaining bundled gems. We do this late in the process
702 + # since they are used during the build to e.g. create the
703 + # documentation.
704 + rm -rf ext/json || die
705 + rm -rf lib/bundler* lib/rdoc/rdoc.gemspec || die
706 +
707 + # Ruby is involved in the install process, we don't want interference here.
708 + unset RUBYOPT
709 +
710 + local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
711 +
712 + LD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
713 + RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
714 + for d in $(find "${S}/ext" -type d) ; do
715 + RUBYLIB="${RUBYLIB}:$d"
716 + done
717 + export LD_LIBRARY_PATH RUBYLIB
718 +
719 + # Create directory for the default gems
720 + local gem_home="${EPREFIX}/usr/$(get_libdir)/ruby/gems/${RUBYVERSION}"
721 + mkdir -p "${D}/${gem_home}" || die "mkdir gem home failed"
722 +
723 + emake V=1 DESTDIR="${D}" GEM_DESTDIR=${gem_home} install
724 +
725 + # Remove installed rubygems and rdoc copy
726 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
727 + rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
728 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
729 + rm -rf "${ED}/usr/bin/"{bundle,bundler,ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
730 +
731 + if use doc; then
732 + emake DESTDIR="${D}" GEM_DESTDIR=${gem_home} install-doc
733 + fi
734 +
735 + if use examples; then
736 + dodoc -r sample
737 + fi
738 +
739 + dodoc ChangeLog NEWS doc/NEWS* README*
740 +
741 + if use rubytests; then
742 + pushd test
743 + insinto /usr/share/${PN}-${SLOT}/test
744 + doins -r .
745 + popd
746 + fi
747 +}
748 +
749 +pkg_postinst() {
750 + if [[ ! -n $(readlink "${EROOT}"/usr/bin/ruby) ]] ; then
751 + eselect ruby set ruby${MY_SUFFIX}
752 + fi
753 +
754 + elog
755 + elog "To switch between available Ruby profiles, execute as root:"
756 + elog "\teselect ruby set ruby(23|24|...)"
757 + elog
758 +}
759 +
760 +pkg_postrm() {
761 + eselect ruby cleanup
762 +}