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/, dev-lang/ruby/files/2.4/
Date: Wed, 12 Dec 2018 07:55:09
Message-Id: 1544601290.5b27f93e5092dfe11d47c4055a0e7bc35c238b4b.graaff@gentoo
1 commit: 5b27f93e5092dfe11d47c4055a0e7bc35c238b4b
2 Author: Craig Andrews <candrews <AT> gentoo <DOT> org>
3 AuthorDate: Mon Dec 10 17:29:31 2018 +0000
4 Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org>
5 CommitDate: Wed Dec 12 07:54:50 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5b27f93e
7
8 dev-lang/ruby: 2.4.5-r1 for OpenSSL 1.1 "disable-deprecated"
9
10 Closes: https://bugs.gentoo.org/614760
11 Package-Manager: Portage-2.3.52, Repoman-2.3.12
12 Signed-off-by: Craig Andrews <candrews <AT> gentoo.org>
13 Signed-off-by: Hans de Graaff <graaff <AT> gentoo.org>
14
15 dev-lang/ruby/files/2.4/012-openssl_1.1.patch | 339 ++++++++++++++++++++++++++
16 dev-lang/ruby/ruby-2.4.5-r1.ebuild | 229 +++++++++++++++++
17 2 files changed, 568 insertions(+)
18
19 diff --git a/dev-lang/ruby/files/2.4/012-openssl_1.1.patch b/dev-lang/ruby/files/2.4/012-openssl_1.1.patch
20 new file mode 100644
21 index 00000000000..edf344bedc8
22 --- /dev/null
23 +++ b/dev-lang/ruby/files/2.4/012-openssl_1.1.patch
24 @@ -0,0 +1,339 @@
25 +From 7af808153dd34a980e027a04d4490ae38019b3ed Mon Sep 17 00:00:00 2001
26 +From: Mark Wright <gienah@g.o>
27 +Date: Sun, 15 Oct 2017 01:24:12 +1100
28 +Subject: [PATCH] Fix build failure against OpenSSL 1.1 built with
29 + no-deprecated Thanks rhenium for the code review and fixes.
30 +
31 +---
32 + ext/openssl/openssl_missing.h | 4 +++
33 + ext/openssl/ossl.c | 23 ++++++---------
34 + ext/openssl/ossl.h | 5 ++++
35 + ext/openssl/ossl_cipher.c | 14 ++++-----
36 + ext/openssl/ossl_engine.c | 54 ++++++++++++++++++++++-------------
37 + ext/openssl/ossl_ssl.c | 2 +-
38 + ext/openssl/ossl_x509cert.c | 4 +--
39 + ext/openssl/ossl_x509crl.c | 4 +--
40 + 8 files changed, 63 insertions(+), 47 deletions(-)
41 +
42 +diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h
43 +index cc31f6ac..debd25ad 100644
44 +--- a/ext/openssl/openssl_missing.h
45 ++++ b/ext/openssl/openssl_missing.h
46 +@@ -209,6 +209,10 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
47 + # define X509_get0_notAfter(x) X509_get_notAfter(x)
48 + # define X509_CRL_get0_lastUpdate(x) X509_CRL_get_lastUpdate(x)
49 + # define X509_CRL_get0_nextUpdate(x) X509_CRL_get_nextUpdate(x)
50 ++# define X509_set1_notBefore(x, t) X509_set_notBefore(x, t)
51 ++# define X509_set1_notAfter(x, t) X509_set_notAfter(x, t)
52 ++# define X509_CRL_set1_lastUpdate(x, t) X509_CRL_set_lastUpdate(x, t)
53 ++# define X509_CRL_set1_nextUpdate(x, t) X509_CRL_set_nextUpdate(x, t)
54 + #endif
55 +
56 + #if !defined(HAVE_SSL_SESSION_GET_PROTOCOL_VERSION)
57 +diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
58 +index 93ecc7d4..245385e7 100644
59 +--- a/ext/openssl/ossl.c
60 ++++ b/ext/openssl/ossl.c
61 +@@ -1109,25 +1109,14 @@ Init_openssl(void)
62 + /*
63 + * Init all digests, ciphers
64 + */
65 +- /* CRYPTO_malloc_init(); */
66 +- /* ENGINE_load_builtin_engines(); */
67 ++#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
68 ++ if (!OPENSSL_init_ssl(0, NULL))
69 ++ rb_raise(rb_eRuntimeError, "OPENSSL_init_ssl");
70 ++#else
71 + OpenSSL_add_ssl_algorithms();
72 + OpenSSL_add_all_algorithms();
73 + ERR_load_crypto_strings();
74 + SSL_load_error_strings();
75 +-
76 +- /*
77 +- * FIXME:
78 +- * On unload do:
79 +- */
80 +-#if 0
81 +- CONF_modules_unload(1);
82 +- destroy_ui_method();
83 +- EVP_cleanup();
84 +- ENGINE_cleanup();
85 +- CRYPTO_cleanup_all_ex_data();
86 +- ERR_remove_state(0);
87 +- ERR_free_strings();
88 + #endif
89 +
90 + /*
91 +@@ -1149,7 +1138,11 @@ Init_openssl(void)
92 + /*
93 + * Version of OpenSSL the ruby OpenSSL extension is running with
94 + */
95 ++#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
96 ++ rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
97 ++#else
98 + rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
99 ++#endif
100 +
101 + /*
102 + * Version number of OpenSSL the ruby OpenSSL extension was built with
103 +diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
104 +index f08889b2..5a15839c 100644
105 +--- a/ext/openssl/ossl.h
106 ++++ b/ext/openssl/ossl.h
107 +@@ -35,6 +35,11 @@
108 + #if !defined(OPENSSL_NO_OCSP)
109 + # include <openssl/ocsp.h>
110 + #endif
111 ++#include <openssl/bn.h>
112 ++#include <openssl/rsa.h>
113 ++#include <openssl/dsa.h>
114 ++#include <openssl/evp.h>
115 ++#include <openssl/dh.h>
116 +
117 + /*
118 + * Common Module
119 +diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
120 +index bfa76c1a..e6179733 100644
121 +--- a/ext/openssl/ossl_cipher.c
122 ++++ b/ext/openssl/ossl_cipher.c
123 +@@ -508,9 +508,9 @@ ossl_cipher_set_iv(VALUE self, VALUE iv)
124 + StringValue(iv);
125 + GetCipher(self, ctx);
126 +
127 + #if defined(HAVE_AUTHENTICATED_ENCRYPTION)
128 +- if (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)
129 ++ if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)
130 + iv_len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
131 + #endif
132 + if (!iv_len)
133 + iv_len = EVP_CIPHER_CTX_iv_length(ctx);
134 +@@ -535,7 +535,7 @@ ossl_cipher_is_authenticated(VALUE self)
135 +
136 + GetCipher(self, ctx);
137 +
138 + #if defined(HAVE_AUTHENTICATED_ENCRYPTION)
139 +- return (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER) ? Qtrue : Qfalse;
140 ++ return (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER) ? Qtrue : Qfalse;
141 + #else
142 + return Qfalse;
143 + #endif
144 +@@ -606,7 +606,7 @@ ossl_cipher_get_auth_tag(int argc, VALUE *argv, VALUE self)
145 +
146 + GetCipher(self, ctx);
147 +
148 +- if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER))
149 ++ if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
150 + ossl_raise(eCipherError, "authentication tag not supported by this cipher");
151 +
152 + ret = rb_str_new(NULL, tag_len);
153 +@@ -641,7 +641,7 @@ ossl_cipher_set_auth_tag(VALUE self, VALUE vtag)
154 + tag_len = RSTRING_LENINT(vtag);
155 +
156 + GetCipher(self, ctx);
157 +- if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER))
158 ++ if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
159 + ossl_raise(eCipherError, "authentication tag not supported by this cipher");
160 +
161 + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, tag))
162 +@@ -668,7 +668,7 @@ ossl_cipher_set_auth_tag_len(VALUE self, VALUE vlen)
163 + EVP_CIPHER_CTX *ctx;
164 +
165 + GetCipher(self, ctx);
166 +- if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER))
167 ++ if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
168 + ossl_raise(eCipherError, "AEAD not supported by this cipher");
169 +
170 + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag_len, NULL))
171 +@@ -695,7 +695,7 @@ ossl_cipher_set_iv_length(VALUE self, VALUE iv_length)
172 + EVP_CIPHER_CTX *ctx;
173 +
174 + GetCipher(self, ctx);
175 +- if (!(EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER))
176 ++ if (!(EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER))
177 + ossl_raise(eCipherError, "cipher does not support AEAD");
178 +
179 + if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, len, NULL))
180 +@@ -786,9 +786,9 @@ ossl_cipher_iv_length(VALUE self)
181 + int len = 0;
182 +
183 + GetCipher(self, ctx);
184 + #if defined(HAVE_AUTHENTICATED_ENCRYPTION)
185 +- if (EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_FLAG_AEAD_CIPHER)
186 ++ if (EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(ctx)) & EVP_CIPH_FLAG_AEAD_CIPHER)
187 + len = (int)(VALUE)EVP_CIPHER_CTX_get_app_data(ctx);
188 + #endif
189 + if (!len)
190 + len = EVP_CIPHER_CTX_iv_length(ctx);
191 +diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
192 +index d69b5dca..5ca0d4ca 100644
193 +--- a/ext/openssl/ossl_engine.c
194 ++++ b/ext/openssl/ossl_engine.c
195 +@@ -46,13 +46,25 @@ VALUE eEngineError;
196 + /*
197 + * Private
198 + */
199 +-#define OSSL_ENGINE_LOAD_IF_MATCH(x) \
200 ++#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
201 ++#define OSSL_ENGINE_LOAD_IF_MATCH(engine_name, x) \
202 + do{\
203 +- if(!strcmp(#x, RSTRING_PTR(name))){\
204 +- ENGINE_load_##x();\
205 ++ if(!strcmp(#engine_name, RSTRING_PTR(name))){\
206 ++ if (OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_##x, NULL))\
207 ++ return Qtrue;\
208 ++ else\
209 ++ ossl_raise(eEngineError, "OPENSSL_init_crypto"); \
210 ++ }\
211 ++}while(0)
212 ++#else
213 ++#define OSSL_ENGINE_LOAD_IF_MATCH(engine_name, x) \
214 ++do{\
215 ++ if(!strcmp(#engine_name, RSTRING_PTR(name))){\
216 ++ ENGINE_load_##engine_name();\
217 + return Qtrue;\
218 + }\
219 + }while(0)
220 ++#endif
221 +
222 + static void
223 + ossl_engine_free(void *engine)
224 +@@ -94,55 +106,55 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
225 + StringValueCStr(name);
226 + #ifndef OPENSSL_NO_STATIC_ENGINE
227 + #if HAVE_ENGINE_LOAD_DYNAMIC
228 +- OSSL_ENGINE_LOAD_IF_MATCH(dynamic);
229 ++ OSSL_ENGINE_LOAD_IF_MATCH(dynamic, DYNAMIC);
230 + #endif
231 + #if HAVE_ENGINE_LOAD_4758CCA
232 +- OSSL_ENGINE_LOAD_IF_MATCH(4758cca);
233 ++ OSSL_ENGINE_LOAD_IF_MATCH(4758cca, 4758CCA);
234 + #endif
235 + #if HAVE_ENGINE_LOAD_AEP
236 +- OSSL_ENGINE_LOAD_IF_MATCH(aep);
237 ++ OSSL_ENGINE_LOAD_IF_MATCH(aep, AEP);
238 + #endif
239 + #if HAVE_ENGINE_LOAD_ATALLA
240 +- OSSL_ENGINE_LOAD_IF_MATCH(atalla);
241 ++ OSSL_ENGINE_LOAD_IF_MATCH(atalla, ATALLA);
242 + #endif
243 + #if HAVE_ENGINE_LOAD_CHIL
244 +- OSSL_ENGINE_LOAD_IF_MATCH(chil);
245 ++ OSSL_ENGINE_LOAD_IF_MATCH(chil, CHIL);
246 + #endif
247 + #if HAVE_ENGINE_LOAD_CSWIFT
248 +- OSSL_ENGINE_LOAD_IF_MATCH(cswift);
249 ++ OSSL_ENGINE_LOAD_IF_MATCH(cswift, CSWIFT);
250 + #endif
251 + #if HAVE_ENGINE_LOAD_NURON
252 +- OSSL_ENGINE_LOAD_IF_MATCH(nuron);
253 ++ OSSL_ENGINE_LOAD_IF_MATCH(nuron, NURON);
254 + #endif
255 + #if HAVE_ENGINE_LOAD_SUREWARE
256 +- OSSL_ENGINE_LOAD_IF_MATCH(sureware);
257 ++ OSSL_ENGINE_LOAD_IF_MATCH(sureware, SUREWARE);
258 + #endif
259 + #if HAVE_ENGINE_LOAD_UBSEC
260 +- OSSL_ENGINE_LOAD_IF_MATCH(ubsec);
261 ++ OSSL_ENGINE_LOAD_IF_MATCH(ubsec, UBSEC);
262 + #endif
263 + #if HAVE_ENGINE_LOAD_PADLOCK
264 +- OSSL_ENGINE_LOAD_IF_MATCH(padlock);
265 ++ OSSL_ENGINE_LOAD_IF_MATCH(padlock, PADLOCK);
266 + #endif
267 + #if HAVE_ENGINE_LOAD_CAPI
268 +- OSSL_ENGINE_LOAD_IF_MATCH(capi);
269 ++ OSSL_ENGINE_LOAD_IF_MATCH(capi, CAPI);
270 + #endif
271 + #if HAVE_ENGINE_LOAD_GMP
272 +- OSSL_ENGINE_LOAD_IF_MATCH(gmp);
273 ++ OSSL_ENGINE_LOAD_IF_MATCH(gmp, GMP);
274 + #endif
275 + #if HAVE_ENGINE_LOAD_GOST
276 +- OSSL_ENGINE_LOAD_IF_MATCH(gost);
277 ++ OSSL_ENGINE_LOAD_IF_MATCH(gost, GOST);
278 + #endif
279 + #if HAVE_ENGINE_LOAD_CRYPTODEV
280 +- OSSL_ENGINE_LOAD_IF_MATCH(cryptodev);
281 ++ OSSL_ENGINE_LOAD_IF_MATCH(cryptodev, CRYPTODEV);
282 + #endif
283 + #if HAVE_ENGINE_LOAD_AESNI
284 +- OSSL_ENGINE_LOAD_IF_MATCH(aesni);
285 ++ OSSL_ENGINE_LOAD_IF_MATCH(aesni, AESNI);
286 + #endif
287 + #endif
288 + #ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO
289 +- OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto);
290 ++ OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto, OPENBSD_DEV_CRYPTO);
291 + #endif
292 +- OSSL_ENGINE_LOAD_IF_MATCH(openssl);
293 ++ OSSL_ENGINE_LOAD_IF_MATCH(openssl, OPENSSL);
294 + rb_warning("no such builtin loader for `%"PRIsVALUE"'", name);
295 + return Qnil;
296 + #endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
297 +@@ -160,7 +172,9 @@ ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
298 + static VALUE
299 + ossl_engine_s_cleanup(VALUE self)
300 + {
301 ++#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000
302 + ENGINE_cleanup();
303 ++#endif
304 + return Qnil;
305 + }
306 +
307 +diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
308 +index 8e3c0c42..d32a299c 100644
309 +--- a/ext/openssl/ossl_ssl.c
310 ++++ b/ext/openssl/ossl_ssl.c
311 +@@ -379,7 +379,7 @@ ossl_call_session_get_cb(VALUE ary)
312 +
313 + /* this method is currently only called for servers (in OpenSSL <= 0.9.8e) */
314 + static SSL_SESSION *
315 +-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
316 ++#if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
317 + ossl_sslctx_session_get_cb(SSL *ssl, const unsigned char *buf, int len, int *copy)
318 + #else
319 + ossl_sslctx_session_get_cb(SSL *ssl, unsigned char *buf, int len, int *copy)
320 +diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
321 +index cf82a53d..8d16b9b7 100644
322 +--- a/ext/openssl/ossl_x509cert.c
323 ++++ b/ext/openssl/ossl_x509cert.c
324 +@@ -440,7 +440,7 @@ ossl_x509_set_not_before(VALUE self, VALUE time)
325 +
326 + GetX509(self, x509);
327 + asn1time = ossl_x509_time_adjust(NULL, time);
328 +- if (!X509_set_notBefore(x509, asn1time)) {
329 ++ if (!X509_set1_notBefore(x509, asn1time)) {
330 + ASN1_TIME_free(asn1time);
331 + ossl_raise(eX509CertError, "X509_set_notBefore");
332 + }
333 +@@ -479,7 +479,7 @@ ossl_x509_set_not_after(VALUE self, VALUE time)
334 +
335 + GetX509(self, x509);
336 + asn1time = ossl_x509_time_adjust(NULL, time);
337 +- if (!X509_set_notAfter(x509, asn1time)) {
338 ++ if (!X509_set1_notAfter(x509, asn1time)) {
339 + ASN1_TIME_free(asn1time);
340 + ossl_raise(eX509CertError, "X509_set_notAfter");
341 + }
342 +diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c
343 +index 5ecd7ea0..45cf7fb4 100644
344 +--- a/ext/openssl/ossl_x509crl.c
345 ++++ b/ext/openssl/ossl_x509crl.c
346 +@@ -226,7 +226,7 @@ ossl_x509crl_set_last_update(VALUE self, VALUE time)
347 +
348 + GetX509CRL(self, crl);
349 + asn1time = ossl_x509_time_adjust(NULL, time);
350 +- if (!X509_CRL_set_lastUpdate(crl, asn1time)) {
351 ++ if (!X509_CRL_set1_lastUpdate(crl, asn1time)) {
352 + ASN1_TIME_free(asn1time);
353 + ossl_raise(eX509CRLError, "X509_CRL_set_lastUpdate");
354 + }
355 +@@ -257,7 +257,7 @@ ossl_x509crl_set_next_update(VALUE self, VALUE time)
356 +
357 + GetX509CRL(self, crl);
358 + asn1time = ossl_x509_time_adjust(NULL, time);
359 +- if (!X509_CRL_set_nextUpdate(crl, asn1time)) {
360 ++ if (!X509_CRL_set1_nextUpdate(crl, asn1time)) {
361 + ASN1_TIME_free(asn1time);
362 + ossl_raise(eX509CRLError, "X509_CRL_set_nextUpdate");
363 + }
364
365 diff --git a/dev-lang/ruby/ruby-2.4.5-r1.ebuild b/dev-lang/ruby/ruby-2.4.5-r1.ebuild
366 new file mode 100644
367 index 00000000000..9213e9e6408
368 --- /dev/null
369 +++ b/dev-lang/ruby/ruby-2.4.5-r1.ebuild
370 @@ -0,0 +1,229 @@
371 +# Copyright 1999-2018 Gentoo Authors
372 +# Distributed under the terms of the GNU General Public License v2
373 +
374 +EAPI=7
375 +
376 +inherit autotools flag-o-matic multilib
377 +
378 +MY_P="${PN}-$(ver_cut 1-3)"
379 +S=${WORKDIR}/${MY_P}
380 +
381 +SLOT=$(ver_cut 1-2)
382 +MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
383 +RUBYVERSION=${SLOT}.0
384 +
385 +DESCRIPTION="An object-oriented scripting language"
386 +HOMEPAGE="https://www.ruby-lang.org/"
387 +SRC_URI="mirror://ruby/${SLOT}/${MY_P}.tar.xz"
388 +
389 +LICENSE="|| ( Ruby-BSD BSD-2 )"
390 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd"
391 +IUSE="berkdb debug doc examples gdbm ipv6 jemalloc libressl +rdoc rubytests socks5 ssl static-libs tk xemacs"
392 +
393 +RDEPEND="
394 + berkdb? ( sys-libs/db:= )
395 + gdbm? ( sys-libs/gdbm:= )
396 + jemalloc? ( dev-libs/jemalloc )
397 + ssl? (
398 + !libressl? ( dev-libs/openssl:0= )
399 + libressl? ( dev-libs/libressl )
400 + )
401 + socks5? ( >=net-proxy/dante-1.1.13 )
402 + tk? (
403 + dev-lang/tcl:0=[threads]
404 + dev-lang/tk:0=[threads]
405 + )
406 + dev-libs/libyaml
407 + virtual/libffi:=
408 + sys-libs/zlib
409 + >=app-eselect/eselect-ruby-20161226
410 + !<dev-ruby/rdoc-3.9.4
411 + !<dev-ruby/rubygems-1.8.10-r1"
412 +
413 +DEPEND="${RDEPEND}"
414 +
415 +BUNDLED_GEMS="
416 + >=dev-ruby/did_you_mean-1.1.0:2.4[ruby_targets_ruby24]
417 + >=dev-ruby/minitest-5.10.1[ruby_targets_ruby24]
418 + >=dev-ruby/net-telnet-0.1.1[ruby_targets_ruby24]
419 + >=dev-ruby/power_assert-0.4.1[ruby_targets_ruby24]
420 + >=dev-ruby/rake-12.0.0[ruby_targets_ruby24]
421 + >=dev-ruby/test-unit-3.2.3[ruby_targets_ruby24]
422 + >=dev-ruby/xmlrpc-0.2.1[ruby_targets_ruby24]
423 +"
424 +
425 +PDEPEND="
426 + ${BUNDLED_GEMS}
427 + virtual/rubygems[ruby_targets_ruby24]
428 + >=dev-ruby/json-2.0.2[ruby_targets_ruby24]
429 + rdoc? ( >=dev-ruby/rdoc-5.1.0[ruby_targets_ruby24] )
430 + xemacs? ( app-xemacs/ruby-modes )"
431 +
432 +src_prepare() {
433 + eapply "${FILESDIR}"/${SLOT}/{002,005,009,012}*.patch
434 +
435 + einfo "Unbundling gems..."
436 + cd "$S"
437 + # Remove bundled gems that we will install via PDEPEND, bug
438 + # 539700. Use explicit version numbers to ensure rm fails when they
439 + # change so we can update dependencies accordingly.
440 + rm -f gems/{did_you_mean-1.1.0,minitest-5.10.1,net-telnet-0.1.1,power_assert-0.4.1,rake-12.0.0,test-unit-3.2.3,xmlrpc-0.2.1}.gem || die
441 +
442 + einfo "Removing bundled libraries..."
443 + rm -fr ext/fiddle/libffi-3.2.1 || die
444 +
445 + # Fix a hardcoded lib path in configure script
446 + sed -i -e "s:\(RUBY_LIB_PREFIX=\"\${prefix}/\)lib:\1$(get_libdir):" \
447 + configure.in || die "sed failed"
448 +
449 + eapply_user
450 +
451 + eautoreconf
452 +}
453 +
454 +src_configure() {
455 + local modules= myconf=
456 +
457 + # -fomit-frame-pointer makes ruby segfault, see bug #150413.
458 + filter-flags -fomit-frame-pointer
459 + # In many places aliasing rules are broken; play it safe
460 + # as it's risky with newer compilers to leave it as it is.
461 + append-flags -fno-strict-aliasing
462 + # SuperH needs this
463 + use sh && append-flags -mieee
464 +
465 + # Socks support via dante
466 + if use socks5 ; then
467 + # Socks support can't be disabled as long as SOCKS_SERVER is
468 + # set and socks library is present, so need to unset
469 + # SOCKS_SERVER in that case.
470 + unset SOCKS_SERVER
471 + fi
472 +
473 + # Increase GC_MALLOC_LIMIT if set (default is 8000000)
474 + if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
475 + append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
476 + fi
477 +
478 + # ipv6 hack, bug 168939. Needs --enable-ipv6.
479 + use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
480 +
481 + # Determine which modules *not* to build depending in the USE flags.
482 + if ! use berkdb ; then
483 + modules="${modules},dbm"
484 + fi
485 + if ! use gdbm ; then
486 + modules="${modules},gdbm"
487 + fi
488 + if ! use ssl ; then
489 + modules="${modules},openssl"
490 + fi
491 + if ! use tk ; then
492 + modules="${modules},tk"
493 + fi
494 +
495 + # Provide an empty LIBPATHENV because we disable rpath but we do not
496 + # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
497 + # #564272
498 + INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
499 + --program-suffix=${MY_SUFFIX} \
500 + --with-soname=ruby${MY_SUFFIX} \
501 + --docdir=${EPREFIX}/usr/share/doc/${P} \
502 + --enable-shared \
503 + --enable-pthread \
504 + --disable-rpath \
505 + --with-out-ext="${modules}" \
506 + $(use_with jemalloc jemalloc) \
507 + $(use_enable socks5 socks) \
508 + $(use_enable doc install-doc) \
509 + --enable-ipv6 \
510 + $(use_enable static-libs static) \
511 + $(use_enable static-libs install-static-library) \
512 + $(use_with static-libs static-linked-ext) \
513 + $(use_enable debug) \
514 + ${myconf} \
515 + --enable-option-checking=no \
516 + || die "econf failed"
517 +}
518 +
519 +src_compile() {
520 + emake V=1 EXTLDFLAGS="${LDFLAGS}" || die "emake failed"
521 +}
522 +
523 +src_test() {
524 + emake -j1 V=1 test || die "make test failed"
525 +
526 + elog "Ruby's make test has been run. Ruby also ships with a make check"
527 + elog "that cannot be run until after ruby has been installed."
528 + elog
529 + if use rubytests; then
530 + elog "You have enabled rubytests, so they will be installed to"
531 + elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
532 + elog "than root, and you must place them into a writeable directory."
533 + elog "Then call: "
534 + elog
535 + elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
536 + else
537 + elog "Enable the rubytests USE flag to install the make check tests"
538 + fi
539 +}
540 +
541 +src_install() {
542 + # Remove the remaining bundled gems. We do this late in the process
543 + # since they are used during the build to e.g. create the
544 + # documentation.
545 + rm -rf ext/json || die
546 +
547 + # Ruby is involved in the install process, we don't want interference here.
548 + unset RUBYOPT
549 +
550 + local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
551 +
552 + LD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
553 + RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
554 + for d in $(find "${S}/ext" -type d) ; do
555 + RUBYLIB="${RUBYLIB}:$d"
556 + done
557 + export LD_LIBRARY_PATH RUBYLIB
558 +
559 + emake V=1 DESTDIR="${D}" install || die "make install failed"
560 +
561 + # Remove installed rubygems and rdoc copy
562 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
563 + rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
564 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
565 + rm -rf "${ED}/usr/bin/"{ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
566 +
567 + if use doc; then
568 + make DESTDIR="${D}" install-doc || die "make install-doc failed"
569 + fi
570 +
571 + if use examples; then
572 + insinto /usr/share/doc/${PF}
573 + doins -r sample
574 + fi
575 +
576 + dodoc ChangeLog NEWS doc/NEWS* README* || die
577 +
578 + if use rubytests; then
579 + pushd test
580 + insinto /usr/share/${PN}-${SLOT}/test
581 + doins -r .
582 + popd
583 + fi
584 +}
585 +
586 +pkg_postinst() {
587 + if [[ ! -n $(readlink "${EROOT}"usr/bin/ruby) ]] ; then
588 + eselect ruby set ruby${MY_SUFFIX}
589 + fi
590 +
591 + elog
592 + elog "To switch between available Ruby profiles, execute as root:"
593 + elog "\teselect ruby set ruby(23|24|...)"
594 + elog
595 +}
596 +
597 +pkg_postrm() {
598 + eselect ruby cleanup
599 +}