Gentoo Archives: gentoo-commits

From: Quentin Retornaz <gentoo@××××××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/libressl:master commit in: dev-lang/ruby/, dev-lang/ruby/files/2.7/
Date: Sat, 07 May 2022 01:31:58
Message-Id: 1651887047.15078e93c9a54ebeeddbff334a0104ae34790ff6.quentin@gentoo
1 commit: 15078e93c9a54ebeeddbff334a0104ae34790ff6
2 Author: orbea <orbea <AT> riseup <DOT> net>
3 AuthorDate: Wed May 4 18:11:07 2022 +0000
4 Commit: Quentin Retornaz <gentoo <AT> retornaz <DOT> com>
5 CommitDate: Sat May 7 01:30:47 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/libressl.git/commit/?id=15078e93
7
8 dev-lang/ruby: Added
9
10 Fixed with OpenBSD patch.
11
12 Signed-off-by: orbea <orbea <AT> riseup.net>
13 Closes: https://github.com/gentoo/libressl/pull/404
14 Signed-off-by: Quentin Retornaz <gentoo <AT> retornaz.com>
15
16 dev-lang/ruby/Manifest | 1 +
17 dev-lang/ruby/files/2.7/001-libressl.patch | 16 ++
18 dev-lang/ruby/files/2.7/003-did-you-mean.patch | 16 ++
19 .../ruby/files/2.7/010-default-gem-location.patch | 20 ++
20 dev-lang/ruby/files/2.7/900-musl-coroutine.patch | 41 ++++
21 dev-lang/ruby/files/2.7/901-musl-stacksize.patch | 26 ++
22 dev-lang/ruby/metadata.xml | 13 +
23 dev-lang/ruby/ruby-2.7.6.ebuild | 272 +++++++++++++++++++++
24 8 files changed, 405 insertions(+)
25
26 diff --git a/dev-lang/ruby/Manifest b/dev-lang/ruby/Manifest
27 new file mode 100644
28 index 0000000..091a58f
29 --- /dev/null
30 +++ b/dev-lang/ruby/Manifest
31 @@ -0,0 +1 @@
32 +DIST ruby-2.7.6.tar.xz 12084408 BLAKE2B 4b40e66aeeca3884983fffcf31c4713eb4fcdd62232e795dc5a0c03236c3c05200068902c0cb987455297bec2bcfc2a9a24f2841d18a480c7d09b86318daab3f SHA512 e86410b59d5917786fe43b00fd75dedd0e7f84611286b9274c542d2e562088fcee6bcc6c2596c30ccf793280d2bac6bfbb2619ef0513b3ca31f10f88684c7b1f
33
34 diff --git a/dev-lang/ruby/files/2.7/001-libressl.patch b/dev-lang/ruby/files/2.7/001-libressl.patch
35 new file mode 100644
36 index 0000000..71badb9
37 --- /dev/null
38 +++ b/dev-lang/ruby/files/2.7/001-libressl.patch
39 @@ -0,0 +1,16 @@
40 +Fix build with opaque OCSP_BASICRESP in LibreSSL 3.5.
41 +The bug this works around should be fixed since LibreSSL 2.4.2
42 +as far as I can tell.
43 +
44 +Index: ext/openssl/ossl_ocsp.c
45 +--- a/ext/openssl/ossl_ocsp.c.orig
46 ++++ b/ext/openssl/ossl_ocsp.c
47 +@@ -1093,7 +1093,7 @@ ossl_ocspbres_verify(int argc, VALUE *argv, VALUE self
48 + * exists in LibreSSL 2.1.10, 2.2.9, 2.3.6, 2.4.1.
49 + */
50 + if (!(flg & (OCSP_NOCHAIN | OCSP_NOVERIFY)) &&
51 +- sk_X509_num(x509s) && sk_X509_num(bs->certs)) {
52 ++ sk_X509_num(x509s) && sk_X509_num(OCSP_resp_get0_certs(bs))) {
53 + int i;
54 +
55 + bs = ASN1_item_dup(ASN1_ITEM_rptr(OCSP_BASICRESP), bs);
56
57 diff --git a/dev-lang/ruby/files/2.7/003-did-you-mean.patch b/dev-lang/ruby/files/2.7/003-did-you-mean.patch
58 new file mode 100644
59 index 0000000..26beb65
60 --- /dev/null
61 +++ b/dev-lang/ruby/files/2.7/003-did-you-mean.patch
62 @@ -0,0 +1,16 @@
63 +--- ruby27/gem_prelude.rb 2021-04-28 19:07:46.875571113 +0200
64 ++++ ruby30/gem_prelude.rb 2021-04-28 19:07:35.971511765 +0200
65 +@@ -1,2 +1,11 @@
66 +-require 'rubygems.rb' if defined?(Gem)
67 +-require 'did_you_mean' if defined?(DidYouMean)
68 ++begin
69 ++ require 'rubygems'
70 ++rescue LoadError
71 ++ warn "`RubyGems' were not loaded."
72 ++end if defined?(Gem)
73 ++
74 ++begin
75 ++ require 'did_you_mean'
76 ++rescue LoadError
77 ++ warn "`did_you_mean' was not loaded."
78 ++end if defined?(DidYouMean)
79
80 diff --git a/dev-lang/ruby/files/2.7/010-default-gem-location.patch b/dev-lang/ruby/files/2.7/010-default-gem-location.patch
81 new file mode 100644
82 index 0000000..7a50c35
83 --- /dev/null
84 +++ b/dev-lang/ruby/files/2.7/010-default-gem-location.patch
85 @@ -0,0 +1,20 @@
86 +--- a/tool/rbinstall.rb.~1~ 2019-01-24 02:00:07.000000000 +0100
87 ++++ b/tool/rbinstall.rb 2019-02-03 08:39:49.778007118 +0100
88 +@@ -806,7 +806,7 @@
89 + end
90 +
91 + def install_default_gem(dir, srcdir)
92 +- gem_dir = Gem.default_dir
93 ++ gem_dir = ENV['GEM_DESTDIR']
94 + directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode)
95 + prepare "default gems from #{dir}", gem_dir, directories
96 +
97 +@@ -844,7 +844,7 @@
98 + end
99 +
100 + install?(:ext, :comm, :gem, :'bundled-gems') do
101 +- gem_dir = Gem.default_dir
102 ++ gem_dir = ENV['GEM_DESTDIR']
103 + directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode)
104 + prepare "bundled gems", gem_dir, directories
105 + install_dir = with_destdir(gem_dir)
106
107 diff --git a/dev-lang/ruby/files/2.7/900-musl-coroutine.patch b/dev-lang/ruby/files/2.7/900-musl-coroutine.patch
108 new file mode 100644
109 index 0000000..ed47c54
110 --- /dev/null
111 +++ b/dev-lang/ruby/files/2.7/900-musl-coroutine.patch
112 @@ -0,0 +1,41 @@
113 +Adapted for Gentoo version 2.7.4
114 +
115 +From b570e7de87aaad8c903176d835e8124127f627b3 Mon Sep 17 00:00:00 2001
116 +From: Andrew Aladjev <aladjev.andrew@×××××.com>
117 +Date: Sat, 26 Sep 2020 12:58:06 +0300
118 +Subject: [PATCH] fixed default coroutine selection for musl
119 +
120 +---
121 + configure.ac | 5 ++++-
122 + coroutine/copy/Context.c | 2 ++
123 + 2 files changed, 6 insertions(+), 1 deletion(-)
124 +
125 +diff --git a/configure.ac b/configure.ac
126 +index ab5d532c103b..084f0936c006 100644
127 +--- a/configure.ac
128 ++++ b/configure.ac
129 +@@ -2364,7 +2364,10 @@
130 + rb_cv_coroutine=copy
131 + ],
132 + [*], [
133 +- rb_cv_coroutine=ucontext
134 ++ AC_CHECK_FUNCS([getcontext swapcontext makecontext],
135 ++ [rb_cv_coroutine=ucontext],
136 ++ [rb_cv_coroutine=copy; break]
137 ++ )
138 + ]
139 + )
140 + AC_MSG_RESULT(${rb_cv_coroutine})
141 +diff --git a/coroutine/copy/Context.c b/coroutine/copy/Context.c
142 +index c1b4144e9857..94a7f57f7d89 100644
143 +--- a/coroutine/copy/Context.c
144 ++++ b/coroutine/copy/Context.c
145 +@@ -5,6 +5,8 @@
146 + * Copyright, 2019, by Samuel Williams.
147 + */
148 +
149 ++#include <sys/types.h>
150 ++
151 + #include "Context.h"
152 +
153 + // http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
154
155 diff --git a/dev-lang/ruby/files/2.7/901-musl-stacksize.patch b/dev-lang/ruby/files/2.7/901-musl-stacksize.patch
156 new file mode 100644
157 index 0000000..e5fcfce
158 --- /dev/null
159 +++ b/dev-lang/ruby/files/2.7/901-musl-stacksize.patch
160 @@ -0,0 +1,26 @@
161 +musl has a conservative stacksize, as compared to glibc, so treat it
162 +like other systems with such stacksize
163 +
164 +diff --git a/thread_pthread.c b/thread_pthread.c
165 +index 951885ffa0..e2d662143b 100644
166 +--- a/thread_pthread.c
167 ++++ b/thread_pthread.c
168 +@@ -721,7 +721,7 @@ ruby_init_stack(volatile VALUE *addr
169 + {
170 + native_main_thread.id = pthread_self();
171 +
172 +-#if MAINSTACKADDR_AVAILABLE
173 ++#if MAINSTACKADDR_AVAILABLE && !(defined(__linux__) && !defined(__GLIBC__))
174 + if (native_main_thread.stack_maxsize) return;
175 + {
176 + void* stackaddr;
177 +@@ -1680,7 +1680,7 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr)
178 +
179 + #ifdef STACKADDR_AVAILABLE
180 + if (get_stack(&base, &size) == 0) {
181 +-# ifdef __APPLE__
182 ++# if defined(__APPLE__) || (defined(__linux__) && !defined(__GLIBC__))
183 + if (pthread_equal(th->thread_id, native_main_thread.id)) {
184 + struct rlimit rlim;
185 + if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur > size) {
186 +
187
188 diff --git a/dev-lang/ruby/metadata.xml b/dev-lang/ruby/metadata.xml
189 new file mode 100644
190 index 0000000..81c9398
191 --- /dev/null
192 +++ b/dev-lang/ruby/metadata.xml
193 @@ -0,0 +1,13 @@
194 +<?xml version="1.0" encoding="UTF-8"?>
195 +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
196 +<pkgmetadata>
197 + <maintainer type="project">
198 + <email>ruby@g.o</email>
199 + <name>Gentoo Ruby Project</name>
200 + </maintainer>
201 + <use>
202 + <flag name="rubytests">Install ruby tests that can only be run after ruby is installed</flag>
203 + <flag name="rdoc">Install <pkg>dev-ruby/rdoc</pkg> after installing Ruby.</flag>
204 + <flag name="systemtap">Enable SystemTAP/DTrace tracing</flag>
205 + </use>
206 +</pkgmetadata>
207
208 diff --git a/dev-lang/ruby/ruby-2.7.6.ebuild b/dev-lang/ruby/ruby-2.7.6.ebuild
209 new file mode 100644
210 index 0000000..fc44e6a
211 --- /dev/null
212 +++ b/dev-lang/ruby/ruby-2.7.6.ebuild
213 @@ -0,0 +1,272 @@
214 +# Copyright 1999-2022 Gentoo Authors
215 +# Distributed under the terms of the GNU General Public License v2
216 +
217 +EAPI=7
218 +
219 +inherit autotools flag-o-matic
220 +
221 +MY_P="${PN}-$(ver_cut 1-3)"
222 +S=${WORKDIR}/${MY_P}
223 +
224 +SLOT=$(ver_cut 1-2)
225 +MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
226 +RUBYVERSION=${SLOT}.0
227 +
228 +DESCRIPTION="An object-oriented scripting language"
229 +HOMEPAGE="https://www.ruby-lang.org/"
230 +SRC_URI="https://cache.ruby-lang.org/pub/ruby/${SLOT}/${MY_P}.tar.xz"
231 +
232 +LICENSE="|| ( Ruby-BSD BSD-2 )"
233 +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~mips ppc ppc64 ~riscv ~s390 sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
234 +IUSE="berkdb debug doc examples gdbm ipv6 jemalloc jit +rdoc rubytests socks5 +ssl static-libs systemtap tk xemacs"
235 +
236 +RDEPEND="
237 + berkdb? ( sys-libs/db:= )
238 + gdbm? ( sys-libs/gdbm:= )
239 + jemalloc? ( dev-libs/jemalloc:= )
240 + jit? ( || ( sys-devel/gcc:* sys-devel/clang:* ) )
241 + ssl? (
242 + dev-libs/openssl:0=
243 + )
244 + socks5? ( >=net-proxy/dante-1.1.13 )
245 + systemtap? ( dev-util/systemtap )
246 + tk? (
247 + dev-lang/tcl:0=[threads]
248 + dev-lang/tk:0=[threads]
249 + )
250 + dev-libs/libyaml
251 + dev-libs/libffi:=
252 + sys-libs/readline:0=
253 + sys-libs/zlib
254 + virtual/libcrypt:=
255 + >=app-eselect/eselect-ruby-20191222
256 +"
257 +
258 +DEPEND="${RDEPEND}"
259 +
260 +BUNDLED_GEMS="
261 + >=dev-ruby/minitest-5.13.0[ruby_targets_ruby27]
262 + >=dev-ruby/net-telnet-0.2.0[ruby_targets_ruby27]
263 + >=dev-ruby/power_assert-1.1.7[ruby_targets_ruby27]
264 + >=dev-ruby/rake-13.0.1[ruby_targets_ruby27]
265 + >=dev-ruby/test-unit-3.3.4[ruby_targets_ruby27]
266 + >=dev-ruby/xmlrpc-0.3.0[ruby_targets_ruby27]
267 +"
268 +
269 +PDEPEND="
270 + ${BUNDLED_GEMS}
271 + virtual/rubygems[ruby_targets_ruby27]
272 + >=dev-ruby/bundler-2.1.4[ruby_targets_ruby27]
273 + >=dev-ruby/did_you_mean-1.3.1[ruby_targets_ruby27]
274 + >=dev-ruby/json-2.0.2[ruby_targets_ruby27]
275 + rdoc? ( >=dev-ruby/rdoc-6.1.2[ruby_targets_ruby27] )
276 + xemacs? ( app-xemacs/ruby-modes )"
277 +
278 +src_prepare() {
279 + eapply "${FILESDIR}"/2.7/{001,003,010}*.patch
280 +
281 + if use elibc_musl ; then
282 + eapply "${FILESDIR}"/2.7/{900,901}-musl-*.patch
283 + fi
284 +
285 + # Reset time on patched gem_prelude.rb to avoid the need for a base
286 + # ruby during bootstrapping, bug 787137
287 + touch -t 202001010000 gem_prelude.rb || die
288 +
289 + einfo "Unbundling gems..."
290 + cd "$S"
291 + # Remove bundled gems that we will install via PDEPEND, bug
292 + # 539700.
293 + rm -fr gems/* || die
294 + # Don't install CLI tools since they will clash with the gem
295 + rm -f bin/{racc,racc2y,y2racc} || die
296 + sed -i -e '/executables/ s:^:#:' lib/racc/racc.gemspec || die
297 +
298 + einfo "Removing bundled libraries..."
299 + rm -fr ext/fiddle/libffi-3.2.1 || die
300 +
301 + if use prefix ; then
302 + # Fix hardcoded SHELL var in mkmf library
303 + sed -i -e "s#\(SHELL = \).*#\1${EPREFIX}/bin/sh#" lib/mkmf.rb || die
304 +
305 + if [[ ${CHOST} == *darwin* ]] ; then
306 + # avoid symlink loop on Darwin (?!)
307 + sed -i \
308 + -e '/LIBRUBY_ALIASES=/s/lib$(RUBY_INSTALL_NAME).$(SOEXT)//' \
309 + configure.ac || die
310 +
311 + # make ar/libtool hack for Darwin work
312 + sed -i \
313 + -e "s/ac_cv_prog_ac_ct_AR='libtool/ac_cv_prog_AR='${CHOST}-libtool/" \
314 + configure.ac || die
315 +
316 + # disable using security framework (GCC barfs on those headers)
317 + sed -i \
318 + -e 's/MAC_OS_X_VERSION_MIN_REQUIRED/_DISABLED_/' \
319 + random.c || die
320 + fi
321 + fi
322 +
323 + eapply_user
324 +
325 + eautoreconf
326 +}
327 +
328 +src_configure() {
329 + local modules= myconf=
330 +
331 + # -fomit-frame-pointer makes ruby segfault, see bug #150413.
332 + filter-flags -fomit-frame-pointer
333 + # In many places aliasing rules are broken; play it safe
334 + # as it's risky with newer compilers to leave it as it is.
335 + append-flags -fno-strict-aliasing
336 +
337 + # Socks support via dante
338 + if use socks5 ; then
339 + # Socks support can't be disabled as long as SOCKS_SERVER is
340 + # set and socks library is present, so need to unset
341 + # SOCKS_SERVER in that case.
342 + unset SOCKS_SERVER
343 + fi
344 +
345 + # Increase GC_MALLOC_LIMIT if set (default is 8000000)
346 + if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
347 + append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
348 + fi
349 +
350 + # ipv6 hack, bug 168939. Needs --enable-ipv6.
351 + use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
352 +
353 + # Determine which modules *not* to build depending in the USE flags.
354 + if ! use berkdb ; then
355 + modules="${modules},dbm"
356 + fi
357 + if ! use gdbm ; then
358 + modules="${modules},gdbm"
359 + fi
360 + if ! use ssl ; then
361 + modules="${modules},openssl"
362 + fi
363 + if ! use tk ; then
364 + modules="${modules},tk"
365 + fi
366 +
367 + # Provide an empty LIBPATHENV because we disable rpath but we do not
368 + # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
369 + # #564272
370 + INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
371 + --program-suffix=${MY_SUFFIX} \
372 + --with-soname=ruby${MY_SUFFIX} \
373 + --with-readline-dir="${EPREFIX}"/usr \
374 + --enable-shared \
375 + --enable-pthread \
376 + --disable-rpath \
377 + --with-out-ext="${modules}" \
378 + $(use_with jemalloc jemalloc) \
379 + $(use_enable jit jit-support ) \
380 + $(use_enable socks5 socks) \
381 + $(use_enable systemtap dtrace) \
382 + $(use_enable doc install-doc) \
383 + --enable-ipv6 \
384 + $(use_enable static-libs static) \
385 + $(use_enable static-libs install-static-library) \
386 + $(use_with static-libs static-linked-ext) \
387 + $(use_enable debug) \
388 + ${myconf} \
389 + --enable-option-checking=no
390 +
391 + # Makefile is broken because it lacks -ldl
392 + rm -rf ext/-test-/popen_deadlock || die
393 +}
394 +
395 +src_compile() {
396 + emake V=1 EXTLDFLAGS="${LDFLAGS}" MJIT_CFLAGS="${CFLAGS}" MJIT_OPTFLAGS="" MJIT_DEBUGFLAGS=""
397 +}
398 +
399 +src_test() {
400 + emake -j1 V=1 test
401 +
402 + elog "Ruby's make test has been run. Ruby also ships with a make check"
403 + elog "that cannot be run until after ruby has been installed."
404 + elog
405 + if use rubytests; then
406 + elog "You have enabled rubytests, so they will be installed to"
407 + elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
408 + elog "than root, and you must place them into a writeable directory."
409 + elog "Then call: "
410 + elog
411 + elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
412 + else
413 + elog "Enable the rubytests USE flag to install the make check tests"
414 + fi
415 +}
416 +
417 +src_install() {
418 + # Remove the remaining bundled gems. We do this late in the process
419 + # since they are used during the build to e.g. create the
420 + # documentation.
421 + einfo "Removing default gems before installation"
422 + rm -rf lib/bundler* lib/rdoc/rdoc.gemspec || die
423 +
424 + # Ruby is involved in the install process, we don't want interference here.
425 + unset RUBYOPT
426 +
427 + local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
428 +
429 + LD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
430 +
431 + if [[ ${CHOST} == *darwin* ]] ; then
432 + DYLD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${DYLD_LIBRARY_PATH+:}${DYLD_LIBRARY_PATH}"
433 + export DYLD_LIBRARY_PATH
434 + fi
435 +
436 + RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
437 + for d in $(find "${S}/ext" -type d) ; do
438 + RUBYLIB="${RUBYLIB}:$d"
439 + done
440 + export LD_LIBRARY_PATH RUBYLIB
441 +
442 + # Create directory for the default gems
443 + local gem_home="${EPREFIX}/usr/$(get_libdir)/ruby/gems/${RUBYVERSION}"
444 + mkdir -p "${D}/${gem_home}" || die "mkdir gem home failed"
445 +
446 + emake V=1 DESTDIR="${D}" GEM_DESTDIR=${gem_home} install
447 +
448 + # Remove installed rubygems and rdoc copy
449 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
450 + rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
451 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
452 + rm -rf "${ED}/usr/bin/"{bundle,bundler,ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
453 +
454 + if use doc; then
455 + emake DESTDIR="${D}" GEM_DESTDIR=${gem_home} install-doc
456 + fi
457 +
458 + if use examples; then
459 + dodoc -r sample
460 + fi
461 +
462 + dodoc ChangeLog NEWS doc/NEWS* README*
463 +
464 + if use rubytests; then
465 + pushd test
466 + insinto /usr/share/${PN}-${SLOT}/test
467 + doins -r .
468 + popd
469 + fi
470 +}
471 +
472 +pkg_postinst() {
473 + if [[ ! -n $(readlink "${EROOT}"/usr/bin/ruby) ]] ; then
474 + eselect ruby set ruby${MY_SUFFIX}
475 + fi
476 +
477 + elog
478 + elog "To switch between available Ruby profiles, execute as root:"
479 + elog "\teselect ruby set ruby(23|24|...)"
480 + elog
481 +}
482 +
483 +pkg_postrm() {
484 + eselect ruby cleanup
485 +}