Diff ruby-3.2.10 with a ruby-4.0.4

/usr/portage/dev-lang/ruby/ruby-4.0.4.ebuild 2026-05-16 19:17:04.611065779 +0300
3 3

  
4 4
EAPI=8
5 5

  
6
RUST_MIN_VER="1.85.0"
6 7
RUST_OPTIONAL="yes"
7 8

  
8
inherit autotools flag-o-matic multiprocessing toolchain-funcs rust
9
inherit autotools flag-o-matic multiprocessing rust
9 10

  
10 11
MY_P="${PN}-$(ver_cut 1-3)"
12
MY_PV="${PV%.*}"
13
MY_SLOT=$(ver_cut 1-2)
11 14

  
12 15
DESCRIPTION="An object-oriented scripting language"
13 16
HOMEPAGE="https://www.ruby-lang.org/"
14
SRC_URI="https://cache.ruby-lang.org/pub/ruby/$(ver_cut 1-2)/${MY_P}.tar.xz"
15
S=${WORKDIR}/${MY_P}
17
if [[ ${PV} == *9999* ]]; then
18
	inherit git-r3
19
	EGIT_BRANCH="ruby_${MY_PV/./_}"
20
	EGIT_REPO_URI="https://github.com/ruby/ruby.git"
21

  
22
	# Self-depend is necessary because ruby from git depends on building some pre-requisite gems.
23
	BDEPEND="
24
		dev-lang/ruby:${MY_SLOT}
25
	"
26
else
27
	SRC_URI="https://cache.ruby-lang.org/pub/ruby/$(ver_cut 1-2)/${MY_P}.tar.xz"
28
	S=${WORKDIR}/${MY_P}
29
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos ~x64-solaris"
30
fi
16 31

  
17 32
LICENSE="|| ( Ruby-BSD BSD-2 )"
18
SLOT=$(ver_cut 1-2)
33
SLOT=${MY_SLOT}
19 34
MY_SUFFIX=$(ver_rs 1 '' ${SLOT})
20 35
RUBYVERSION=${SLOT}.0
21 36

  
22
KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~mips ppc ppc64 ~riscv ~s390 ~sparc x86 ~arm64-macos ~x64-macos ~x64-solaris"
23 37
IUSE="berkdb debug doc examples gdbm jemalloc jit socks5 +ssl static-libs systemtap tk valgrind xemacs"
24 38

  
25 39
RDEPEND="
......
38 52
	)
39 53
	dev-libs/libyaml
40 54
	dev-libs/libffi:=
41
	sys-libs/readline:0=
42 55
	virtual/zlib:=
43 56
	virtual/libcrypt:=
44
	>=app-eselect/eselect-ruby-20231008
57
	>=app-eselect/eselect-ruby-20251225
45 58
"
46 59

  
47 60
DEPEND="
......
50 63
"
51 64

  
52 65
BUNDLED_GEMS="
53
	>=dev-ruby/debug-1.7.1[ruby_targets_ruby32(-)]
54
	>=dev-ruby/irb-1.6.2[ruby_targets_ruby32(-)]
55
	>=dev-ruby/matrix-0.4.2[ruby_targets_ruby32(-)]
56
	>=dev-ruby/minitest-5.16.3[ruby_targets_ruby32(-)]
57
	>=dev-ruby/net-ftp-0.2.1[ruby_targets_ruby32(-)]
58
	>=dev-ruby/net-imap-0.3.4.1[ruby_targets_ruby32(-)]
59
	>=dev-ruby/net-pop-0.1.2[ruby_targets_ruby32(-)]
60
	>=dev-ruby/net-smtp-0.3.4[ruby_targets_ruby32(-)]
61
	>=dev-ruby/power_assert-2.0.3[ruby_targets_ruby32(-)]
62
	>=dev-ruby/prime-0.1.2[ruby_targets_ruby32(-)]
63
	>=dev-ruby/rake-13.0.6-r2[ruby_targets_ruby32(-)]
64
	>=dev-ruby/rbs-2.8.2[ruby_targets_ruby32(-)]
65
	>=dev-ruby/rexml-3.4.4[ruby_targets_ruby32(-)]
66
	>=dev-ruby/rss-0.3.1[ruby_targets_ruby32(-)]
67
	>=dev-ruby/test-unit-3.5.7[ruby_targets_ruby32(-)]
68
	>=dev-ruby/typeprof-0.21.3[ruby_targets_ruby32(-)]
66
	>=dev-ruby/minitest-6.0.0[ruby_targets_ruby40(-)]
67
	>=dev-ruby/power_assert-3.0.1[ruby_targets_ruby40(-)]
68
	>=dev-ruby/rake-13.3.1[ruby_targets_ruby40(-)]
69
	>=dev-ruby/test-unit-3.7.5[ruby_targets_ruby40(-)]
70
	>=dev-ruby/rexml-3.4.4[ruby_targets_ruby40(-)]
71
	>=dev-ruby/rss-0.3.2[ruby_targets_ruby40(-)]
72
	>=dev-ruby/net-ftp-0.3.9[ruby_targets_ruby40(-)]
73
	>=dev-ruby/net-imap-0.6.2[ruby_targets_ruby40(-)]
74
	>=dev-ruby/net-pop-0.1.2[ruby_targets_ruby40(-)]
75
	>=dev-ruby/net-smtp-0.5.1[ruby_targets_ruby40(-)]
76
	>=dev-ruby/matrix-0.4.3[ruby_targets_ruby40(-)]
77
	>=dev-ruby/prime-0.1.4[ruby_targets_ruby40(-)]
78
	>=dev-ruby/rbs-3.10.0[ruby_targets_ruby40(-)]
79
	>=dev-ruby/typeprof-0.31.1[ruby_targets_ruby40(-)]
80
	>=dev-ruby/debug-1.11.1[ruby_targets_ruby40(-)]
81
	>=dev-ruby/racc-1.8.1[ruby_targets_ruby40(-)]
82

  
83
	>=dev-ruby/mutex_m-0.3.0[ruby_targets_ruby40(-)]
84
	>=dev-ruby/getoptlong-0.2.1[ruby_targets_ruby40(-)]
85
	>=dev-ruby/base64-0.3.0[ruby_targets_ruby40(-)]
86
	>=dev-ruby/bigdecimal-4.0.1[ruby_targets_ruby40(-)]
87
	>=dev-ruby/observer-0.1.2[ruby_targets_ruby40(-)]
88
	>=dev-ruby/abbrev-0.1.2[ruby_targets_ruby40(-)]
89
	>=dev-ruby/resolv-replace-0.1.1[ruby_targets_ruby40(-)]
90
	>=dev-ruby/rinda-0.2.0[ruby_targets_ruby40(-)]
91
	>=dev-ruby/drb-2.2.3[ruby_targets_ruby40(-)]
92
	>=dev-ruby/nkf-0.2.0[ruby_targets_ruby40(-)]
93
	>=dev-ruby/syslog-0.3.0[ruby_targets_ruby40(-)]
94
	>=dev-ruby/csv-3.3.5[ruby_targets_ruby40(-)]
95
	>=dev-ruby/repl_type_completor-0.1.12[ruby_targets_ruby40(-)]
96
	>=dev-ruby/ostruct-0.6.3[ruby_targets_ruby40(-)]
97
	>=dev-ruby/pstore-0.2.0[ruby_targets_ruby40(-)]
98
	>=dev-ruby/benchmark-0.5.0[ruby_targets_ruby40(-)]
99
	>=dev-ruby/logger-1.7.0[ruby_targets_ruby40(-)]
100
	>=dev-ruby/reline-0.6.3[ruby_targets_ruby40(-)]
101
	>=dev-ruby/readline-0.0.4[ruby_targets_ruby40(-)]
102
	>=dev-ruby/fiddle-1.1.8[ruby_targets_ruby40(-)]
69 103
"
70 104

  
71 105
PDEPEND="
72 106
	${BUNDLED_GEMS}
73
	virtual/rubygems[ruby_targets_ruby32(-)]
74
	>=dev-ruby/bundler-2.3.3[ruby_targets_ruby32(-)]
75
	>=dev-ruby/did_you_mean-1.6.1[ruby_targets_ruby32(-)]
76
	>=dev-ruby/json-2.6.1[ruby_targets_ruby32(-)]
77
	>=dev-ruby/rdoc-6.3.3[ruby_targets_ruby32(-)]
107
	virtual/rubygems[ruby_targets_ruby40(-)]
108
	>=dev-ruby/bundler-4.0.3[ruby_targets_ruby40(-)]
109
	>=dev-ruby/did_you_mean-2.0.0[ruby_targets_ruby40(-)]
110
	>=dev-ruby/irb-1.16.0[ruby_targets_ruby40(-)]
111
	>=dev-ruby/json-2.18.0[ruby_targets_ruby40(-)]
112
	>=dev-ruby/rdoc-7.0.2[ruby_targets_ruby40(-)]
78 113
	xemacs? ( app-xemacs/ruby-modes )
79 114
"
80 115

  
......
84 119

  
85 120
src_prepare() {
86 121
	eapply "${FILESDIR}"/"${SLOT}"/010*.patch
87
	eapply "${FILESDIR}"/"${SLOT}"/011*.patch
88
	eapply "${FILESDIR}"/"${SLOT}"/013*.patch
89
	eapply "${FILESDIR}"/"${SLOT}"/017*.patch
90 122
	eapply "${FILESDIR}"/"${SLOT}"/902*.patch
91 123

  
92 124
	if use elibc_musl ; then
......
94 126
	fi
95 127

  
96 128
	einfo "Unbundling gems..."
97
	cd "$S"
129
	cd "${S}" || die
98 130
	# Remove bundled gems that we will install via PDEPEND, bug
99 131
	# 539700.
100 132
	rm -fr gems/* || die
101 133
	touch gems/bundled_gems || die
102
	# Don't install CLI tools since they will clash with the gem
103
	rm -f bin/{racc,racc2y,y2racc} || die
104
	sed -i -e '/executables/ s:^:#:' lib/racc/racc.gemspec || die
134

  
135
	# Doesn't play well with PORTAGE_NICENESS/PORTAGE_SCHEDULING_POLICY
136
	rm -f spec/ruby/core/process/setpriority_spec.rb || die
105 137

  
106 138
	# Remove tests that are known to fail or require a network connection
107 139
	rm -f test/ruby/test_process.rb test/rubygems/test_gem{,_path_support}.rb || die
108 140
	rm -f test/rubygems/test_bundled_ca.rb || die
109
	rm -f test/rinda/test_rinda.rb test/socket/test_tcp.rb \
110
	   test/fiber/test_address_resolve.rb spec/ruby/library/socket/tcpsocket/{initialize,open}_spec.rb|| die
141
	rm -f test/rinda/test_rinda.rb test/socket/test_tcp.rb test/fiber/test_address_resolve.rb \
142
	   spec/ruby/library/socket/tcpsocket/{initialize,open}_spec.rb \
143
		spec/ruby/library/socket/socket/connect_spec.rb || die
111 144

  
112 145
	# Remove webrick tests because setting LD_LIBRARY_PATH does not work for them.
113 146
	rm -rf tool/test/webrick || die
114 147

  
115
	# Avoid test using the system ruby
116
	sed -i -e '/test_dumb_terminal/aomit "Uses system ruby"' test/reline/test_reline.rb || die
117

  
118
	# Avoid testing against hard-coded blockdev devices and user names
119
	# that most likely are not available
120
	sed -e '/def blockdev/a@blockdev = nil' \
121
		-e '/test_expand_path_for_existent_username/aomit "Checks USER"' \
122
		-i test/ruby/test_file_exhaustive.rb || die
148
	# Avoid testing against hard-coded blockdev devices that most likely are not available
149
	sed -i -e '/def blockdev/a@blockdev = nil' test/ruby/test_file_exhaustive.rb || die
123 150

  
124 151
	# Avoid tests that require gem downloads
125
	sed -i -e '/^test-syntax-suggest/ s/\$(TEST_RUNNABLE)/no/' common.mk || die
126
	sed -i -e '/^check:/ s/\$(TEST_RUNNABLE)-\$(PREPARE_SYNTAX_SUGGEST) test-syntax-suggest//' common.mk || die
152
	sed -e '/^check/ s/\(test-syntax-suggest\|\$(PREPARE_SYNTAX_SUGGEST)\)//g' \
153
		-i common.mk || die
127 154

  
128 155
	# Avoid test that fails intermittently
129 156
	sed -e '/test_gem_exec_gem_uninstall/aomit "Fails intermittently"' \
130 157
		-i test/rubygems/test_gem_commands_exec_command.rb || die
131 158

  
132
	# Avoid test that can easily timeout
133
	sed -e '/test_getch_timeout/aomit "Times out easily"' \
134
		-i test/io/console/test_io_console.rb || die
159
	# Avoid test fragile for git command output not matching on whitespace
160
	sed -e '/test_pretty_print/aomit "Fragile for output differences"' \
161
		-i test/rubygems/test_gem_source_git.rb || die
162

  
163
	# Avoid tests that don't expect our ruby40 executable name.
164
	sed -e '/test_prelude_gems_and_loaded_features/aomit "Does not match ruby40"' \
165
		-i test/ruby/test_box.rb
166

  
167
	# Have ruby --version print out ${PV}
168
	if [[ ${PV} == *9999* ]]; then
169
		sed -i "s/#define RUBY_VERSION_TEENY.*/#define RUBY_VERSION_TEENY 9999/" version.h || die
170

  
171
		cp "${BROOT}"/usr/share/gnuconfig/config.guess "${S}"/tool/config.guess || die
172
		cp "${BROOT}"/usr/share/gnuconfig/config.sub "${S}"/tool/config.sub || die
173
	fi
174

  
175
	# Avoid specs that require gems to be installed already due to our unbundling.
176
	rm -rf spec/ruby/library/irb || die
135 177

  
136 178
	if use prefix ; then
137 179
		# Fix hardcoded SHELL var in mkmf library
......
144 186
}
145 187

  
146 188
src_configure() {
147
	local modules="win32,win32ole" myconf=
189
	local modules="win32,win32ole"
148 190

  
149 191
	# Ruby's build system does interesting things with MAKEOPTS and doesn't
150 192
	# handle MAKEOPTS="-Oline" or similar well. Just filter it all out
......
165 207
	# In many places aliasing rules are broken; play it safe
166 208
	# as it's risky with newer compilers to leave it as it is.
167 209
	append-flags -fno-strict-aliasing
168
	# Workaround for bug #965095 (gcc PR122610)
169
	tc-is-gcc && append-flags -fno-ipa-modref
210
	# Fails to link (gcc PR124865, gcc PR50676)
211
	filter-flags -flto-partition=cache
212
	# bug #972696
213
	append-cppflags -DRB_THREAD_CURRENT_EC_NOINLINE
170 214

  
171 215
	# Workaround for bug #938302
172 216
	if use systemtap && has_version "dev-debug/systemtap[-dtrace-symlink(+)]" ; then
......
182 226
	fi
183 227

  
184 228
	# Increase GC_MALLOC_LIMIT if set (default is 8000000)
185
	if [ -n "${RUBY_GC_MALLOC_LIMIT}" ] ; then
229
	if [[ -n "${RUBY_GC_MALLOC_LIMIT}" ]] ; then
186 230
		append-flags "-DGC_MALLOC_LIMIT=${RUBY_GC_MALLOC_LIMIT}"
187 231
	fi
188 232

  
......
205 249
	# #564272
206 250
	# except on Darwin, where we really need LIBPATHENV to set the right
207 251
	# DYLD_ stuff during the invocation of miniruby for it to work
208
	#
209
	# --with-setjmp-type=setjmp for bug #949016
210 252
	[[ ${CHOST} == *-darwin* ]] || export LIBPATHENV=""
211
	INSTALL="${EPREFIX}/usr/bin/install -c" econf \
212
		--program-suffix=${MY_SUFFIX} \
213
		--with-soname=ruby${MY_SUFFIX} \
214
		--with-readline-dir="${EPREFIX}"/usr \
215
		--enable-shared \
216
		--enable-pthread \
217
		--disable-rpath \
218
		--without-baseruby \
219
		--with-compress-debug-sections=no \
220
		--with-setjmp-type=setjmp \
221
		--enable-mkmf-verbose \
222
		--with-out-ext="${modules}" \
223
		$(use_with jemalloc jemalloc) \
224
		$(use_enable jit jit-support) \
225
		$(use_enable jit yjit) \
226
		$(use_enable socks5 socks) \
227
		$(use_enable systemtap dtrace) \
228
		$(use_enable doc install-doc) \
229
		$(use_enable static-libs static) \
230
		$(use_enable static-libs install-static-library) \
231
		$(use_with static-libs static-linked-ext) \
232
		$(use_enable debug) \
233
		${myconf} \
234
		$(use_with valgrind) \
253

  
254
	local myeconfargs=(
255
		--program-suffix=${MY_SUFFIX}
256
		--with-soname=ruby${MY_SUFFIX}
257
		--enable-shared
258
		--enable-pthread
259
		--disable-rpath
260
		--without-baseruby
261
		--with-compress-debug-sections=no
262
		# --with-setjmp-type=setjmp for bug #949016
263
		--with-setjmp-type=setjmp
264
		--enable-mkmf-verbose
265
		--with-out-ext="${modules}"
266
		$(use_with jemalloc jemalloc)
267
		$(use_enable jit jit-support)
268
		$(use_enable jit yjit)
269
		$(use_enable jit zjit)
270
		$(use_enable socks5 socks)
271
		$(use_enable systemtap dtrace)
272
		$(use_enable doc install-doc)
273
		$(use_enable static-libs static)
274
		$(use_enable static-libs install-static-library)
275
		$(use_with static-libs static-linked-ext)
276
		$(use_enable debug)
277
		$(use_with valgrind)
235 278
		--enable-option-checking=no
279
	)
280

  
281
	# Fix co-routine selection for x32, bug 933070
282
	[[ ${CHOST} == *gnux32 ]] && myeconfargs+=( --with-coroutine=amd64 )
283

  
284
	# Live ebuilds require a Ruby version to build with.
285
	[[ ${PV} == *9999* ]] && myeconfargs+=( --with-baseruby="${BROOT}"/usr/bin/ruby$(ver_rs 1 "" "${MY_PV}") )
286

  
287
	INSTALL="${EPREFIX}/usr/bin/install -c" econf "${myeconfargs[@]}"
236 288

  
237 289
	# Makefile is broken because it lacks -ldl
238 290
	rm -rf ext/-test-/popen_deadlock || die
......
244 296
}
245 297

  
246 298
src_test() {
247
	local -x USER=$(whoami)
248 299
	local -x LD_LIBRARY_PATH="${S}${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
249 300
	emake V=1 check
250 301
}
......
259 310
	# Ruby is involved in the install process, we don't want interference here.
260 311
	unset RUBYOPT
261 312

  
262
	local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)'|make -f - getminiruby)
263

  
313
	local MINIRUBY=$(echo -e 'include Makefile\ngetminiruby:\n\t@echo $(MINIRUBY)' | make -f - getminiruby)
264 314
	local -x LD_LIBRARY_PATH="${S}:${ED}/usr/$(get_libdir)${LD_LIBRARY_PATH+:}${LD_LIBRARY_PATH}"
265

  
266 315
	local -x RUBYLIB="${S}:${ED}/usr/$(get_libdir)/ruby/${RUBYVERSION}"
316
	local d
267 317
	for d in $(find "${S}/ext" -type d) ; do
268
		RUBYLIB="${RUBYLIB}:$d"
318
		RUBYLIB="${RUBYLIB}:${d}"
269 319
	done
270 320

  
271 321
	# Create directory for the default gems
......
288 338
		dodoc -r sample
289 339
	fi
290 340

  
291
	dodoc ChangeLog NEWS.md README*
341
	dodoc NEWS.md README*
292 342
	dodoc -r doc
293 343
}
294 344

  
Thank you!