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, 01 May 2022 06:34:51
Message-Id: 1651386116.fb8f6d6440a1f1fc2540b3d02faef116bc49221d.graaff@gentoo
1 commit: fb8f6d6440a1f1fc2540b3d02faef116bc49221d
2 Author: Hans de Graaff <graaff <AT> gentoo <DOT> org>
3 AuthorDate: Sun May 1 06:21:56 2022 +0000
4 Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org>
5 CommitDate: Sun May 1 06:21:56 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fb8f6d64
7
8 dev-lang/ruby: run the full test suite
9
10 In previous ruby versions the full test suite could only be run against
11 an installed ruby version, but this is no longer the case, and in fact
12 the tests that we installed with the "rubytests" USE flag no longer
13 worked as-is. Instead, "make check" can be used to run the full suite
14 against the currently built ruby version.
15
16 In order for these checks to pass we also need to explicitly avoid
17 building the win32 extensions.
18
19 Thanks to chewi for investigating and suggesting improvements.
20
21 Signed-off-by: Hans de Graaff <graaff <AT> gentoo.org>
22
23 dev-lang/ruby/ruby-3.1.2-r1.ebuild | 249 +++++++++++++++++++++++++++++++++++++
24 1 file changed, 249 insertions(+)
25
26 diff --git a/dev-lang/ruby/ruby-3.1.2-r1.ebuild b/dev-lang/ruby/ruby-3.1.2-r1.ebuild
27 new file mode 100644
28 index 000000000000..f1cb6ecc0ea6
29 --- /dev/null
30 +++ b/dev-lang/ruby/ruby-3.1.2-r1.ebuild
31 @@ -0,0 +1,249 @@
32 +# Copyright 1999-2022 Gentoo Authors
33 +# Distributed under the terms of the GNU General Public License v2
34 +
35 +EAPI=8
36 +
37 +inherit autotools flag-o-matic
38 +
39 +MY_P="${PN}-$(ver_cut 1-3)"
40 +S=${WORKDIR}/${MY_P}
41 +
42 +SLOT=$(ver_cut 1-2)
43 +MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
44 +RUBYVERSION=${SLOT}.0
45 +
46 +DESCRIPTION="An object-oriented scripting language"
47 +HOMEPAGE="https://www.ruby-lang.org/"
48 +SRC_URI="https://cache.ruby-lang.org/pub/ruby/${SLOT}/${MY_P}.tar.xz"
49 +
50 +LICENSE="|| ( Ruby-BSD BSD-2 )"
51 +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"
52 +IUSE="berkdb debug doc examples gdbm ipv6 jemalloc jit +rdoc socks5 +ssl static-libs systemtap tk xemacs"
53 +
54 +RDEPEND="
55 + berkdb? ( sys-libs/db:= )
56 + gdbm? ( sys-libs/gdbm:= )
57 + jemalloc? ( dev-libs/jemalloc:= )
58 + jit? ( || ( sys-devel/gcc:* sys-devel/clang:* ) )
59 + ssl? (
60 + dev-libs/openssl:0=
61 + )
62 + socks5? ( >=net-proxy/dante-1.1.13 )
63 + systemtap? ( dev-util/systemtap )
64 + tk? (
65 + dev-lang/tcl:0=[threads]
66 + dev-lang/tk:0=[threads]
67 + )
68 + dev-libs/libyaml
69 + dev-libs/libffi:=
70 + sys-libs/readline:0=
71 + sys-libs/zlib
72 + virtual/libcrypt:=
73 + >=app-eselect/eselect-ruby-20201225
74 +"
75 +
76 +DEPEND="${RDEPEND}"
77 +
78 +BUNDLED_GEMS="
79 + >=dev-ruby/minitest-5.15.0[ruby_targets_ruby31]
80 + >=dev-ruby/power_assert-2.0.1[ruby_targets_ruby31]
81 + >=dev-ruby/rake-13.0.6[ruby_targets_ruby31]
82 + >=dev-ruby/rbs-2.1.0[ruby_targets_ruby31]
83 + >=dev-ruby/rexml-3.2.5[ruby_targets_ruby31]
84 + >=dev-ruby/rss-0.2.9[ruby_targets_ruby31]
85 + >=dev-ruby/test-unit-3.5.3[ruby_targets_ruby31]
86 + >=dev-ruby/typeprof-0.12.2[ruby_targets_ruby31]
87 +"
88 +
89 +PDEPEND="
90 + ${BUNDLED_GEMS}
91 + virtual/rubygems[ruby_targets_ruby31]
92 + >=dev-ruby/bundler-2.3.3[ruby_targets_ruby31]
93 + >=dev-ruby/did_you_mean-1.6.1[ruby_targets_ruby31]
94 + >=dev-ruby/json-2.6.1[ruby_targets_ruby31]
95 + rdoc? ( >=dev-ruby/rdoc-6.3.3[ruby_targets_ruby31] )
96 + xemacs? ( app-xemacs/ruby-modes )"
97 +
98 +src_prepare() {
99 + eapply "${FILESDIR}"/"${SLOT}"/010*.patch
100 +
101 + if use elibc_musl ; then
102 + eapply "${FILESDIR}"/3.1/901-musl-*.patch
103 + fi
104 +
105 + einfo "Unbundling gems..."
106 + cd "$S"
107 + # Remove bundled gems that we will install via PDEPEND, bug
108 + # 539700.
109 + rm -fr gems/* || die
110 + touch gems/bundled_gems || die
111 + # Don't install CLI tools since they will clash with the gem
112 + rm -f bin/{racc,racc2y,y2racc} || die
113 + sed -i -e '/executables/ s:^:#:' lib/racc/racc.gemspec || die
114 +
115 + einfo "Removing bundled libraries..."
116 + rm -fr ext/fiddle/libffi-3.2.1 || die
117 +
118 + # Remove tests that are known to fail
119 + rm -f test/ruby/test_process.rb test/rubygems/test_gem{,_path_support}.rb || die
120 +
121 +
122 + if use prefix ; then
123 + # Fix hardcoded SHELL var in mkmf library
124 + sed -i -e "s#\(SHELL = \).*#\1${EPREFIX}/bin/sh#" lib/mkmf.rb || die
125 +
126 + if [[ ${CHOST} == *darwin* ]] ; then
127 + # avoid symlink loop on Darwin (?!)
128 + sed -i \
129 + -e '/LIBRUBY_ALIASES=/s/lib$(RUBY_INSTALL_NAME).$(SOEXT)//' \
130 + configure.ac || die
131 +
132 + # make ar/libtool hack for Darwin work
133 + sed -i \
134 + -e "s/ac_cv_prog_ac_ct_AR='libtool/ac_cv_prog_AR='${CHOST}-libtool/" \
135 + configure.ac || die
136 + fi
137 + fi
138 +
139 + eapply_user
140 +
141 + eautoreconf
142 +}
143 +
144 +src_configure() {
145 + local modules="win32,win32ole" myconf=
146 +
147 + # -fomit-frame-pointer makes ruby segfault, see bug #150413.
148 + filter-flags -fomit-frame-pointer
149 + # In many places aliasing rules are broken; play it safe
150 + # as it's risky with newer compilers to leave it as it is.
151 + append-flags -fno-strict-aliasing
152 +
153 + # Socks support via dante
154 + if use socks5 ; then
155 + # Socks support can't be disabled as long as SOCKS_SERVER is
156 + # set and socks library is present, so need to unset
157 + # SOCKS_SERVER in that case.
158 + unset SOCKS_SERVER
159 + fi
160 +
161 + # Increase GC_MALLOC_LIMIT if set (default is 8000000)
162 + if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
163 + append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
164 + fi
165 +
166 + # ipv6 hack, bug 168939. Needs --enable-ipv6.
167 + use ipv6 || myconf="${myconf} --with-lookup-order-hack=INET"
168 +
169 + # Determine which modules *not* to build depending in the USE flags.
170 + if ! use berkdb ; then
171 + modules="${modules},dbm"
172 + fi
173 + if ! use gdbm ; then
174 + modules="${modules},gdbm"
175 + fi
176 + if ! use ssl ; then
177 + modules="${modules},openssl"
178 + fi
179 + if ! use tk ; then
180 + modules="${modules},tk"
181 + fi
182 +
183 + # Provide an empty LIBPATHENV because we disable rpath but we do not
184 + # need LD_LIBRARY_PATH by default since that breaks USE=multitarget
185 + # #564272
186 + INSTALL="${EPREFIX}/usr/bin/install -c" LIBPATHENV="" econf \
187 + --program-suffix=${MY_SUFFIX} \
188 + --with-soname=ruby${MY_SUFFIX} \
189 + --with-readline-dir="${EPREFIX}"/usr \
190 + --enable-shared \
191 + --enable-pthread \
192 + --disable-rpath \
193 + --with-out-ext="${modules}" \
194 + $(use_with jemalloc jemalloc) \
195 + $(use_enable jit jit-support ) \
196 + $(use_enable socks5 socks) \
197 + $(use_enable systemtap dtrace) \
198 + $(use_enable doc install-doc) \
199 + --enable-ipv6 \
200 + $(use_enable static-libs static) \
201 + $(use_enable static-libs install-static-library) \
202 + $(use_with static-libs static-linked-ext) \
203 + $(use_enable debug) \
204 + ${myconf} \
205 + --enable-option-checking=no
206 +
207 + # Makefile is broken because it lacks -ldl
208 + rm -rf ext/-test-/popen_deadlock || die
209 +}
210 +
211 +src_compile() {
212 + emake V=1 EXTLDFLAGS="${LDFLAGS}" MJIT_CFLAGS="${CFLAGS}" MJIT_OPTFLAGS="" MJIT_DEBUGFLAGS=""
213 +}
214 +
215 +src_test() {
216 + emake -j1 V=1 check
217 +}
218 +
219 +src_install() {
220 + # Remove the remaining bundled gems. We do this late in the process
221 + # since they are used during the build to e.g. create the
222 + # documentation.
223 + einfo "Removing default gems before installation"
224 + rm -rf lib/bundler* lib/rdoc/rdoc.gemspec || 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 +
233 + if [[ ${CHOST} == *darwin* ]] ; then
234 + DYLD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${DYLD_LIBRARY_PATH+:}${DYLD_LIBRARY_PATH}"
235 + export DYLD_LIBRARY_PATH
236 + fi
237 +
238 + RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
239 + for d in $(find "${S}/ext" -type d) ; do
240 + RUBYLIB="${RUBYLIB}:$d"
241 + done
242 + export LD_LIBRARY_PATH RUBYLIB
243 +
244 + # Create directory for the default gems
245 + local gem_home="${EPREFIX}/usr/$(get_libdir)/ruby/gems/${RUBYVERSION}"
246 + mkdir -p "${D}/${gem_home}" || die "mkdir gem home failed"
247 +
248 + emake V=1 DESTDIR="${D}" GEM_DESTDIR=${gem_home} install
249 +
250 + # Remove installed rubygems and rdoc copy
251 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}/rubygems" || die "rm rubygems failed"
252 + rm -rf "${ED}/usr/bin/"gem"${MY_SUFFIX}" || die "rm rdoc bins failed"
253 + rm -rf "${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"/rdoc* || die "rm rdoc failed"
254 + rm -rf "${ED}/usr/bin/"{bundle,bundler,ri,rdoc}"${MY_SUFFIX}" || die "rm rdoc bins failed"
255 +
256 + if use doc; then
257 + emake DESTDIR="${D}" GEM_DESTDIR=${gem_home} install-doc
258 + fi
259 +
260 + if use examples; then
261 + dodoc -r sample
262 + fi
263 +
264 + dodoc ChangeLog NEWS.md doc/NEWS* README*
265 +}
266 +
267 +pkg_postinst() {
268 + if [[ ! -n $(readlink "${EROOT}"/usr/bin/ruby) ]] ; then
269 + eselect ruby set ruby${MY_SUFFIX}
270 + fi
271 +
272 + elog
273 + elog "To switch between available Ruby profiles, execute as root:"
274 + elog "\teselect ruby set ruby(23|24|...)"
275 + elog
276 +}
277 +
278 +pkg_postrm() {
279 + eselect ruby cleanup
280 +}