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.7/
Date: Wed, 28 Apr 2021 17:26:10
Message-Id: 1619630763.f6aa0fc2dcee195658e697026e607dbb91bfd31d.graaff@gentoo
1 commit: f6aa0fc2dcee195658e697026e607dbb91bfd31d
2 Author: Hans de Graaff <graaff <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 28 17:25:42 2021 +0000
4 Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 28 17:26:03 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f6aa0fc2
7
8 dev-lang/ruby: backport ruby 3.0 gem_prelude.rb
9
10 The ruby26 and ruby30 gem_prelude.rb fails gracefully when the
11 did_you_mean gem cannot be loaded. Backport the ruby30 version since it
12 is more modular. This helps with cases where the did_you_mean gem is not
13 yet installed as part of a fresh ruby install.
14
15 Bug: https://bugs.gentoo.org/705346
16 Package-Manager: Portage-3.0.18, Repoman-3.0.2
17 Signed-off-by: Hans de Graaff <graaff <AT> gentoo.org>
18
19 dev-lang/ruby/files/2.7/003-did-you-mean.patch | 16 ++
20 dev-lang/ruby/ruby-2.7.3-r1.ebuild | 263 +++++++++++++++++++++++++
21 2 files changed, 279 insertions(+)
22
23 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
24 new file mode 100644
25 index 00000000000..26beb65a488
26 --- /dev/null
27 +++ b/dev-lang/ruby/files/2.7/003-did-you-mean.patch
28 @@ -0,0 +1,16 @@
29 +--- ruby27/gem_prelude.rb 2021-04-28 19:07:46.875571113 +0200
30 ++++ ruby30/gem_prelude.rb 2021-04-28 19:07:35.971511765 +0200
31 +@@ -1,2 +1,11 @@
32 +-require 'rubygems.rb' if defined?(Gem)
33 +-require 'did_you_mean' if defined?(DidYouMean)
34 ++begin
35 ++ require 'rubygems'
36 ++rescue LoadError
37 ++ warn "`RubyGems' were not loaded."
38 ++end if defined?(Gem)
39 ++
40 ++begin
41 ++ require 'did_you_mean'
42 ++rescue LoadError
43 ++ warn "`did_you_mean' was not loaded."
44 ++end if defined?(DidYouMean)
45
46 diff --git a/dev-lang/ruby/ruby-2.7.3-r1.ebuild b/dev-lang/ruby/ruby-2.7.3-r1.ebuild
47 new file mode 100644
48 index 00000000000..682230b1d99
49 --- /dev/null
50 +++ b/dev-lang/ruby/ruby-2.7.3-r1.ebuild
51 @@ -0,0 +1,263 @@
52 +# Copyright 1999-2021 Gentoo Authors
53 +# Distributed under the terms of the GNU General Public License v2
54 +
55 +EAPI=7
56 +
57 +inherit autotools flag-o-matic multilib
58 +
59 +MY_P="${PN}-$(ver_cut 1-3)"
60 +S=${WORKDIR}/${MY_P}
61 +
62 +SLOT=$(ver_cut 1-2)
63 +MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
64 +RUBYVERSION=${SLOT}.0
65 +
66 +DESCRIPTION="An object-oriented scripting language"
67 +HOMEPAGE="https://www.ruby-lang.org/"
68 +SRC_URI="https://cache.ruby-lang.org/pub/ruby/${SLOT}/${MY_P}.tar.xz"
69 +
70 +LICENSE="|| ( Ruby-BSD BSD-2 )"
71 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
72 +IUSE="berkdb debug doc examples gdbm ipv6 jemalloc jit libressl +rdoc rubytests socks5 +ssl static-libs systemtap tk xemacs"
73 +
74 +RDEPEND="
75 + berkdb? ( sys-libs/db:= )
76 + gdbm? ( sys-libs/gdbm:= )
77 + jemalloc? ( dev-libs/jemalloc )
78 + jit? ( || ( sys-devel/gcc:* sys-devel/clang:* ) )
79 + ssl? (
80 + !libressl? ( dev-libs/openssl:0= )
81 + libressl? ( dev-libs/libressl )
82 + )
83 + socks5? ( >=net-proxy/dante-1.1.13 )
84 + systemtap? ( dev-util/systemtap )
85 + tk? (
86 + dev-lang/tcl:0=[threads]
87 + dev-lang/tk:0=[threads]
88 + )
89 + dev-libs/libyaml
90 + dev-libs/libffi:=
91 + sys-libs/readline:0=
92 + sys-libs/zlib
93 + >=app-eselect/eselect-ruby-20191222
94 +"
95 +
96 +DEPEND="${RDEPEND}"
97 +
98 +BUNDLED_GEMS="
99 + >=dev-ruby/minitest-5.13.0[ruby_targets_ruby27]
100 + >=dev-ruby/net-telnet-0.2.0[ruby_targets_ruby27]
101 + >=dev-ruby/power_assert-1.1.7[ruby_targets_ruby27]
102 + >=dev-ruby/rake-13.0.1[ruby_targets_ruby27]
103 + >=dev-ruby/test-unit-3.3.4[ruby_targets_ruby27]
104 + >=dev-ruby/xmlrpc-0.3.0[ruby_targets_ruby27]
105 +"
106 +
107 +PDEPEND="
108 + ${BUNDLED_GEMS}
109 + virtual/rubygems[ruby_targets_ruby27]
110 + >=dev-ruby/bundler-2.1.4[ruby_targets_ruby27]
111 + >=dev-ruby/did_you_mean-1.3.1[ruby_targets_ruby27]
112 + >=dev-ruby/json-2.0.2[ruby_targets_ruby27]
113 + rdoc? ( >=dev-ruby/rdoc-6.1.2[ruby_targets_ruby27] )
114 + xemacs? ( app-xemacs/ruby-modes )"
115 +
116 +src_prepare() {
117 + # 005 does not compile bigdecimal and is questionable because it
118 + # compiles ruby in a non-standard way, may be dropped
119 + eapply "${FILESDIR}"/2.7/{002,003,010}*.patch
120 +
121 + einfo "Unbundling gems..."
122 + cd "$S"
123 + # Remove bundled gems that we will install via PDEPEND, bug
124 + # 539700.
125 + rm -fr gems/* || die
126 + # Don't install CLI tools since they will clash with the gem
127 + rm -f bin/{racc,racc2y,y2racc} || die
128 + sed -i -e '/executables/ s:^:#:' lib/racc/racc.gemspec || die
129 +
130 + einfo "Removing bundled libraries..."
131 + rm -fr ext/fiddle/libffi-3.2.1 || die
132 +
133 + if use prefix ; then
134 + # Fix hardcoded SHELL var in mkmf library
135 + sed -i -e "s#\(SHELL = \).*#\1${EPREFIX}/bin/sh#" lib/mkmf.rb || die
136 +
137 + if [[ ${CHOST} == *darwin* ]] ; then
138 + # avoid symlink loop on Darwin (?!)
139 + sed -i \
140 + -e '/LIBRUBY_ALIASES=/s/lib$(RUBY_INSTALL_NAME).$(SOEXT)//' \
141 + configure.ac || die
142 +
143 + # make ar/libtool hack for Darwin work
144 + sed -i \
145 + -e "s/ac_cv_prog_ac_ct_AR='libtool/ac_cv_prog_AR='${CHOST}-libtool/" \
146 + configure.ac || die
147 + fi
148 + fi
149 +
150 + eapply_user
151 +
152 + eautoreconf
153 +}
154 +
155 +src_configure() {
156 + local modules= myconf=
157 +
158 + # -fomit-frame-pointer makes ruby segfault, see bug #150413.
159 + filter-flags -fomit-frame-pointer
160 + # In many places aliasing rules are broken; play it safe
161 + # as it's risky with newer compilers to leave it as it is.
162 + append-flags -fno-strict-aliasing
163 +
164 + # Socks support via dante
165 + if use socks5 ; then
166 + # Socks support can't be disabled as long as SOCKS_SERVER is
167 + # set and socks library is present, so need to unset
168 + # SOCKS_SERVER in that case.
169 + unset SOCKS_SERVER
170 + fi
171 +
172 + # Increase GC_MALLOC_LIMIT if set (default is 8000000)
173 + if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
174 + append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
175 + fi
176 +
177 + # ipv6 hack, bug 168939. Needs --enable-ipv6.
178 + use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
179 +
180 + # Determine which modules *not* to build depending in the USE flags.
181 + if ! use berkdb ; then
182 + modules="${modules},dbm"
183 + fi
184 + if ! use gdbm ; then
185 + modules="${modules},gdbm"
186 + fi
187 + if ! use ssl ; then
188 + modules="${modules},openssl"
189 + fi
190 + if ! use tk ; then
191 + modules="${modules},tk"
192 + fi
193 +
194 + # Provide an empty LIBPATHENV because we disable rpath but we do not
195 + # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
196 + # #564272
197 + INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
198 + --program-suffix=${MY_SUFFIX} \
199 + --with-soname=ruby${MY_SUFFIX} \
200 + --with-readline-dir="${EPREFIX}"/usr \
201 + --enable-shared \
202 + --enable-pthread \
203 + --disable-rpath \
204 + --with-out-ext="${modules}" \
205 + $(use_with jemalloc jemalloc) \
206 + $(use_enable jit jit-support ) \
207 + $(use_enable socks5 socks) \
208 + $(use_enable systemtap dtrace) \
209 + $(use_enable doc install-doc) \
210 + --enable-ipv6 \
211 + $(use_enable static-libs static) \
212 + $(use_enable static-libs install-static-library) \
213 + $(use_with static-libs static-linked-ext) \
214 + $(use_enable debug) \
215 + ${myconf} \
216 + --enable-option-checking=no
217 +
218 + # Makefile is broken because it lacks -ldl
219 + rm -rf ext/-test-/popen_deadlock || die
220 +}
221 +
222 +src_compile() {
223 + emake V=1 EXTLDFLAGS="${LDFLAGS}" MJIT_CFLAGS="${CFLAGS}" MJIT_OPTFLAGS="" MJIT_DEBUGFLAGS=""
224 +}
225 +
226 +src_test() {
227 + emake -j1 V=1 test
228 +
229 + elog "Ruby's make test has been run. Ruby also ships with a make check"
230 + elog "that cannot be run until after ruby has been installed."
231 + elog
232 + if use rubytests; then
233 + elog "You have enabled rubytests, so they will be installed to"
234 + elog "/usr/share/${PN}-${SLOT}/test. To run them you must be a user other"
235 + elog "than root, and you must place them into a writeable directory."
236 + elog "Then call: "
237 + elog
238 + elog "ruby${MY_SUFFIX} -C /location/of/tests runner.rb"
239 + else
240 + elog "Enable the rubytests USE flag to install the make check tests"
241 + fi
242 +}
243 +
244 +src_install() {
245 + # Remove the remaining bundled gems. We do this late in the process
246 + # since they are used during the build to e.g. create the
247 + # documentation.
248 + einfo "Removing default gems before installation"
249 + rm -rf .ext/common/json.rb .ext/common/json ext/json || die
250 + rm -rf lib/bundler* lib/rdoc/rdoc.gemspec || die
251 + rm -rf lib/did_you_mean* || die
252 +
253 + # Ruby is involved in the install process, we don't want interference here.
254 + unset RUBYOPT
255 +
256 + local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
257 +
258 + LD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
259 +
260 + if [[ ${CHOST} == *darwin* ]] ; then
261 + DYLD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${DYLD_LIBRARY_PATH+:}${DYLD_LIBRARY_PATH}"
262 + export DYLD_LIBRARY_PATH
263 + fi
264 +
265 + RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
266 + for d in $(find "${S}/ext" -type d) ; do
267 + RUBYLIB="${RUBYLIB}:$d"
268 + done
269 + export LD_LIBRARY_PATH RUBYLIB
270 +
271 + # Create directory for the default gems
272 + local gem_home="${EPREFIX}/usr/$(get_libdir)/ruby/gems/${RUBYVERSION}"
273 + mkdir -p "${D}/${gem_home}" || die "mkdir gem home failed"
274 +
275 + emake V=1 DESTDIR="${D}" GEM_DESTDIR=${gem_home} install
276 +
277 + # Remove installed rubygems and rdoc copy
278 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
279 + rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
280 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
281 + rm -rf "${ED}/usr/bin/"{bundle,bundler,ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
282 +
283 + if use doc; then
284 + emake DESTDIR="${D}" GEM_DESTDIR=${gem_home} install-doc
285 + fi
286 +
287 + if use examples; then
288 + dodoc -r sample
289 + fi
290 +
291 + dodoc ChangeLog NEWS doc/NEWS* README*
292 +
293 + if use rubytests; then
294 + pushd test
295 + insinto /usr/share/${PN}-${SLOT}/test
296 + doins -r .
297 + popd
298 + fi
299 +}
300 +
301 +pkg_postinst() {
302 + if [[ ! -n $(readlink "${EROOT}"/usr/bin/ruby) ]] ; then
303 + eselect ruby set ruby${MY_SUFFIX}
304 + fi
305 +
306 + elog
307 + elog "To switch between available Ruby profiles, execute as root:"
308 + elog "\teselect ruby set ruby(23|24|...)"
309 + elog
310 +}
311 +
312 +pkg_postrm() {
313 + eselect ruby cleanup
314 +}