Compare commits

...

126 Commits

Author SHA1 Message Date
33731c3ae4
Add riscv64 information for checksec
Signed-off-by: David Abdurachmanov <davidlt@rivosinc.com>
2024-07-24 09:52:48 +03:00
Fedora Release Engineering
55661b64e9 Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-19 18:58:13 +00:00
Vít Ondruch
ca13a51589 Upgrade to Ruby 3.3.4.
Resolves: rhbz#2292052
2024-07-10 11:17:20 +02:00
Vít Ondruch
7724c2d703 Make sure hardening configuration flags are correctly applied.
Previously, upstream flags were overriding our configuration flags,
therefore we had two workarounds in place. This commit replaces these
workarounds by upstream solution. While it should not result in any
functional changes, it is be better to have this patch in place to make
easier to spot when it is not needed anymore.
2024-06-18 12:56:21 +02:00
Vít Ondruch
42b0e43e5a Fix generators for RPM 4.20 compatibility
RPM 4.20 introduce per-build directory. However, this also brings some
issues where `%{_builddir}` might have different value in different
context, leading to issues such as:

~~~
Processing files: ruby-default-gems-3.3.1-8.fc41.noarch
make: *** /builddir/build/BUILD/ruby-3.3.1/redhat-linux-build: No such file or directory.  Stop.
~~~

Therefore the generators are not executed properly. Use `%define`
instead of `%global`, because those are laze evaluated and actually
suggested by RPM upstream:

https://github.com/rpm-software-management/rpm/issues/3151
2024-06-07 12:25:48 +02:00
Vít Ondruch
c913e4326c Drop patch which was needed for alexandria
It seems it build just fine now.
2024-06-06 19:13:11 +02:00
Vít Ondruch
93638d9e58 Upgrade to Ruby 3.3.2.
Resolves: rhbz#2284020
2024-06-06 16:07:59 +02:00
Vít Ondruch
677893973e Make sure fortification flags are applied
This is example of current build options:

~~~
gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fPIC -m64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -I. -I.ext/include/x86_64-linux -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/include -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1 -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/prism -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/enc/unicode/15.0.0      -o dmyext.o -c /builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/dmyext.c
~~~

Please note that there are included Fedora options:

~~~
-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3
~~~

as well as upstream options:

~~~
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
~~~

The problem is that the configure script cannot properly detect
`_FORTIFY_SOURCE=3` and instead of replacing that option, it includes
new definition \[[1]\]. This happens since Fedora started to use
`_FORTIFY_SOURCE=3` option. To mitigate this issue, upstream
fortification was disabled (this might or might not stay disabled
"forever").

These are the build options with this change applied for comparison:

~~~
gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fPIC -m64 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -fexcess-precision=standard -DRUBY_EXPORT -I. -I.ext/include/x86_64-linux -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/include -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1 -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/prism -I/builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/enc/unicode/15.0.0      -o dmyext.o -c /builddir/build/BUILD/ruby-3.3.1-build/ruby-3.3.1/dmyext.c
~~~

[1]: https://bugs.ruby-lang.org/issues/20520
2024-06-05 16:29:24 +02:00
Vít Ondruch
d9051618e3 Adjust the test to updated checksec output.
`checksec` output since v2.7.0 become more nuanced. Previously, the
`FORTIFY` could become just `Yes` / `No`. Now it can have also `Partial`
state, which better describe our situation.

Currently if e.g. `Fortifiable=28` and `Fortified=11`, that means that the
fortification is just partial and another 17 functions could be
fortified.

Also, check the numbers specifically, because this seems to be the
interesting information. Unfortunatelly, the results differ between
platforms.

Last but not least, use `sed` to analyze the output, because this allows to
always display the processed text. The trick comes from \[[1]\].

On top of this, use XML formatted output, which provides more context to
reader.

[1]: https://unix.stackexchange.com/questions/366/convince-grep-to-output-all-lines-not-just-those-with-matches

Resolves: rhbz#2282953
2024-06-05 09:45:17 +02:00
Vít Ondruch
ff5301a5f3 Fix patch to apply cleanly. 2024-04-24 17:35:38 +02:00
Vít Ondruch
c649282efb Upgrade to Ruby 3.3.1. 2024-04-24 12:31:33 +02:00
Vít Ondruch
4ff7de7007 License review and clarification 2024-04-12 17:28:42 +02:00
Vít Ondruch
5da6a15c57 Ruby bundled NKF, add appropriate bundled provide and test 2024-04-12 17:26:16 +02:00
Vít Ondruch
a34f33bc50 Fix FTBFS caused by OpenSSL 3.2.1 update. 2024-03-06 15:14:30 +01:00
Vít Ondruch
3008410463 Merge #169 Use gem macros for rubygem-rbs subpackage. 2024-01-26 15:04:52 +00:00
Vít Ondruch
ac77c2a354 Use gem macros for rubygem-rbs subpackage.
This were apparenlyt overlooked previously.
2024-01-26 14:16:50 +01:00
Jarek Prokop
aa7e8debee Revert adding AI_ADDRCONFIG flag to getaddrinfo(3) calls.
It is causing problems when network is in certain, valid, configuration.
The point of it is to workaround a glibc bug that is not present for us.
https://bugs.ruby-lang.org/issues/20208

To reproduce, have IPv6 enabled localhost but only IPv4
interfaces (such as eth0, name and count of them may vary based on system)
to disable public interfaces via sysctl:
`$ sysctl "net.ipv6.conf.<interface>.disable_ipv6=1"`
Where <interface> is NOT lo but can be eth0 or other.

Confirm with command `$ ip addr` command that only `lo`
interface has IPv6 address.

and run the following with Ruby 3.3:
~~~
$ ruby -rnet/http -e 'http = Net::HTTP.new("localhost", 8080); http.local_host = Addrinfo.tcp("localhost", 8080).ip_address; p http.get("/")'
~~~
The error is then related to EAFNOSUPPORT:
```
Errno::EAFNOSUPPORT: Failed to open TCP connection to localhost:37337 (Address family not supported by protocol - bind(2) for "::1" port 45395)
```

running above Ruby command with `strace` suggest that
there is an attempt to bind with AF_INET6
using an AF_INET socket, however, only if the reproducer above
attempts to set the `http.local_host` with Addrinfo.

From upstream issue #20208:
"This is calling getaddrinfo to resolve "localhost" for us to use
it as the local side of the connection. Because Ruby does not know
what you intend to do with this IP address, it does not make the request
with AI_ADDRCONFIG. Thus, you get an IPv6 result returned,
since there is an IPv6 addres for localhost!"
2024-01-26 13:54:20 +01:00
Fedora Release Engineering
066e0a3d6d Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-22 12:17:40 +00:00
Jarek Prokop
308b2c0ab2 Fix compiling coroutines with aarch64's branch protection.
Armv8.3+ capable CPUs might segfault with incorrect compilation options.
See related upstream report: https://bugs.ruby-lang.org/issues/20085

We have hit this on COPR which uses [0] c7g.xlarge AWS flavor for aarch64
architecture builds. This machine flavor seems to fall into the ARMv8.3+
range.

Fedora CFLAGS come with `-mbranch-protection=standard` which means that
both BTI and the PAC protections are used. The option is equivalent
to `-mbranch-protection=pac-ret+bti`.

However, since the upstream configure.ac automatically appends
`-mbranch-protection=pac-ret`, the BTI protection is not used
as the last used option seems to overwrite [1] the Fedora
default for this.

To resolve both of these issues, of BTI being skipped and the potential
segfaults a patch is applied.

To fix segfaults an upstream patch was applied [2].

To fix the issue of overridden option I have patched the
configure.ac file to check for the `=standard` first when searching for a usable
`-mbranch-protection` option.

The overriding of our options was reported upstream:
<https://bugs.ruby-lang.org/issues/20154>
In the same issue I provided the extension of compilation option as an
attachment, to showcase a workaround that fixes the situation in Fedora.

[0] <https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/Y4GPCGQAZT2LJ5CE7MTIEFKGAPP6O2DW/>
[1] <https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/QWLEBS4YQH73HJNNLKCCGIIOU3SSXAYK/>
[2] <02973b78f4>
2024-01-15 16:38:51 +01:00
Vít Ondruch
05a6c9c8f3 Upgrade to Ruby 3.3.0.
Resolves: rhbz#2255918
2024-01-02 18:52:33 +01:00
Vít Ondruch
f195b6a3c8 Drop attempt to disable JIT test on i686
The was renamed test_jit.rb → test_mjit.rb in Ruby 3.2:

ead96e7b44

Therefore this is alread no-op and we can just drop it.
2023-12-07 13:22:00 +01:00
Jarek Prokop
321ed23c22 Update ticket reference for disabled tests on x86.
Tests fail with a LANG=C environment. A new investigation into the
failing tests on x86 revealed exact commits which introduced the issue
and the commits that fixed the situation. Fix is not yet present in Ruby
3.2, therefore the conditional disabling the tests was left in.
A new re-reported ticket replaced the old one. The new upstream ticket
includes better detailed description of the environment causing the
issue.

The tests pass in Rawhide mock (F40), as the LANG there is C.UTF-8
that does not suffer from the issue.

Upstream ticket: https://bugs.ruby-lang.org/issues/20045
2023-12-07 12:01:03 +01:00
Jarek Prokop
ba498ce48c armv7hl is no longer one of arches we build on.
No point in keeping dead conditional around.
2023-11-29 20:11:24 +01:00
Jun Aruga
8d5b538747 ssl: use ffdhe2048 from RFC 7919 as the default DH group parameter
When the dependant openssl-libs was upgraded from 1:3.1.1-4.fc40 to
1:3.1.4-1.fc40, Fedora rawhide started to fail on Koschei.

This commit fixes the following failures in OpenSSL FIPS.

```
+ make -C redhat-linux-build runruby 'TESTRUN_SCRIPT=   -I/builddir/build/BUILD/ruby-3.2.2/tool/lib --enable-gems   /builddir/build/SOURCES/test_openssl_fips.rb /builddir/build/BUILD/ruby-3.2.2 --verbose'
...
  1) Failure:
OpenSSL::TestFIPS#test_fips_mode_get_with_fips_mode_set [/builddir/build/BUILD/ruby-3.2.2/test/openssl/test_fips.rb:38]:
assert_separately failed with error message
pid 93968 exit 1
| /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/pkey.rb:132:in `initialize': could not parse pkey (OpenSSL::PKey::DHError)
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/pkey.rb:132:in `new'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/pkey.rb:132:in `new'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:37:in `<class:SSLContext>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:23:in `<module:SSL>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:22:in `<module:OpenSSL>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:21:in `<top (required)>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl.rb:21:in `require_relative'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl.rb:21:in `<top (required)>'
| >-from -:in `require'
  2) Failure:
OpenSSL::TestFIPS#test_fips_mode_get_is_true_on_fips_mode_enabled [/builddir/build/BUILD/ruby-3.2.2/test/openssl/test_fips.rb:12]:
assert_separately failed with error message
pid 93969 exit 1
| /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/pkey.rb:132:in `initialize': could not parse pkey (OpenSSL::PKey::DHError)
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/pkey.rb:132:in `new'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/pkey.rb:132:in `new'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:37:in `<class:SSLContext>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:23:in `<module:SSL>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:22:in `<module:OpenSSL>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl/ssl.rb:21:in `<top (required)>'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl.rb:21:in `require_relative'
| >-from /builddir/build/BUILD/ruby-3.2.2/redhat-linux-build/.ext/common/openssl.rb:21:in `<top (required)>'
| >-from -:in `require'
Finished tests in 0.166449s, 72.0941 tests/s, 342.4468 assertions/s.
12 tests, 57 assertions, 2 failures, 0 errors, 1 skips
```

The commit was ported from CentOS Stream rpms/ruby stream-ruby-3.1-rhel-9.4.0 branch:
<59242d8ce8>.
2023-11-09 17:58:10 +01:00
Vít Ondruch
5fd12c42e7 Cache Gem.default_dir
RubyGems do internally the same \[[1]\]. This should help with:

1) Performance (not tested)
2) Running RubyGems test suite (main motivation), which actually
   overrides the `@default_dir` \[[2]\] to be able to place test content
   into dedicated directory.

[1]: f8e87eba76/lib/rubygems/defaults.rb (L38)
[2]: f8e87eba76/test/rubygems/helper.rb (L372)
2023-11-03 17:12:13 +01:00
Vít Ondruch
d432c95c15 Remove spaces from changelog NVR. 2023-11-03 12:24:38 +01:00
Jarek Prokop
393e74f1e0 Fix bundled provide net-http-persistent typo. 2023-11-02 16:06:07 +01:00
Jun Aruga
1f35109c5e Fix OpenSSL.fips_mode and OpenSSL::PKey.read in OpenSSL 3 FIPS. 2023-09-22 12:54:53 +02:00
Fedora Release Engineering
64dc6dd3e4 Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-21 17:14:32 +00:00
Jarek Prokop
814eaf5324 Re-enable FFI related tests.
libffi since NVR libffi-3.4.4-3.fc39 builds with static trampolines
enabled. This fixes the failures which were the reason for disabling
the tests.

Since it recently landed in Rawhide, we can re-enable the tests.
2023-07-12 10:30:51 +02:00
Pavel Valena
da8822cd33 Use new %patch macro
instead of %patchN, as advised by warning:

%patchN is deprecated (11 usages found), use %patch N (or %patch -P N)
2023-05-03 11:11:47 +02:00
Vít Ondruch
9e39fd242a Upgrade to Ruby 3.2.2.
Resolves: rhbz#2183284
2023-03-31 15:27:47 +02:00
Vít Ondruch
31778c5ebd Use %{_fileattsdir} for RPM macro generator. 2023-03-08 13:11:49 +01:00
Vít Ondruch
8f9fe41ba6 Use %{_rpmmacrodir} for RPM macros. 2023-03-08 13:09:30 +01:00
Vít Ondruch
59f62d6bc9 Upgrade to Ruby 3.2.1.
Resolves: rhbz#2168292
2023-02-10 10:45:13 +01:00
Vít Ondruch
65acd291de yaml and libffi sources are not bundled anymore.
https://bugs.ruby-lang.org/issues/18571
2023-02-09 14:22:39 +01:00
Miro Hrončok
9c8400d99a Don't Suggest rubypick when built without rubypick 2023-01-25 12:06:23 +01:00
Fedora Release Engineering
d46ef9bbf3 Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-20 20:05:46 +00:00
Vít Ondruch
ff0f48acd6 Fix ELN FTBFS due to stronger crypto settings. 2023-01-05 10:30:24 +01:00
Vít Ondruch
22597b6039 Fix compatibilty with rpmlint 2.0+
Revert "ruby.rpmlintrc: Add a filter for "E: shared-lib-without-dependency-information"."

This reverts commit aee17a2180.

This is not needed anymore, because Zuul runs rpmlint 2.0+ already.
2023-01-02 18:20:46 +01:00
Vít Ondruch
c4043528c1 The missing-call-to-chdir-with-chroot test was removed in rpmlint 2.0
83f915a54d
2023-01-02 18:16:58 +01:00
Vít Ondruch
be9fcec798 gem.build_complete is corectly recognized by rpmlint 2.0+ 2023-01-02 18:13:01 +01:00
Vít Ondruch
f2899ee090 Upgrade to Ruby 3.2.0.
For details of the evolution please check `private-ruby-3.2` branch.
2023-01-02 18:09:09 +01:00
Yaakov Selkowitz
25858e766a Add upstream patches to avoid SHA1 usage in ossl 2022-12-22 11:37:52 -05:00
Vít Ondruch
f8ef5964d0 Fix for tzdata-2022g. 2022-12-21 16:11:40 +01:00
Vít Ondruch
b1748af87f Fix CGI causing issue with leading '.' in domain names.
The original issue broke rubygem-actionpack:

https://github.com/rails/rails/issues/46578
https://github.com/rails/rails/pull/46595

rubygem-rack:

https://github.com/rack/rack/pull/1988

And rack-test (where I have not checked details).
2022-12-08 18:06:47 +01:00
Vít Ondruch
2cdb051166 Disable MJIT test cases on i686 due to issues with PCH. 2022-12-08 18:06:11 +01:00
Vít Ondruch
9819174c8d Use --enable-mkmf-verbose configuration opiton instead of patch.
https://github.com/ruby/ruby/pull/5879
2022-11-28 12:20:25 +01:00
Vít Ondruch
649a6e3083 Upgrade to Ruby 3.1.3. 2022-11-28 12:20:25 +01:00
Vít Ondruch
1d0c071aeb Revert "Re-enable package notes."
This reverts commit 588a4ae9f0, because it
causes additional issues:

https://bugzilla.redhat.com/show_bug.cgi?id=2043092#c67
2022-11-22 18:24:53 +01:00
Jun Aruga
79d75fdcdd Bypass git submodule test failure on Git >= 2.38.1. 2022-11-03 10:59:34 +01:00
Vít Ondruch
588a4ae9f0 Re-enable package notes.
The rhbz#2043092 is not resolved. Nevertheless, the generation of
package notes should not break builds of rubygem- packages anymore.
Nevertheless, the additional linker options will keep making issues for
`gem install`ed gems. Nothing new here unfortunately.
2022-09-29 09:27:19 +02:00
Jarek Prokop
c2026da175 Disable Fiddle test cases making use of FFI closure.
Fiddle::Closure object is making use of FFI closure
from libffi. When such object is created (instantiated) in Ruby,
and then the process forks on an SELinux-enabled system, the memory
will become corrupted. That is usually not a problem until the
The garbage collector sweeps the object and tries to free it, in which case the
Ruby process will fail with signal SIGABRT.

Tests in test/fiddle/test_closure.rb, test/fiddle/test_func.rb,
and test/fiddle/test_function.rb use the `Fiddle::Closure` class
directly and fiddle/test_import.rb use the class indirectly through
`bind_function` method, therefore they are disabled to prevent
introducing the problematic object into the Ruby GC during test suite
execution instead of relying on that fork and subsequent
garbage collection will not happen.

If an FFI closure object is allocated in Ruby
and the `fork` function is used afterward, the memory
pointing to the closure gets corrupted, and if Ruby GC
tries to collect the object in that state, a SIGABRT
error occurs.

The minimal Ruby reproducer for the issue is the following:
~~~
$ cat fiddle_fork.rb
require 'fiddle/closure'
require 'fiddle/struct'

Fiddle::Closure.new(Fiddle::TYPE_VOID, [])

fork { }

GC.start
~~~

We allocate an unused Closure object,
so it is free for the GC to pick up. Before we call `GC.start`
we fork the process as that corrupts the memory.

Running this with ruby-3.1.2-167.fc37.x86_64 on SELinux enabled system:
~~~
$ ruby fiddle_fork.rb
Aborted (core dumped)
~~~

Such issues may appear at random (depending on the use of forking and GC)
in larger applications that use Fiddle::Closure but can be spotted by the
following functions appearing in the coredump backtrace:
~~~
0x00007f6284d3e5b3 in dlfree (mem=<optimized out>) at ../src/dlmalloc.c:4350
0x00007f6284d6d0b1 in dealloc () from /usr/lib64/ruby/fiddle.so
0x00007f6295e432ec in finalize_list () from /lib64/libruby.so.3.1
0x00007f6295e43420 in finalize_deferred.lto_priv () from /lib64/libruby.so.3.1
0x00007f6295e4ff1c in gc_start_internal.lto_priv () from /lib64/libruby.so.3.1
~~~

Possible solutions to prevent Ruby from crashing:
* Do not use Fiddle::Closure.
* Use the Fiddle::Closure object only in isolated subprocess that
  will not fork further.
* Enable static trampolines in libffi as noted in bugzilla comment:
  <https://bugzilla.redhat.com/show_bug.cgi?id=2040380#c9>

See related discussion on
<https://bugzilla.redhat.com/show_bug.cgi?id=2040380>

Ruby upstream ticket:
<https://bugs.ruby-lang.org/issues/18914>

Ruby Fiddle ticket:
<https://github.com/ruby/fiddle/issues/102>
2022-09-02 14:54:35 +02:00
Jun Aruga
3f106c188e Add IRB to ruby-bundled-gems recommends.
Resolves: rhbz#2120562
2022-08-29 15:11:15 +02:00
Jun Aruga
bf921512e2 Make RDoc soft dependnecy in IRB.
Resolves: rhbz#2119964
2022-08-29 15:05:44 +02:00
Jun Aruga
ad7f78b5c8 Fix tests with Europe/Amsterdam pre-1970 time on tzdata version 2022b.
Resolves: rhbz#2120354
2022-08-24 15:58:40 +02:00
Jarek Prokop
f93afdebdd Fix Ruby build failing due to unremovable tmp subdirectory.
RPM 4.18.0-beta1 or later versions remove the build directory
automatically, the build fails on removing temporary directories with
the missing 'w' bit.

RubyGems contain this patch since version 3.3.8.
This was merged to ruby_3_1 branch in upstream ruby, but it is not
included in the v3_1_2 tag, so new Ruby 3.1 release should contain this
change.

Relevant RPM upstream PR: https://github.com/rpm-software-management/rpm/pull/2080
Relevant bug: https://bugzilla.redhat.com/show_bug.cgi?id=2105393
2022-07-25 11:55:57 +02:00
Fedora Release Engineering
e2951e6856 Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-23 01:10:40 +00:00
Jarek Prokop
ca94aff023 Define the GC compaction support during run time.
Previous commit changed GC compaction methods to not be implemented
when not supported. However, that commit only does compile time checks,
but there are additional compaction support checks during run time.

This commit changes it so that GC compaction methods aren't defined
also during run time if the platform does not support GC compaction.

The patch is manually backported from following change set:
https://github.com/ruby/ruby/pull/6019
2c19086323

To apply the patch included with this commit,
first apply `ruby-3.2.0-define-unsupported-gc-compaction-methods-as-rb_f_notimplement.patch`
and then apply the `ruby-3.2.0-detect_compaction_support_during_runtime.patch`.

Related upstream issue: https://bugs.ruby-lang.org/issues/18829
2022-06-24 14:09:42 +02:00
Jarek Prokop
b7b5473796 Define compaction methods as rb_f_notimplement on unsupported platforms.
The patch implements the methods as rb_f_notimplement.
To test for compaction users can now use `GC.respond_to?(:compact)`.

The upstream patch relies on the macro `GC_COMPACTION_SUPPORTED`
that is defined when the `__wasi__` is false. The define is defined by
an arch conditional in the specfile, which is not optimal but works in our case.
663833b08f
https://bugs.ruby-lang.org/issues/18829

This also requires regenerating the gc.rbinc and miniprelude.c
since the patch touches gc.rb. This patch is available in
ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch.

To regenerate the gc.rbinc and miniprelude.c files patch:
~~~
tar -Jxvf ./ruby-3.1.2.tar.xz
git clone https://github.com/ruby/ruby.git
cd ruby && git checkout v3_1_2
patch -p1 < ../ruby-3.2.0-define-unsupported-gc-compaction-methods-as-rb_f_notimplement.patch
./autogen.sh && ./configure
make gc.rbinc miniprelude.c
cd ..
diff -u {ruby-3.1.2,ruby}/gc.rbinc > ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch
diff -u {ruby-3.1.2,ruby}/miniprelude.c >> ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch
~~~

Uptream bug: https://bugs.ruby-lang.org/issues/18779
Upstream PR: https://github.com/ruby/ruby/pull/5934
2022-06-14 12:59:25 +02:00
Jun Aruga
2c91b113bb Update a comment about make verbose option, dropping Q= explanation.
According to the <https://bugs.ruby-lang.org/issues/18756>, the `Q=` is not
recommended. The `V=1` is recommended to output for the verbose mode.
The `make V=1` suppresses some logs that `make` without `V=1` outputs rather
than just adding verbose logs.

While the `V=1 ECHO0=echo` is more equivalent with `Q=`, the
`make V=1 ECHO0=echo` doesn't really output meaningful logs additionally.
So, the `make V=1` is the best option for us to check the compiler flags.
2022-05-12 11:50:01 +02:00
Jun Aruga
03e8cec9fe Drop Q= in make options.
Because the `%make_build` macro includes the `V=1`. Note there is no actual
difference of build.log between before and after this commit.

```
$ rpm --eval %make_build
/usr/bin/make -O -j8 V=1 VERBOSE=1
```
2022-04-29 16:01:56 +02:00
Vít Ondruch
c2061af620 Use upstream patch for correct build of gem extensions. 2022-04-14 13:50:23 +02:00
Vít Ondruch
09d0e79c2b Upgrade to Ruby 3.1.2. 2022-04-14 13:50:23 +02:00
Vít Ondruch
22d91a0910 Properly build binary gem extensions.
Because the gem extensions were built in `%{buildroot}` they referred
`BUILDROOT` directory, which would be under normal circumstances
reported by RPM, but there was a bug in RPM due to changes in grep:

https://github.com/rpm-software-management/rpm/issues/1968
2022-04-04 12:30:05 +02:00
Jun Aruga
796a198176 Add Bundler tests.
* Add `make test-bundler-parallel` executed on the upstream CI.
  See <41a48535d1/.github/workflows/ubuntu.yml (L22)>.
* The tests are disabled as a default, as it requires the internet.
  Run the Bundler tests as follows.
  ```
  $ mock --with bundler_tests ruby-3.1.0-161.fc37.src.rpm
  ```
* Fix a test for `bin/bundle update --bundler` in `make test-bundler`.
2022-03-22 19:10:01 +01:00
Jun Aruga
aee17a2180 ruby.rpmlintrc: Add a filter for "E: shared-lib-without-dependency-information".
Add a filter for "E: shared-lib-without-dependency-information" for
rpmlint 1.11 compatibility in Zuul CI.
2022-03-15 23:15:53 +01:00
Jun Aruga
df8cc89df4 ruby.rpmlintrc: Recover the filter to ignore a false positive missing-call-to-chdir-with-chroot error.
The filter was deleted at the b0ce095f6d . But it
is still needed to pass Zuul CI.
2022-03-15 23:15:49 +01:00
Jun Aruga
9e774fba70 ruby.rpmlintrc: Ignore zero-length error for gem.build_complete file.
This error is gone as false positive in rpmlint 2.0+. However the rpmlint
version on Zuul CI running on the Fedora 34 container is still 1.11. After Zuul
CI is upgraded to Fedora 35+ container, and uses the rpmlint 2, we can notice
this filter is not used by "E: unused-rpmlintrc-filter" error, and remove it.
2022-03-15 23:15:44 +01:00
Vít Ondruch
74983bcd56 Upgrade to Ruby 3.1.1. 2022-03-15 13:26:14 +01:00
Jun Aruga
67d5a7b3c6 Revert "Remove colon from load call."
This is for a compatibility of Zuul CI still using RPM 4.16 on F34.

This reverts commit 46ee70614f.
2022-03-14 11:28:52 +01:00
Vít Ondruch
204bab4f7f Prevent segfaults running with SystemTap. 2022-02-10 14:14:12 +01:00
Vít Ondruch
8157cd4820 Revert "Temporary bump rubygem-json release."
This reverts commit 1ff09bed2b.
2022-01-26 15:33:43 +01:00
Vít Ondruch
1ff09bed2b Temporary bump rubygem-json release.
This allow to rebuild independent rubygem-json package, which would have
otherwise higher release and caused issues with build of other packages.
2022-01-26 09:54:45 +01:00
Vít Ondruch
b0ce095f6d Upgrade to Ruby 3.1.0.
For details of the evolution please check `private-ruby-3.1` branch.
2022-01-26 09:54:13 +01:00
Vít Ondruch
a51a61214c Drop Puma workaround.
This is considered as Puma issue which should be addressed in latest
release:

https://github.com/puma/puma/issues/2753
2022-01-25 18:25:09 +01:00
Vít Ondruch
2da7a540e7 Update OpenSSL 3 compatibility patches.
This replaces the parts of the original PR with official patches which
landed in [ruby/openssl](https://github.com/ruby/openssl) repository and
should reflect the state of OpenSSL 3 support in Ruby 3.1.
2022-01-25 18:24:19 +01:00
Vít Ondruch
a0bcb33eaa Disable package notes to prevent rubygem- build breakage.
The embedded linker flags breaks build of rubygem- packages with binary
extension:

~~~
gcc -shared -o nio4r_ext.so bytebuffer.o monitor.o nio4r_ext.o selector.o -L. -L/usr/lib64 -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/.package_note-rubygem-nio4r-2.5.2-6.fc36.x86_64.ld -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -Wl,-dT,/builddir/build/BUILD/.package_note-ruby-0.15.2-157.fc36.x86_64.ld  -m64  -lruby  -lm   -lc
/usr/bin/ld: cannot open linker script file /builddir/build/BUILD/.package_note-ruby-0.15.2-157.fc36.x86_64.ld: No such file or directory
~~~
2022-01-20 17:27:08 +01:00
Vít Ondruch
a28556f684 Fix segfault in TestArray#test_sample on s390x.
~~~
... snip ...

[ 3104/21226] TestArray#test_sample/builddir/build/BUILD/ruby-3.0.3/test/ruby/test_array.rb:2871: [BUG] Segmentation fault at 0x00000000c04fb000
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [s390x-linux]
-- Control frame information -----------------------------------------------
c:0031 p:---- s:0176 e:000175 CFUNC  :srand
c:0030 p:0011 s:0171 e:000170 METHOD /builddir/build/BUILD/ruby-3.0.3/test/ruby/test_array.rb:2871
c:0029 p:0052 s:0165 e:000164 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1283
c:0028 p:0065 s:0159 e:000158 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1330
c:0027 p:0013 s:0150 e:000149 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit/testcase.rb:18
c:0026 p:0077 s:0145 e:000144 BLOCK  /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:979 [FINISH]
c:0025 p:---- s:0138 e:000137 CFUNC  :map
c:0024 p:0006 s:0134 E:0012c8 BLOCK  /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:972
c:0023 p:0186 s:0130 E:000ba0 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:999
c:0022 p:0042 s:0118 E:000888 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1136
c:0021 p:0010 s:0111 E:0007a0 BLOCK  /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:627 [FINISH]
c:0020 p:---- s:0105 e:000104 CFUNC  :each
c:0019 p:0054 s:0101 E:001588 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:625
c:0018 p:0008 s:0094 E:001eb8 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:662
c:0017 p:0140 s:0087 E:0011a8 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:908
c:0016 p:0016 s:0074 E:001ca8 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1073
c:0015 p:0005 s:0069 E:000710 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1147
c:0014 p:0006 s:0065 E:000438 BLOCK  /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1134 [FINISH]
c:0013 p:---- s:0061 e:000060 CFUNC  :each
c:0012 p:0047 s:0057 E:0022b8 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1133
c:0011 p:0013 s:0052 E:000288 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1121
c:0010 p:0008 s:0047 E:000c70 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:847
c:0009 p:0008 s:0041 E:0008d0 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:695
c:0008 p:0015 s:0035 E:001f08 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:34
c:0007 p:0006 s:0030 E:0003c8 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1175
c:0006 p:0032 s:0025 E:000e80 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1245
c:0005 p:0009 s:0021 E:0018b8 METHOD /builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1249
c:0004 p:0172 s:0016 E:0001b8 TOP    /builddir/build/BUILD/ruby-3.0.3/tool/test/runner.rb:23 [FINISH]
c:0003 p:---- s:0011 e:000010 CFUNC  :require_relative
c:0002 p:0092 s:0006 E:001bf0 EVAL   ./test/runner.rb:11 [FINISH]
c:0001 p:0000 s:0003 E:0004f0 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
./test/runner.rb:11:in `<main>'
./test/runner.rb:11:in `require_relative'
/builddir/build/BUILD/ruby-3.0.3/tool/test/runner.rb:23:in `<top (required)>'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1249:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1245:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1175:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:34:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:695:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:847:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1121:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1133:in `_run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1133:in `each'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1134:in `block in _run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1147:in `run_tests'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1073:in `_run_anything'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:908:in `_run_anything'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:662:in `_run_suites'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:625:in `_run_suites'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:625:in `each'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:627:in `block in _run_suites'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1136:in `_run_suite'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:999:in `_run_suite'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:972:in `block in _run_suite'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:972:in `map'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:979:in `block (2 levels) in _run_suite'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit/testcase.rb:18:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/minitest/unit.rb:1330:in `run'
/builddir/build/BUILD/ruby-3.0.3/tool/lib/test/unit.rb:1283:in `run_test'
/builddir/build/BUILD/ruby-3.0.3/test/ruby/test_array.rb:2871:in `test_sample'
/builddir/build/BUILD/ruby-3.0.3/test/ruby/test_array.rb:2871:in `srand'
-- C level backtrace information -------------------------------------------
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_print_backtrace+0x1c) [0x3ffab964c5c] vm_dump.c:758
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_vm_bugreport.constprop.0+0x4ba) [0x3ffab977f0a] vm_dump.c:998
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_bug_for_fatal_signal+0xb2) [0x3ffab7b2252] error.c:786
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(sigsegv+0x58) [0x3ffab8d2fb8] signal.c:963
[0x3ffabb7e490]
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_free_tmp_buffer+0x4) [0x3ffab7d1114] gc.c:11047
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rand_init+0x122) [0x3ffab896892] random.c:387
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_f_srand+0x6e) [0x3ffab8975fe] random.c:873
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_call_cfunc_with_frame+0x170) [0x3ffab9421f0] vm_insnhelper.c:2931
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_sendish+0x53a) [0x3ffab94659a] vm_insnhelper.c:4532
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_exec_core.lto_priv.0+0xe6) [0x3ffab947d16] insns.def:789
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_vm_exec+0x1ee) [0x3ffab96129e] vm.c:2172
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_yield+0xaa) [0x3ffab951a6a] vm.c:1398
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_ary_collect.lto_priv.0+0x6a) [0x3ffab742d6a] array.c:3635
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_call_cfunc_with_frame+0x170) [0x3ffab9421f0] vm_insnhelper.c:2931
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_sendish+0x53a) [0x3ffab94659a] vm_insnhelper.c:4532
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_exec_core.lto_priv.0+0x21c0) [0x3ffab949df0] insns.def:770
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_vm_exec+0x1ee) [0x3ffab96129e] vm.c:2172
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_yield+0xaa) [0x3ffab951a6a] vm.c:1398
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_ary_each+0x4c) [0x3ffab742aac] array.c:2523
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_call_cfunc_with_frame+0x170) [0x3ffab9421f0] vm_insnhelper.c:2931
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_call_method_each_type+0x530) [0x3ffab942d20] vm_insnhelper.c:3400
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_sendish+0x53a) [0x3ffab94659a] vm_insnhelper.c:4532
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_exec_core.lto_priv.0+0x21c0) [0x3ffab949df0] insns.def:770
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_vm_exec+0x1ee) [0x3ffab96129e] vm.c:2172
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_yield+0xaa) [0x3ffab951a6a] vm.c:1398
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_ary_each+0x4c) [0x3ffab742aac] array.c:2523
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_call_cfunc_with_frame+0x170) [0x3ffab9421f0] vm_insnhelper.c:2931
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_call_method_each_type+0x530) [0x3ffab942d20] vm_insnhelper.c:3400
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_sendish+0x53a) [0x3ffab94659a] vm_insnhelper.c:4532
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_exec_core.lto_priv.0+0x21c0) [0x3ffab949df0] insns.def:770
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_vm_exec+0x1ee) [0x3ffab96129e] vm.c:2172
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(require_internal.lto_priv.0+0xbc6) [0x3ffab809be6] load.c:1109
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_require_string+0x48) [0x3ffab809db8] load.c:1186
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_call_cfunc_with_frame+0x170) [0x3ffab9421f0] vm_insnhelper.c:2931
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_sendish+0x53a) [0x3ffab94659a] vm_insnhelper.c:4532
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(vm_exec_core.lto_priv.0+0xe6) [0x3ffab947d16] insns.def:789
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_vm_exec+0x1ee) [0x3ffab96129e] vm.c:2172
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(rb_ec_exec_node+0x10c) [0x3ffab7b71ac] eval.c:317
/builddir/build/BUILD/ruby-3.0.3/libruby.so.3.0.3(ruby_run_node+0x70) [0x3ffab7b72c0] eval.c:375
[0x2aa26e811f0]
[0x3ffab4b3872]
[0x3ffab4b3950]
[0x2aa26e81250]

... snip ...
~~~
2022-01-20 11:20:01 +01:00
Vít Ondruch
b6d9b2acd1 Disable some Fiddle test by libffi-3.4.2. 2022-01-19 17:08:19 +01:00
Vít Ondruch
46ee70614f Remove colon from load call.
This is not needed by RPM 4.17+ and might improve backwared compatibilty
with RHEL 7, where the original LUA implementation of `load` macro was
used.
2022-01-19 17:07:44 +01:00
Jun Aruga
b24ebf5ec1 Remove the patch applied to pass the test/fiddle/test_import.rb on PPC.
In Ruby 3.0.3, a new logic with the hard-coded "libc.so.6" to detect glibc
works on PPC, both Power 8 and 9.
See <https://bugs.ruby-lang.org/issues/12666#note-13>.

Note the logic also fixes the following error on a Power 9 environment where
the path is `/lib64/glibc-hwcaps/power9/libc-2.28.so`.

```
/builddir/build/BUILD/ruby-2.6.9/.ext/common/fiddle/import.rb:299:in `import_function': cannot find the function: strcpy() (Fiddle::DLError)
    from /builddir/build/BUILD/ruby-2.6.9/.ext/common/fiddle/import.rb:172:in `extern'
    from /builddir/build/BUILD/ruby-2.6.9/test/fiddle/test_import.rb:17:in `<module:LIBC>'
    from /builddir/build/BUILD/ruby-2.6.9/test/fiddle/test_import.rb:10:in `<module:Fiddle>'
    from /builddir/build/BUILD/ruby-2.6.9/test/fiddle/test_import.rb:9:in `<top (required)>'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:958:in `require'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:958:in `block in non_options'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:952:in `each'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:952:in `non_options'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:64:in `process_args'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:130:in `process_args'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:1136:in `process_args'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:1141:in `run'
    from /builddir/build/BUILD/ruby-2.6.9/test/lib/test/unit.rb:1148:in `run'
    from ./test/runner.rb:33:in `<main>'
```
2022-01-11 11:50:01 +01:00
Miro Hrončok
08a1249d7f Rebuilt for https://fedoraproject.org/wiki/Changes/LIBFFI34 2022-01-10 11:55:34 +01:00
Vít Ondruch
5d3688479a Fix loading of default gems.
Resolves: rhbz#2027099
2021-12-10 17:06:26 +01:00
Vít Ondruch
dbe75d1cb5 Fix wrong version in changelog. 2021-12-08 12:10:25 +01:00
Vít Ondruch
d584a5bfb3 Upgrade to Ruby 3.0.3. 2021-11-25 17:46:48 +01:00
Vít Ondruch
c4f8814a93 Fix OpenSSL 3.0 compatibility.
Resolves: rhbz#2021922
2021-11-22 18:21:04 +01:00
Jun Aruga
78a9fbc351 Add AC_PROG_CC to make C++ compiler dependency optional on autoconf >= 2.70.
Resolves: rhbz#1999479
2021-10-04 12:23:30 +02:00
Sahana Prasad
d75a6c86f9 Rebuilt with OpenSSL 3.0.0 2021-09-14 19:13:53 +02:00
Vít Ondruch
11a27766bd Load user installed RubyGems plugins. 2021-08-24 18:23:20 +02:00
Vít Ondruch
1170d812fe Enable LTO. 2021-08-24 17:37:08 +02:00
Fedora Release Engineering
089c0a1928 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-07-23 11:43:38 +00:00
Jarek Prokop
63065e7db7 Upgrade to Ruby 3.0.2.
- Fix command injection vulnerability in RDoc.
  Resolves: CVE-2021-31799
- Fix FTP PASV command response can cause Net::FTP to connect to arbitrary host.
  Resolves: CVE-2021-31810
- Fix StartTLS stripping vulnerability in Net::IMAP.
  Resolves: CVE-2021-32066
- Fix dependencies of gems with explicit source installed from a different
  source.
  Resolves: CVE-2020-36327
2021-07-15 14:02:23 +02:00
Timm Bäder
6b2ff68f33 Pass ldflags to gem install
We have them, so we may as well pass them. This also fixes building ruby
gems with clang.
2021-05-31 10:25:26 +00:00
Jun Aruga
e6a3dff909 ruby.rpmlintrc: Remove prefix match.
A result of ruby.spec file depends on how the spec file is called by rpmlint.

```
$ rpmlint ruby.spec
ruby.spec:20: E: use-of-RPM_SOURCE_DIR
..
0 packages and 1 specfiles checked; 3 errors, 4 warnings.

$ rpmlint ./ruby.spec
./ruby.spec:20: E: use-of-RPM_SOURCE_DIR
..
0 packages and 1 specfiles checked; 3 errors, 4 warnings.
```
2021-05-18 15:40:11 +02:00
Jun Aruga
a09dbbec17 ruby.rpmlintrc: Ignore a shared-lib-without-dependency-information error.
Nothing referred and no dependency information should be no problem.

Ignore the following error.

```
ruby-libs.x86_64: E: shared-lib-without-dependency-information /usr/lib64/ruby/enc/gb2312.so
```
2021-05-18 15:40:05 +02:00
Jun Aruga
882d68b75c ruby.rpmlintrc: Ignore a false positive missing-call-to-chdir-with-chroot error.
The `chroot` in the `dir.c` is just used as a Ruby binding `Dir.chroot`
for the function.

Ignore the following error.

```
ruby-libs.x86_64: E: missing-call-to-chdir-with-chroot /usr/lib64/libruby.so.3.0.1
```
2021-05-18 15:40:00 +02:00
Jun Aruga
26bc979446 ruby.rpmlintrc: Ignore the non-executable-script errors in bundled gems.
The bundled gem files permissions are overridden as 644 by `make install`.
Ignore following errors in bundled gems.

```
rubygem-power_assert.noarch: E: non-executable-script /usr/share/gems/gems/power_assert-1.2.0/bin/console 644 /usr/bin/env ruby
rubygem-power_assert.noarch: E: non-executable-script /usr/share/gems/gems/power_assert-1.2.0/bin/setup 644 /usr/bin/env bash
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/bundle 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/console 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/rake 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/rdoc 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/rubocop 644 /usr/bin/env ruby
rubygem-rake.noarch: E: non-executable-script /usr/share/gems/gems/rake-13.0.3/bin/setup 644 /usr/bin/env bash
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/annotate-with-rdoc 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/console 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/query-rdoc 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/rbs-prof 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/setup 644 /usr/bin/env bash
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/sort 644 /usr/bin/env ruby
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/steep 644 /bin/sh
rubygem-rbs.noarch: E: non-executable-script /usr/share/gems/gems/rbs-1.0.4/bin/test_runner.rb 644 /usr/bin/env ruby
rubygem-test-unit.noarch: E: non-executable-script /usr/share/gems/gems/test-unit-3.3.7/test/run-test.rb 644 /usr/bin/env ruby
```
2021-05-18 15:39:53 +02:00
Jun Aruga
fbaee91204 ruby.rpmlintrc: Ignore non executable template files for Bundler.
The template files do not have to have executable bits.
Ignore the following errors.

```
rubygem-bundler.noarch: E: non-executable-script /usr/share/gems/gems/bundler-2.2.15/lib/bundler/templates/Executable 644 /usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
rubygem-bundler.noarch: E: non-executable-script /usr/share/gems/gems/bundler-2.2.15/lib/bundler/templates/Executable.bundler 644 /usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
rubygem-bundler.noarch: E: non-executable-script /usr/share/gems/gems/bundler-2.2.15/lib/bundler/templates/Executable.standalone 644 /usr/bin/env <%= Bundler.settings[:shebang] || RbConfig::CONFIG["ruby_install_name"] %>
rubygem-bundler.noarch: E: non-executable-script /usr/share/gems/gems/bundler-2.2.15/lib/bundler/templates/newgem/bin/console.tt 644 /usr/bin/env ruby
rubygem-bundler.noarch: E: non-executable-script /usr/share/gems/gems/bundler-2.2.15/lib/bundler/templates/newgem/bin/setup.tt 644 /usr/bin/env bash
rubygem-bundler.noarch: E: non-executable-script /usr/share/gems/gems/bundler-2.2.15/lib/bundler/templates/newgem/exe/newgem.tt 644 /usr/bin/env ruby
```
2021-05-18 15:39:38 +02:00
Jun Aruga
1b641ac57f Fix FTBFS due to an incompatible load.
The FTBFS has started to happen with rpm-4.16.90-0.git15395.2.fc35.

root.log

```
DEBUG util.py:444:  error: line 116: Unknown tag: /chroot_tmpdir/srpm_unpacked/SOURCES/macros.ruby
```

As the `%{?load:...}` is undocumented, it is gone.

https://github.com/rpm-software-management/rpm/issues/1669
2021-05-05 14:15:31 +02:00
Vít Ondruch
9e656cf658 Upgrade to Ruby 3.0.1. 2021-04-06 12:57:56 +02:00
Vít Ondruch
fd8c8ee765 Remove IRB dependency from rubygem-rdoc.
The IRB dependency was dropped in RDoc 6.0.0 already, but nobody
noticed:

https://github.com/ruby/rdoc/pull/512
2021-04-01 13:10:34 +02:00
Jun Aruga
4108f57be7 Ignore the rpmlint "W: unversioned-explicit-provides".
Ignore the following warnings for bundled ccan-* libraries.

```
ruby.spec:231: W: unversioned-explicit-provides bundled(ccan-build_assert)
ruby.spec:232: W: unversioned-explicit-provides bundled(ccan-check_type)
ruby.spec:233: W: unversioned-explicit-provides bundled(ccan-container_of)
ruby.spec:234: W: unversioned-explicit-provides bundled(ccan-list)
ruby.src:231: W: unversioned-explicit-provides bundled(ccan-build_assert)
ruby.src:232: W: unversioned-explicit-provides bundled(ccan-check_type)
ruby.src:233: W: unversioned-explicit-provides bundled(ccan-container_of)
ruby.src:234: W: unversioned-explicit-provides bundled(ccan-list)
```
2021-03-24 14:33:39 +01:00
Jun Aruga
b65d1d3090 Ignore the rpmlint "E: use-of-RPM_SOURCE_DIR".
Ignore the following errors.

```
ruby.spec:20: E: use-of-RPM_SOURCE_DIR
ruby.src:20: E: use-of-RPM_SOURCE_DIR
```
2021-03-24 14:33:24 +01:00
Jun Aruga
303495d1bf Add ruby.rpmlintrc.
Ignore the false positive errors and warnings by the
`rpmlint --file ruby.rpmlintrc`, that is executed by Zuul CI.

You can run the command on your local like this.

```
$ rpmlint --file ruby.rpmlintrc ruby.spec /var/lib/mock/fedora-rawhide-x86_64/result/*.rpm
```

The `rpmlint` without `--file` option shows the original result.
2021-03-24 14:19:53 +01:00
Vít Ondruch
dae90ef93d Summary should not end with . 2021-03-22 10:10:27 +01:00
Vít Ondruch
cb0039f53c Remove excesive space. 2021-03-05 14:06:28 +01:00
Vít Ondruch
9b149e59e4 Properly support DWARF5 debug information.
Resolves: rhbz#1920533
2021-03-03 11:26:27 +01:00
Vít Ondruch
2bc8b3d5d5 Apply patch fixing flaky excon test suite. 2021-03-02 11:05:16 +01:00
Vít Ondruch
3210f66fb1 Avoid ruby-spec to be stuck in "C-API Kernel function rb_rescue2". 2021-02-16 10:00:33 +01:00
Vít Ondruch
35f28c9a68 Use proper path for plugin wrappers. 2021-01-27 14:03:19 +01:00
Vít Ondruch
b7229da165 Disable test which started to fail presumably after move to DWARF5
https://bugzilla.redhat.com/show_bug.cgi?id=1920533

Unfortunately, these used to be problematic already before:
https://bugs.ruby-lang.org/issues/13758
2021-01-27 14:03:19 +01:00
Vít Ondruch
b3e2d7fc60 Add missing rubygem- prefix for bundled provide.
The `bundled()` provide name must corresponded with package name. This
was omited due to mistake probably.
2021-01-26 12:32:40 +01:00
Vít Ondruch
c7513cd67c Bundle OpenSSL into StdLib.
Symlinks to StdLib provided to preserve `--disable-gems` functionality
together with `require_relative` cause double loading issues [1], e.g.:

~~~
$ ruby --disable-gems -e 'require "openssl"; require "openssl/digest"'
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::MD4
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of MD4 was here
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::MD5
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of MD5 was here
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::RIPEMD160
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of RIPEMD160 was here
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::SHA1
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of SHA1 was here
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::SHA224
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of SHA224 was here
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::SHA256
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of SHA256 was here
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::SHA384
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of SHA384 was here
/usr/share/ruby/openssl/digest.rb:45: warning: already initialized constant OpenSSL::Digest::SHA512
/usr/share/gems/gems/openssl-2.2.0/lib/openssl/digest.rb:45: warning: previous definition of SHA512 was here
/usr/share/ruby/openssl/digest.rb:52:in `<class:Digest>': superclass mismatch for class Digest (TypeError)
	from /usr/share/ruby/openssl/digest.rb:16:in `<module:OpenSSL>'
	from /usr/share/ruby/openssl/digest.rb:15:in `<top (required)>'
	from -e:1:in `require'
	from -e:1:in `<main>'
~~~

We could maintain a downstream patch reverting the `require_relative`,
but given that how much troubles the extracted gems cause, it'll be
better to keep them bundled. This will provide similar experience to
upstream and prevent similar issues.

[1]: https://bugs.ruby-lang.org/issues/16978#note-11
2021-01-26 11:57:47 +01:00
Jun Aruga
cdeff9e00a Refactor small issues. 2021-01-18 19:03:49 +01:00
Vít Ondruch
1e72602218 Fix SEGFAULT in rubygem-shoulda-matchers test suite. 2021-01-16 11:44:56 +01:00
Vít Ondruch
0256efd992 Provide gem.build_complete file for binary gems.
When the `gem.build_complete` file is not present, Bundler treats the
package as uninstalled, therefore leaves it out from the dependency
resolution with error such as:

~~~
Could not find gem 'openssl', which is required by gem 'net-ssh', in any of the sources.
~~~

[1] 1969e8adfc/bundler/lib/bundler/source/rubygems.rb (L353-L384)
2021-01-12 18:20:07 +01:00
Vít Ondruch
64975231d1 Re-enable test suite.
It was disabled by mistake in fcc584306b
when I was trying to come up with fix for armv7hl.
2021-01-11 10:19:35 +01:00
Vít Ondruch
f63d6e5cd4 Remove time from changelog
It makes some tools to complain about changelog ordering.
2021-01-11 09:27:24 +01:00
Vít Ondruch
0e7ccf2b47 ruby-default-gems have to depend on rubygem(io-console) due to reline.
This fixes IRB failures:

~~~
$ irb
/usr/share/rubygems/rubygems/specification.rb:1398:in `rescue in block in activate_dependencies': Could not find 'io-console' (~> 0.5) among 76 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/builddir/.local/share/gem/ruby:/usr/share/gems:/usr/local/share/gems' at: /usr/share/gems/specifications/reline-0.2.0.gemspec, execute `gem env` for more information
	from /usr/share/rubygems/rubygems/specification.rb:1395:in `block in activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `each'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1366:in `activate'
	from /usr/share/rubygems/rubygems/specification.rb:1402:in `block in activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `each'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1366:in `activate'
	from /usr/share/rubygems/rubygems.rb:302:in `block in activate_bin_path'
	from /usr/share/rubygems/rubygems.rb:301:in `synchronize'
	from /usr/share/rubygems/rubygems.rb:301:in `activate_bin_path'
	from /usr/bin/irb:23:in `<main>'
/usr/share/rubygems/rubygems/dependency.rb:307:in `to_specs': Could not find 'io-console' (~> 0.5) among 76 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/builddir/.local/share/gem/ruby:/usr/share/gems:/usr/local/share/gems' , execute `gem env` for more information
	from /usr/share/rubygems/rubygems/specification.rb:1396:in `block in activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `each'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1366:in `activate'
	from /usr/share/rubygems/rubygems/specification.rb:1402:in `block in activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `each'
	from /usr/share/rubygems/rubygems/specification.rb:1384:in `activate_dependencies'
	from /usr/share/rubygems/rubygems/specification.rb:1366:in `activate'
	from /usr/share/rubygems/rubygems.rb:302:in `block in activate_bin_path'
	from /usr/share/rubygems/rubygems.rb:301:in `synchronize'
	from /usr/share/rubygems/rubygems.rb:301:in `activate_bin_path'
	from /usr/bin/irb:23:in `<main>'
~~~
2021-01-08 18:49:16 +01:00
Vít Ondruch
071cbd0906 Rename patch to the correct name. 2021-01-08 16:14:30 +01:00
Vít Ondruch
fcc584306b Fix SEGFAULT preventing rubygem-unicode to build on armv7hl. 2021-01-08 15:38:01 +01:00
Vít Ondruch
9a03f61609 Add %{gem_plugin} convenience macro.
This allows easy plugin stub ownership for RubyGems plugin packages.
2021-01-06 14:26:09 +01:00
Vít Ondruch
15d70f8b4a Properly own RubyGems plugin directory.
RubyGems 3.2.0 rewored their plugins system for improvement performance
[[1]]. Each RubyGems plugins has now generated loader stub during
installation. This directory needs to have proper ownership.

[1]: https://github.com/rubygems/rubygems/pull/3108
2021-01-06 14:26:09 +01:00
Vít Ondruch
f11a9b4fe3 Upgrade to Ruby 3.0.0.
* Extract RSS and REXML into separate subpackages, because they were moved from
  default gems to bundled gems.

* Obsolete Net::Telnet and XMLRPC packages, because they were dropped from Ruby.

The detailed changelog leading to this release is preserved in
private-ruby-3.0 branch.
2021-01-04 16:42:55 +01:00
Pavel Valena
2a352348bd Add Recommends: redhat-rpm-config to devel subpackage
as it's needed for building (gem install ...) gems with binary extensions.

This is a workaround to have /usr/lib/rpm/redhat/redhat-hardened-cc1
on the system, as same CFLAGS are reused from when Ruby was built.

Resolves: rhbz#1905222
2020-12-17 02:53:30 +01:00
25 changed files with 1704 additions and 1646 deletions

3
.gitignore vendored
View File

@ -1,4 +1,3 @@
/*/
/ruby-2.*.tar.bz2
/ruby-2.*.tar.xz
/ruby-*.tar.xz
/*.rpm

View File

@ -2,13 +2,31 @@
%gem_dir %{_datadir}/gems
%gem_archdir %{_libdir}/gems
# %gem_name_version - Provides gem_name-version string.
#
# Usage: %gem_name_version [custom_gem_name]
#
# Prints gem_name-version string, by default joining %gem_name, %version and
# %prerelease macros. When [custom_gem_name] is provided, the
# custom_gem_name is joined with %custom_gem_name_version macro which needs
# to be predefined. Please note that for the version macros are the dashes
# replaced by underscores.
#
%gem_name_version() %{?1}%{!?1:%{gem_name}}-%{?1:%{expand:%{%{gsub %{1} - _}_version}}}%{!?1:%{version}}%{?prerelease}
# Common gem locations and files.
%gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}%{?prerelease}
%gem_extdir_mri %{gem_archdir}/%{name}/%{gem_name}-%{version}%{?prerelease}
%gem_libdir %{gem_instdir}/lib
%gem_cache %{gem_dir}/cache/%{gem_name}-%{version}%{?prerelease}.gem
%gem_spec %{gem_dir}/specifications/%{gem_name}-%{version}%{?prerelease}.gemspec
%gem_docdir %{gem_dir}/doc/%{gem_name}-%{version}%{?prerelease}
#
# These macros leverages %gem_name_version macro and accepts custom gem_name.
#
# -d Use default gem install location.
#
%gem_instdir() %{gem_dir}/gems/%{gem_name_version %{?1}}
%gem_extdir_mri() %{gem_archdir}/%{name}/%{gem_name_version %{?1}}
%gem_libdir() %{gem_instdir %{?1}}/lib
%gem_cache() %{gem_dir}/cache/%{gem_name_version %{?1}}.gem
%gem_spec(d) %{gem_dir}/specifications%{?-d:/default}/%{gem_name_version %{?1}}.gemspec
%gem_docdir() %{gem_dir}/doc/%{gem_name_version %{?1}}
%gem_plugin() %{gem_dir}/plugins/%{?1}%{!?1:%{gem_name}}_plugin.rb
# %gem_install - Install gem into appropriate directory.
@ -21,7 +39,7 @@
%gem_install(d:n:) \
mkdir -p %{-d*}%{!?-d:.%{gem_dir}} \
\
CONFIGURE_ARGS="--with-cflags='%{optflags}' --with-cxxflags='%{optflags}' $CONFIGURE_ARGS" \\\
CONFIGURE_ARGS="--with-cflags='%{optflags}' --with-cxxflags='%{optflags}' --with-ldflags='%{build_ldflags}' $CONFIGURE_ARGS" \\\
gem install \\\
-V \\\
--local \\\

View File

@ -87,41 +87,51 @@ module Gem
# Remove methods we are going to override. This avoids "method redefined;"
# warnings otherwise issued by Ruby.
remove_method :operating_system_defaults if method_defined? :operating_system_defaults
remove_method :default_dir if method_defined? :default_dir
remove_method :default_specifications_dir if method_defined? :default_specifications_dir
remove_method :default_path if method_defined? :default_path
remove_method :default_bindir if method_defined? :default_bindir
remove_method :default_ext_dir_for if method_defined? :default_ext_dir_for
##
# Regular user installs into user directory, root manages /usr/local.
def operating_system_defaults
unless opt_build_root?
options = if Process.uid == 0
"--install-dir=#{Gem.default_dirs[:local][:gem_dir]} --bindir #{Gem.default_dirs[:local][:bin_dir]}"
else
"--user-install --bindir #{File.join [Dir.home, 'bin']}"
end
{"gem" => options}
else
{}
end
end
##
# RubyGems default overrides.
def default_dir
Gem.default_dirs[:system][:gem_dir]
if opt_build_root?
Gem.default_dirs[:system][:gem_dir]
elsif Process.uid == 0
Gem.default_dirs[:local][:gem_dir]
else
Gem.user_dir
end
end
##
# Path to specification files of default gems.
def default_specifications_dir
@default_specifications_dir ||= File.join(Gem.default_dirs[:system][:gem_dir], "specifications", "default")
end
##
# Default gem load path
def default_path
path = default_dirs.collect {|location, paths| paths[:gem_dir]}
path.unshift Gem.user_dir if File.exist? Gem.user_home
path
end
def default_bindir
if opt_build_root?
Gem.default_dirs[:system][:bin_dir]
elsif Process.uid == 0
Gem.default_dirs[:local][:bin_dir]
else
File.join [Dir.home, 'bin']
end
end
def default_ext_dir_for base_dir
dir = if rpmbuild?
build_dir = base_dir.chomp Gem.default_dirs[:system][:gem_dir]

View File

@ -1,25 +0,0 @@
From 28cc0749d6729aa2444661ee7b411e183fe220b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Mon, 19 Nov 2012 15:14:51 +0100
Subject: [PATCH] Verbose mkmf.
---
lib/mkmf.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 682eb46..e6b1445 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -1930,7 +1930,7 @@ def configuration(srcdir)
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
-V = 0
+V = 1
Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO1 = $(V:1=@ #{CONFIG['NULLCMD']})
--
1.8.3.1

View File

@ -11,7 +11,7 @@ diff --git a/configure.ac b/configure.ac
index d261ea57b5..3c13076b82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3105,6 +3105,11 @@ AS_IF([test ${multiarch+set}], [
@@ -3482,6 +3482,11 @@ AS_IF([test ${multiarch+set}], [
])
archlibdir='${libdir}/${arch}'
@ -23,6 +23,3 @@ index d261ea57b5..3c13076b82 100644
sitearchlibdir='${libdir}/${sitearch}'
archincludedir='${includedir}/${arch}'
sitearchincludedir='${includedir}/${sitearch}'
--
2.22.0

View File

@ -14,7 +14,7 @@ diff --git a/configure.ac b/configure.ac
index c42436c23d..d261ea57b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3743,7 +3743,8 @@ AS_CASE(["$ruby_version_dir_name"],
@@ -4321,7 +4321,8 @@ AS_CASE(["$ruby_version_dir_name"],
ruby_version_dir=/'${ruby_version_dir_name}'
if test -z "${ruby_version_dir_name}"; then
@ -66,7 +66,7 @@ diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
index 07076d4..35e6c3c 100755
--- a/tool/mkconfig.rb
+++ b/tool/mkconfig.rb
@@ -114,7 +114,7 @@
@@ -115,7 +115,7 @@
val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump
case name
when /^prefix$/
@ -75,6 +75,3 @@ index 07076d4..35e6c3c 100755
when /^ARCH_FLAG$/
val = "arch_flag || #{val}" if universal
when /^UNIVERSAL_ARCHNAMES$/
--
1.9.0

View File

@ -11,7 +11,7 @@ diff --git a/configure.ac b/configure.ac
index 3c13076b82..93af30321d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3807,6 +3807,8 @@ AC_SUBST(vendorarchdir)dnl
@@ -4385,6 +4385,8 @@ AC_SUBST(vendorarchdir)dnl
AC_SUBST(CONFIGURE, "`echo $0 | sed 's|.*/||'`")dnl
AC_SUBST(configure_args, "`echo "${ac_configure_args}" | sed 's/\\$/$$/g'`")dnl
@ -20,6 +20,3 @@ index 3c13076b82..93af30321d 100644
AS_IF([test "${universal_binary-no}" = yes ], [
arch="universal-${target_os}"
AS_IF([test "${rb_cv_architecture_available}" = yes], [
--
1.8.3.1

View File

@ -15,7 +15,7 @@ diff --git a/configure.ac b/configure.ac
index 93af30321d..bc13397e0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3779,6 +3779,10 @@ AC_ARG_WITH(vendorarchdir,
@@ -4357,6 +4357,10 @@ AC_ARG_WITH(vendorarchdir,
[vendorarchdir=$withval],
[vendorarchdir=${multiarch+'${rubysitearchprefix}/vendor_ruby'${ruby_version_dir}}${multiarch-'${vendorlibdir}/${sitearch}'}])
@ -26,7 +26,7 @@ index 93af30321d..bc13397e0e 100644
AS_IF([test "${LOAD_RELATIVE+set}"], [
AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)
RUBY_EXEC_PREFIX=''
@@ -3803,6 +3807,7 @@ AC_SUBST(sitearchdir)dnl
@@ -4381,6 +4385,7 @@ AC_SUBST(sitearchdir)dnl
AC_SUBST(vendordir)dnl
AC_SUBST(vendorlibdir)dnl
AC_SUBST(vendorarchdir)dnl
@ -64,10 +64,10 @@ index 79c003e..34f2382 100644
% R = {}
% R["ruby_version"] = '"RUBY_LIB_VERSION"'
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index b47b6e1..0b99408 100755
index e9110a17ca..76a1f0a315 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -343,6 +343,7 @@ def CONFIG.[](name, mandatory = false)
@@ -359,6 +359,7 @@ def CONFIG.[](name, mandatory = false)
vendorlibdir = CONFIG["vendorlibdir"]
vendorarchlibdir = CONFIG["vendorarchdir"]
end
@ -75,7 +75,7 @@ index b47b6e1..0b99408 100755
mandir = CONFIG["mandir", true]
docdir = CONFIG["docdir", true]
enable_shared = CONFIG["ENABLE_SHARED"] == 'yes'
@@ -570,7 +571,16 @@ def stub
@@ -595,7 +596,16 @@ def stub
install?(:local, :comm, :lib) do
prepare "library scripts", rubylibdir
noinst = %w[*.txt *.rdoc *.gemspec]
@ -92,6 +92,3 @@ index b47b6e1..0b99408 100755
end
install?(:local, :comm, :hdr, :'comm-hdr') do
--
1.8.3.1

View File

@ -12,15 +12,15 @@ ruby_version_dir_name now specifies custom version string for versioned
directories, e.g. instead of default X.Y.Z, you can specify whatever
string.
---
configure.ac | 64 ++++++++++++++++++++++++---------------------
configure.ac | 66 ++++++++++++++++++++++++---------------------
template/ruby.pc.in | 1 +
2 files changed, 35 insertions(+), 30 deletions(-)
2 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/configure.ac b/configure.ac
index 80b137e380..63cd3b4f8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3694,9 +3694,6 @@ AS_CASE(["$target_os"],
@@ -4271,9 +4271,6 @@ AS_CASE(["$target_os"],
rubyw_install_name='$(RUBYW_INSTALL_NAME)'
])
@ -30,7 +30,7 @@ index 80b137e380..63cd3b4f8b 100644
rubyarchprefix=${multiarch+'${archlibdir}/${RUBY_BASE_NAME}'}${multiarch-'${rubylibprefix}/${arch}'}
AC_ARG_WITH(rubyarchprefix,
AS_HELP_STRING([--with-rubyarchprefix=DIR],
@@ -3719,56 +3716,62 @@ AC_ARG_WITH(ridir,
@@ -4296,57 +4293,63 @@ AC_ARG_WITH(ridir,
AC_SUBST(ridir)
AC_SUBST(RI_BASE_NAME)
@ -46,6 +46,7 @@ index 80b137e380..63cd3b4f8b 100644
-AS_IF([test ${RUBY_LIB_VERSION_STYLE+set}], [
- {
- echo "#define RUBY_LIB_VERSION_STYLE $RUBY_LIB_VERSION_STYLE"
- echo '@%:@include "confdefs.h"'
- echo '#define STRINGIZE(x) x'
- test -f revision.h -o -f "${srcdir}/revision.h" || echo '#define RUBY_REVISION 0'
- echo '#include "version.h"'
@ -61,6 +62,7 @@ index 80b137e380..63cd3b4f8b 100644
+RUBY_LIB_VERSION_STYLE='3 /* full */'
+{
+echo "#define RUBY_LIB_VERSION_STYLE $RUBY_LIB_VERSION_STYLE"
+echo '@%:@include "confdefs.h"'
+echo '#define STRINGIZE(x) x'
+test -f revision.h -o -f "${srcdir}/revision.h" || echo '#define RUBY_REVISION 0'
+echo '#include "version.h"'
@ -120,7 +122,7 @@ index 80b137e380..63cd3b4f8b 100644
AS_IF([test "${LOAD_RELATIVE+set}"], [
AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)
@@ -3785,6 +3788,7 @@ AC_SUBST(sitearchincludedir)dnl
@@ -4363,6 +4366,7 @@ AC_SUBST(sitearchincludedir)dnl
AC_SUBST(arch)dnl
AC_SUBST(sitearch)dnl
AC_SUBST(ruby_version)dnl
@ -132,16 +134,14 @@ diff --git a/template/ruby.pc.in b/template/ruby.pc.in
index 8a2c066..c81b211 100644
--- a/template/ruby.pc.in
+++ b/template/ruby.pc.in
@@ -9,6 +9,7 @@ MAJOR=@MAJOR@
@@ -2,6 +2,7 @@ MAJOR=@MAJOR@
MINOR=@MINOR@
TEENY=@TEENY@
ruby_version=@ruby_version@
+ruby_version_dir_name=@ruby_version_dir_name@
RUBY_API_VERSION=@RUBY_API_VERSION@
RUBY_PROGRAM_VERSION=@RUBY_PROGRAM_VERSION@
RUBY_BASE_NAME=@RUBY_BASE_NAME@
--
2.1.0
arch=@arch@
From 518850aba6eee76de7715aae8d37330e34b01983 Mon Sep 17 00:00:00 2001
@ -165,13 +165,13 @@ index 970cb91..5bf8230 100644
- version = RbConfig::CONFIG['ruby_version']
+ version = RbConfig::CONFIG['ruby_version_dir_name'] || RbConfig::CONFIG['ruby_version']
BASE = if RbConfig::CONFIG.key? 'ridir' then
File.join RbConfig::CONFIG['ridir'], version
BASE = File.join RbConfig::CONFIG['ridir'], version
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index d4c110e..d39c9a6 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -433,7 +433,7 @@ def CONFIG.[](name, mandatory = false)
@@ -453,7 +453,7 @@ def CONFIG.[](name, mandatory = false)
install?(:doc, :rdoc) do
if $rdocdir
@ -180,9 +180,6 @@ index d4c110e..d39c9a6 100755
prepare "rdoc", ridatadir
install_recursive($rdocdir, ridatadir, :no_install => rdoc_noinst, :mode => $data_mode)
end
--
2.23.0
From 9f0ec0233f618cbb862629816b22491c3df79578 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
@ -190,46 +187,39 @@ Date: Tue, 31 Mar 2015 16:37:44 +0200
Subject: [PATCH 3/4] Add ruby_version_dir_name support for RubyGems.
---
lib/rubygems/defaults.rb | 9 +++++----
lib/rubygems/defaults.rb | 7 ++++---
test/rubygems/test_gem.rb | 5 +++--
2 files changed, 8 insertions(+), 6 deletions(-)
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index d4ff4a262c..3f9a5bf590 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -32,13 +32,13 @@ def self.default_dir
[
File.dirname(RbConfig::CONFIG['sitedir']),
'Gems',
- RbConfig::CONFIG['ruby_version']
+ RbConfig::CONFIG['ruby_version_dir_name'] || RbConfig::CONFIG['ruby_version']
]
else
[
RbConfig::CONFIG['rubylibprefix'],
'gems',
- RbConfig::CONFIG['ruby_version']
+ RbConfig::CONFIG['ruby_version_dir_name'] || RbConfig::CONFIG['ruby_version']
]
end
@@ -35,7 +35,7 @@ def self.default_spec_cache_dir
# specified in the environment
@@ -75,7 +75,8 @@ def self.default_specifications_dir
def self.default_dir
- @default_dir ||= File.join(RbConfig::CONFIG["rubylibprefix"], "gems", RbConfig::CONFIG["ruby_version"])
+ @default_dir ||= File.join(RbConfig::CONFIG["rubylibprefix"], "gems", RbConfig::CONFIG["ruby_version_dir_name"] || RbConfig::CONFIG["ruby_version"])
end
def self.user_dir
parts = [Gem.user_home, '.gem', ruby_engine]
- parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
+ ruby_version_dir_name = RbConfig::CONFIG['ruby_version_dir_name'] || RbConfig::CONFIG['ruby_version']
##
@@ -104,7 +104,8 @@ def self.user_dir
gem_dir = File.join(Gem.user_home, ".gem")
gem_dir = File.join(Gem.data_home, "gem") unless File.exist?(gem_dir)
parts = [gem_dir, ruby_engine]
- parts << RbConfig::CONFIG["ruby_version"] unless RbConfig::CONFIG["ruby_version"].empty?
+ ruby_version_dir_name = RbConfig::CONFIG["ruby_version_dir_name"] || RbConfig::CONFIG["ruby_version"]
+ parts << ruby_version_dir_name unless ruby_version_dir_name.empty?
File.join parts
end
@@ -158,7 +159,7 @@ def self.vendor_dir # :nodoc:
return nil unless RbConfig::CONFIG.key? 'vendordir'
@@ -265,7 +266,7 @@ def self.vendor_dir # :nodoc:
return nil unless RbConfig::CONFIG.key? "vendordir"
File.join RbConfig::CONFIG['vendordir'], 'gems',
- RbConfig::CONFIG['ruby_version']
+ RbConfig::CONFIG['ruby_version_dir_name'] || RbConfig::CONFIG['ruby_version']
File.join RbConfig::CONFIG["vendordir"], "gems",
- RbConfig::CONFIG["ruby_version"]
+ RbConfig::CONFIG["ruby_version_dir_name"] || RbConfig::CONFIG["ruby_version"]
end
##
@ -237,27 +227,25 @@ diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb
index b25068405d..e9fef4a311 100644
--- a/test/rubygems/test_gem.rb
+++ b/test/rubygems/test_gem.rb
@@ -1378,7 +1378,8 @@ def test_self_use_paths
@@ -1353,7 +1353,8 @@ def test_self_use_paths
def test_self_user_dir
parts = [@userhome, '.gem', Gem.ruby_engine]
- parts << RbConfig::CONFIG['ruby_version'] unless RbConfig::CONFIG['ruby_version'].empty?
+ ruby_version_dir_name = RbConfig::CONFIG['ruby_version_dir_name'] || RbConfig::CONFIG['ruby_version']
parts = [@userhome, ".gem", Gem.ruby_engine]
- parts << RbConfig::CONFIG["ruby_version"] unless RbConfig::CONFIG["ruby_version"].empty?
+ ruby_version_dir_name = RbConfig::CONFIG["ruby_version_dir_name"] || RbConfig::CONFIG["ruby_version"]
+ parts << ruby_version_dir_name unless ruby_version_dir_name.empty?
assert_equal File.join(parts), Gem.user_dir
end
@@ -1454,7 +1455,7 @@ def test_self_vendor_dir
vendordir(File.join(@tempdir, 'vendor')) do
FileUtils.mkdir_p File.join(parts)
@@ -1429,7 +1430,7 @@ def test_self_vendor_dir
vendordir(File.join(@tempdir, "vendor")) do
expected =
File.join RbConfig::CONFIG['vendordir'], 'gems',
- RbConfig::CONFIG['ruby_version']
+ RbConfig::CONFIG['ruby_version_dir_name'] || RbConfig::CONFIG['ruby_version']
File.join RbConfig::CONFIG["vendordir"], "gems",
- RbConfig::CONFIG["ruby_version"]
+ RbConfig::CONFIG["ruby_version_dir_name"] || RbConfig::CONFIG["ruby_version"]
assert_equal expected, Gem.vendor_dir
end
--
2.1.0
From 88c38a030c22dbf9422ece847bdfbf87d6659313 Mon Sep 17 00:00:00 2001
@ -274,15 +262,12 @@ diff --git a/configure.ac b/configure.ac
index a00f2b6776..999e2d6d5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,7 +98,7 @@ RUBY_BASE_NAME=`echo ruby | sed "$program_transform_name"`
@@ -136,7 +136,7 @@ RUBY_BASE_NAME=`echo ruby | sed "$program_transform_name"`
RUBYW_BASE_NAME=`echo rubyw | sed "$program_transform_name"`
AC_SUBST(RUBY_BASE_NAME)
AC_SUBST(RUBYW_BASE_NAME)
-AC_SUBST(RUBY_VERSION_NAME, '${RUBY_BASE_NAME}-${ruby_version}')
+AC_SUBST(RUBY_VERSION_NAME, '${RUBY_BASE_NAME}-${ruby_version_dir_name}')
AC_CANONICAL_TARGET
test x"$target_alias" = x &&
--
2.1.0
dnl checks for alternative programs
AC_CANONICAL_BUILD

View File

@ -1,136 +0,0 @@
From 346e147ba6480839b87046e9a9efab0bf6ed3660 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Wed, 10 Aug 2016 17:35:48 +0200
Subject: [PATCH] Rely on ldd to detect glibc.
This is just workaround, since we know we are quite sure this will be successful
on Red Hat platforms.
This workaround rhbz#1361037
---
test/fiddle/helper.rb | 111 ------------------------------------------
1 file changed, 111 deletions(-)
diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb
index 1da3d93..65148a1 100644
--- a/test/fiddle/helper.rb
+++ b/test/fiddle/helper.rb
@@ -6,115 +6,6 @@
libc_so = libm_so = nil
-case RUBY_PLATFORM
-when /cygwin/
- libc_so = "cygwin1.dll"
- libm_so = "cygwin1.dll"
-when /android/
- libdir = '/system/lib'
- if [0].pack('L!').size == 8
- libdir = '/system/lib64'
- end
- libc_so = File.join(libdir, "libc.so")
- libm_so = File.join(libdir, "libm.so")
-when /linux/
- libdir = '/lib'
- case RbConfig::SIZEOF['void*']
- when 4
- # 32-bit ruby
- case RUBY_PLATFORM
- when /armv\w+-linux/
- # In the ARM 32-bit libc package such as libc6:armhf libc6:armel,
- # libc.so and libm.so are installed to /lib/arm-linux-gnu*.
- # It's not installed to /lib32.
- dirs = Dir.glob('/lib/arm-linux-gnu*')
- libdir = dirs[0] if dirs && File.directory?(dirs[0])
- else
- libdir = '/lib32' if File.directory? '/lib32'
- end
- when 8
- # 64-bit ruby
- libdir = '/lib64' if File.directory? '/lib64'
- end
- libc_so = File.join(libdir, "libc.so.6")
- libm_so = File.join(libdir, "libm.so.6")
-when /mingw/, /mswin/
- require "rbconfig"
- crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase'
- libc_so = libm_so = "#{crtname}.dll"
-when /darwin/
- libc_so = libm_so = "/usr/lib/libSystem.B.dylib"
-when /kfreebsd/
- libc_so = "/lib/libc.so.0.1"
- libm_so = "/lib/libm.so.1"
-when /gnu/ #GNU/Hurd
- libc_so = "/lib/libc.so.0.3"
- libm_so = "/lib/libm.so.6"
-when /mirbsd/
- libc_so = "/usr/lib/libc.so.41.10"
- libm_so = "/usr/lib/libm.so.7.0"
-when /freebsd/
- libc_so = "/lib/libc.so.7"
- libm_so = "/lib/libm.so.5"
-when /bsd|dragonfly/
- libc_so = "/usr/lib/libc.so"
- libm_so = "/usr/lib/libm.so"
-when /solaris/
- libdir = '/lib'
- case RbConfig::SIZEOF['void*']
- when 4
- # 32-bit ruby
- libdir = '/lib' if File.directory? '/lib'
- when 8
- # 64-bit ruby
- libdir = '/lib/64' if File.directory? '/lib/64'
- end
- libc_so = File.join(libdir, "libc.so")
- libm_so = File.join(libdir, "libm.so")
-when /aix/
- pwd=Dir.pwd
- libc_so = libm_so = "#{pwd}/libaixdltest.so"
- unless File.exist? libc_so
- cobjs=%w!strcpy.o!
- mobjs=%w!floats.o sin.o!
- funcs=%w!sin sinf strcpy strncpy!
- expfile='dltest.exp'
- require 'tmpdir'
- Dir.mktmpdir do |dir|
- begin
- Dir.chdir dir
- %x!/usr/bin/ar x /usr/lib/libc.a #{cobjs.join(' ')}!
- %x!/usr/bin/ar x /usr/lib/libm.a #{mobjs.join(' ')}!
- %x!echo "#{funcs.join("\n")}\n" > #{expfile}!
- require 'rbconfig'
- if RbConfig::CONFIG["GCC"] = 'yes'
- lflag='-Wl,'
- else
- lflag=''
- end
- flags="#{lflag}-bE:#{expfile} #{lflag}-bnoentry -lm"
- %x!#{RbConfig::CONFIG["LDSHARED"]} -o #{libc_so} #{(cobjs+mobjs).join(' ')} #{flags}!
- ensure
- Dir.chdir pwd
- end
- end
- end
-else
- libc_so = ARGV[0] if ARGV[0] && ARGV[0][0] == ?/
- libm_so = ARGV[1] if ARGV[1] && ARGV[1][0] == ?/
- if( !(libc_so && libm_so) )
- $stderr.puts("libc and libm not found: #{$0} <libc> <libm>")
- end
-end
-
-libc_so = nil if !libc_so || (libc_so[0] == ?/ && !File.file?(libc_so))
-libm_so = nil if !libm_so || (libm_so[0] == ?/ && !File.file?(libm_so))
-
-# macOS 11.0+ removed libSystem.B.dylib from /usr/lib. But It works with dlopen.
-if RUBY_PLATFORM =~ /darwin/
- libc_so = libm_so = "/usr/lib/libSystem.B.dylib"
-end
-
if !libc_so || !libm_so
ruby = EnvUtil.rubybin
# When the ruby binary is 32-bit and the host is 64-bit,
--
2.9.2

View File

@ -15,10 +15,11 @@ To keep the things simple for now, load the ABRT hook via C.
[4]: https://github.com/ruby/ruby/pull/2735
[5]: https://lists.fedoraproject.org/archives/list/ruby-sig@lists.fedoraproject.org/message/LH6L6YJOYQT4Y5ZNOO4SLIPTUWZ5V45Q/
---
abrt.c | 12 ++++++++++++++
common.mk | 3 ++-
ruby.c | 4 ++++
3 files changed, 18 insertions(+), 1 deletion(-)
abrt.c | 12 ++++++++++++
common.mk | 3 ++-
ruby.c | 4 ++++
spec/ruby/core/kernel/require_spec.rb | 2 ++
4 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 abrt.c
diff --git a/abrt.c b/abrt.c
@ -43,9 +44,9 @@ diff --git a/common.mk b/common.mk
index b2e5b2b6d0..f39f81da5c 100644
--- a/common.mk
+++ b/common.mk
@@ -81,7 +81,8 @@ ENC_MK = enc.mk
MAKE_ENC = -f $(ENC_MK) V="$(V)" UNICODE_HDR_DIR="$(UNICODE_HDR_DIR)" \
RUBY="$(MINIRUBY)" MINIRUBY="$(MINIRUBY)" $(mflags)
@@ -111,7 +111,8 @@ PRISM_FILES = prism/api_node.$(OBJEXT) \
prism/prism.$(OBJEXT) \
prism_init.$(OBJEXT)
-COMMONOBJS = array.$(OBJEXT) \
+COMMONOBJS = abrt.$(OBJEXT) \
@ -57,7 +58,7 @@ diff --git a/ruby.c b/ruby.c
index 60c57d6259..1eec16f2c8 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1451,10 +1451,14 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
@@ -1722,10 +1722,14 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
void Init_builtin_features(void);
@ -72,6 +73,16 @@ index 60c57d6259..1eec16f2c8 100644
rb_const_remove(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"));
}
--
2.24.1
diff --git a/spec/ruby/core/kernel/require_spec.rb b/spec/ruby/core/kernel/require_spec.rb
index 60c57d6259..1eec16f2c8 100644
--- a/spec/ruby/core/kernel/require_spec.rb
+++ b/spec/ruby/core/kernel/require_spec.rb
@@ -25,6 +25,8 @@
out = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems --disable-did-you-mean')
features = out.lines.map { |line| File.basename(line.chomp, '.*') }
+ # Ignore ABRT
+ features -= %w[abrt]
# Ignore CRuby internals
features -= %w[encdb transdb windows_1252]
features.reject! { |feature| feature.end_with?('-fake') }

View File

@ -1,32 +0,0 @@
From 6532dbecf36d1f24dab1f2143afd171e0b7699eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Wed, 4 Sep 2019 15:07:07 +0200
Subject: [PATCH] Remove RubyGems dependency.
Since `Process::RLIMIT_NOFILE` is platform specific, better to use Ruby
introspection than detecting platform.
---
.../vendor/net-http-persistent/lib/net/http/persistent.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
index a54be2a..06739f1 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
@@ -197,10 +197,10 @@ class Bundler::Persistent::Net::HTTP::Persistent
##
# The default connection pool size is 1/4 the allowed open files.
- if Gem.win_platform? then
- DEFAULT_POOL_SIZE = 256
- else
+ if Process.const_defined? :RLIMIT_NOFILE
DEFAULT_POOL_SIZE = Process.getrlimit(Process::RLIMIT_NOFILE).first / 4
+ else
+ DEFAULT_POOL_SIZE = 256
end
##
--
2.23.0

View File

@ -1,34 +0,0 @@
From 9b42fce32bff25e0569581f76f532b9d57865aef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Mon, 27 Jul 2020 14:56:05 +0200
Subject: [PATCH] Timeout the test_bug_reporter_add witout raising error.
While timeouting the threads might be still good idea, it does not seems
the timeout impacts the TestBugReporter#test_bug_reporter_add result,
because the output of the child process has been already collected
earlier.
It seems that when the system is under heavy load, the thread might not
be sheduled to finish its processing. Even finishing the child process
might take tens of seconds and therefore the test case finish might take
a while.
---
test/-ext-/bug_reporter/test_bug_reporter.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb
index 628fcd0340..2c677cc8a7 100644
--- a/test/-ext-/bug_reporter/test_bug_reporter.rb
+++ b/test/-ext-/bug_reporter/test_bug_reporter.rb
@@ -19,7 +19,7 @@ def test_bug_reporter_add
args = ["--disable-gems", "-r-test-/bug_reporter",
"-C", tmpdir]
stdin = "register_sample_bug_reporter(12345); Process.kill :SEGV, $$"
- assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT")
+ assert_in_out_err(args, stdin, [], expected_stderr, encoding: "ASCII-8BIT", timeout_error: nil)
ensure
FileUtils.rm_rf(tmpdir) if tmpdir
end
--
2.27.0

View File

@ -1,22 +0,0 @@
From 0689147586c6cb56b91bf0f368890f19d630ece1 Mon Sep 17 00:00:00 2001
From: nobletrout <nobletrout@gmail.com>
Date: Tue, 5 Feb 2019 08:14:02 -0500
Subject: [PATCH] remove unneeded gem require for ipaddr
ipaddr is a builtin class for ruby, that is occasionally merged. If the version isn't specified by the runtime dependency, then it will default to needing the latest gem rather than the version that ships with that version of ruby. That will lead to all kinds of potential dependency fails that are most likely unneeded since this gem already requires ruby > 2.3.0
---
ext/openssl/openssl.gemspec | 1 -
1 file changed, 1 deletion(-)
diff --git a/ext/openssl/openssl.gemspec b/ext/openssl/openssl.gemspec
index 7c17cd54..f721f247 100644
--- a/ext/openssl/openssl.gemspec
+++ b/ext/openssl/openssl.gemspec
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
s.rubygems_version = "3.0.0.beta1"
s.summary = "OpenSSL provides SSL, TLS and general purpose cryptography."
- s.add_runtime_dependency("ipaddr", [">= 0"])
s.add_development_dependency("rake", [">= 0"])
s.add_development_dependency("rake-compiler", [">= 0"])
s.add_development_dependency("test-unit", ["~> 3.0"])

View File

@ -1,178 +0,0 @@
From c5806d668f84a86e9e6a522f84b8aa6cb4cdaae9 Mon Sep 17 00:00:00 2001
From: Ali Saidi <alisaidi@amazon.com>
Date: Wed, 5 Aug 2020 20:46:28 -0500
Subject: [PATCH 1/3] Enable unaligned accesses on arm64
64-bit Arm platforms support unaligned accesses.
Running the string benchmarks this change improves performance
by an average of 1.04x, min .96x, max 1.21x, median 1.01x
---
include/ruby/defines.h | 2 +-
regint.h | 2 +-
siphash.c | 2 +-
st.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index 49f673ef936a..0193275e8b78 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -485,7 +485,7 @@
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
- defined(__powerpc64__) || \
+ defined(__powerpc64__) || defined(__aarch64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# else
diff --git a/regint.h b/regint.h
index a2f5bbba1d1f..0740429688bc 100644
--- a/regint.h
+++ b/regint.h
@@ -52,7 +52,7 @@
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
- defined(__powerpc64__) || \
+ defined(__powerpc64__) || defined(__aarch64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# else
diff --git a/siphash.c b/siphash.c
index 153d2c690ab9..ddf8ee245d81 100644
--- a/siphash.c
+++ b/siphash.c
@@ -30,7 +30,7 @@
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
- defined(__powerpc64__) || \
+ defined(__powerpc64__) || defined(__aarch64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# endif
diff --git a/st.c b/st.c
index c11535ef9779..8be466bf733f 100644
--- a/st.c
+++ b/st.c
@@ -1815,7 +1815,7 @@ st_values_check(st_table *tab, st_data_t *values, st_index_t size,
#ifndef UNALIGNED_WORD_ACCESS
# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
- defined(__powerpc64__) || \
+ defined(__powerpc64__) || defined(__aarch64__) || \
defined(__mc68020__)
# define UNALIGNED_WORD_ACCESS 1
# endif
From 79b7b9143fda0f33fc9375980cecc61eb42c6f66 Mon Sep 17 00:00:00 2001
From: Ali Saidi <alisaidi@amazon.com>
Date: Wed, 5 Aug 2020 21:04:37 -0500
Subject: [PATCH 2/3] arm64 enable gc optimizations
Similar to x86 and powerpc optimizations.
| |compare-ruby|built-ruby|
|:------|-----------:|---------:|
|hash1 | 0.225| 0.237|
| | -| 1.05x|
|hash2 | 0.110| 0.110|
| | 1.00x| -|
---
gc.c | 13 +++++++++++++
gc.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/gc.c b/gc.c
index 22972dfc806c..788f06f1586e 100644
--- a/gc.c
+++ b/gc.c
@@ -1153,6 +1153,19 @@ tick(void)
return val;
}
+#elif defined(__aarch64__) && defined(__GNUC__)
+typedef unsigned long tick_t;
+#define PRItick "lu"
+
+static __inline__ tick_t
+tick(void)
+{
+ unsigned long val;
+ __asm__ __volatile__ ("mrs %0, cntvct_el0", : "=r" (val));
+ return val;
+}
+
+
#elif defined(_WIN32) && defined(_MSC_VER)
#include <intrin.h>
typedef unsigned __int64 tick_t;
diff --git a/gc.h b/gc.h
index 6568079c54e5..47a4ca19a0c5 100644
--- a/gc.h
+++ b/gc.h
@@ -8,6 +8,8 @@
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p)))
#elif defined(__powerpc64__) && defined(__GNUC__)
#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p)))
+#elif defined(__aarch64__) && defined(__GNUC__)
+#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mov\t%0, sp" : "=r" (*(p)))
#else
NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
From c985b8c6868a380e44e285368af4a4f414ce3309 Mon Sep 17 00:00:00 2001
From: Ali Saidi <alisaidi@amazon.com>
Date: Wed, 5 Aug 2020 21:15:55 -0500
Subject: [PATCH 3/3] vm_exec.c: improve performance for arm64
| |compare-ruby|built-ruby|
|:------------------------------|-----------:|---------:|
|vm_array | 26.501M| 27.959M|
| | -| 1.06x|
|vm_attr_ivar | 21.606M| 31.429M|
| | -| 1.45x|
|vm_attr_ivar_set | 21.178M| 26.113M|
| | -| 1.23x|
|vm_backtrace | 6.621| 6.668|
| | -| 1.01x|
|vm_bigarray | 26.205M| 29.958M|
| | -| 1.14x|
|vm_bighash | 504.155k| 479.306k|
| | 1.05x| -|
|vm_block | 16.692M| 21.315M|
| | -| 1.28x|
|block_handler_type_iseq | 5.083| 7.004|
| | -| 1.38x|
---
vm_exec.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/vm_exec.c b/vm_exec.c
index ce2e053ee745..7aa56f6ad620 100644
--- a/vm_exec.c
+++ b/vm_exec.c
@@ -27,6 +27,9 @@ static void vm_insns_counter_count_insn(int insn) {}
#elif defined(__GNUC__) && defined(__powerpc64__)
#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg)
+#elif defined(__GNUC__) && defined(__aarch64__)
+#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("x" reg)
+
#else
#define DECL_SC_REG(type, r, reg) register type reg_##r
#endif
@@ -74,6 +77,11 @@ vm_exec_core(rb_execution_context_t *ec, VALUE initial)
DECL_SC_REG(rb_control_frame_t *, cfp, "15");
#define USE_MACHINE_REGS 1
+#elif defined(__GNUC__) && defined(__aarch64__)
+ DECL_SC_REG(const VALUE *, pc, "19");
+ DECL_SC_REG(rb_control_frame_t *, cfp, "20");
+#define USE_MACHINE_REGS 1
+
#else
register rb_control_frame_t *reg_cfp;
const VALUE *reg_pc;

View File

@ -0,0 +1,23 @@
From 6365d1b79e10330fced83d00d4cb950380a3b0fe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Thu, 7 Sep 2023 13:13:02 +0200
Subject: [PATCH] Disable syntax-suggest test case.
This requires internet connection.
---
common.mk | 2 --
1 file changed, 2 deletions(-)
diff --git a/common.mk b/common.mk
index d55d1788aa..73755f6ccd 100644
--- a/common.mk
+++ b/common.mk
@@ -1601,8 +1601,6 @@ yes-test-syntax-suggest: $(PREPARE_SYNTAX_SUGGEST)
$(ACTIONS_ENDGROUP)
no-test-syntax-suggest:
-check: $(DOT_WAIT) $(PREPARE_SYNTAX_SUGGEST) test-syntax-suggest
-
test-bundler-precheck: $(TEST_RUNNABLE)-test-bundler-precheck
no-test-bundler-precheck:
yes-test-bundler-precheck: main $(arch)-fake.rb

View File

@ -0,0 +1,302 @@
From 3d405634f43d39079ee93cdc59ed7fc0a5e8917a Mon Sep 17 00:00:00 2001
From: KJ Tsanaktsidis <kj@kjtsanaktsidis.id.au>
Date: Sun, 9 Jun 2024 21:15:39 +1000
Subject: [PATCH] Extract hardening CFLAGS to a special $hardenflags variable
This changes the automatic detection of -fstack-protector,
-D_FORTIFY_SOURCE, and -mbranch-protection to write to $hardenflags
instead of $XCFLAGS. The definition of $cflags is changed to
"$hardenflags $orig_cflags $optflags $debugflags $warnflags" to match.
Furthermore, these flags are _prepended_ to $hardenflags, rather than
appended.
The implications of doing this are as follows:
* If a CRuby builder specifies cflags="-mbranch-protection=foobar" at
the ./configure script, and the configure script detects that
-mbranch-protection=pac-ret is accepted, then GCC will be invoked as
"gcc -mbranch-protection=pac-ret -mbranch-protection=foobar". Since
the last flags take precedence, that means that user-supplied values
of these flags in $cflags will take priority.
* Likewise, if a CRuby builder explicitly specifies
"hardenflags=-mbranch-protection=foobar", because we _prepend_ to
$hardenflags in our autoconf script, we will still invoke GCC as
"gcc -mbranch-protection=pac-ret -mbranch-protection=foobar".
* If a CRuby builder specifies CFLAGS="..." at the configure line,
automatic detection of hardening flags is ignored as before.
* C extensions will _also_ be built with hardening flags now as well
(this was not the case by default before because the detected flags
went into $XCFLAGS).
Additionally, as part of this work, I changed how the detection of
PAC/BTI in Context.S works. Rather than appending the autodetected
option to ASFLAGS, we simply compile a set of test programs with the
actual CFLAGS in use to determine what PAC/BTI settings were actually
chosen by the builder. Context.S is made aware of these choices through
some custom macros.
The result of this work is that:
* Ruby will continue to choose some sensible defaults for hardening
options for the C compiler
* Distributors are able to specify CFLAGS that are consistent with their
distribution and override these defaults
* Context.S will react to whatever -mbranch-protection is actually in
use, not what was autodetected
* Extensions get built with hardening flags too.
[Bug #20154]
[Bug #20520]
---
configure.ac | 81 ++++++++++++++++++++++++++++++-----
coroutine/arm64/Context.S | 14 +++---
template/Makefile.in | 1 +
tool/m4/ruby_append_option.m4 | 4 ++
tool/m4/ruby_try_cflags.m4 | 17 ++++++++
5 files changed, 100 insertions(+), 17 deletions(-)
diff --git a/configure.ac b/configure.ac
index f35fad6a362611..0da15772d36671 100644
--- a/configure.ac
+++ b/configure.ac
@@ -354,7 +354,7 @@ test -z "$warnflags" ||
AS_IF([test -z "${CFLAGS+set}"], [
cflags=`echo " $cflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
orig_cflags="$cflags"
- cflags="$cflags "'${optflags} ${debugflags} ${warnflags}'
+ cflags='${hardenflags} '"$cflags "'${optflags} ${debugflags} ${warnflags}'
])
dnl AS_IF([test -z "${CXXFLAGS+set}"], [
dnl cxxflags=`echo " $cxxflags " | sed "$cflagspat;s/^ *//;s/ *$//"`
@@ -802,7 +802,7 @@ AS_IF([test "$GCC" = yes], [
[fortify_source=$enableval])
AS_IF([test "x$fortify_source" != xno], [
RUBY_TRY_CFLAGS([$optflags -D_FORTIFY_SOURCE=2],
- [RUBY_APPEND_OPTION(XCFLAGS, -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)], [],
+ [RUBY_PREPEND_OPTION(hardenflags, -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2)], [],
[@%:@include <stdio.h>])
])
@@ -823,20 +823,24 @@ AS_IF([test "$GCC" = yes], [
AC_MSG_CHECKING([for -fstack-protector])
AC_MSG_RESULT(["$stack_protector"])
AS_CASE(["$stack_protector"], [-*], [
- RUBY_APPEND_OPTION(XCFLAGS, $stack_protector)
- RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector)
- RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
+ RUBY_PREPEND_OPTION(hardenflags, $stack_protector)
+ RUBY_APPEND_OPTION(XLDFLAGS, $stack_protector)
+ RUBY_APPEND_OPTION(LDFLAGS, $stack_protector)
])
# aarch64 branch protection
AS_CASE(["$target_cpu"], [aarch64], [
AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [
- RUBY_TRY_CFLAGS(option, [branch_protection=yes], [branch_protection=no])
+ # Try these flags in the _prepended_ position - i.e. we want to try building a program
+ # with CFLAGS="-mbranch-protection=pac-ret $CFLAGS". If the builder has provided different
+ # branch protection flags in CFLAGS, we don't want to overwrite those. We just want to
+ # find some branch protection flags which work if none were provided.
+ RUBY_TRY_CFLAGS_PREPEND(option, [branch_protection=yes], [branch_protection=no])
AS_IF([test "x$branch_protection" = xyes], [
- # C compiler and assembler must be consistent for -mbranch-protection
- # since they both check `__ARM_FEATURE_PAC_DEFAULT` definition.
- RUBY_APPEND_OPTION(XCFLAGS, option)
- RUBY_APPEND_OPTION(ASFLAGS, option)
+ # _prepend_ the options to CFLAGS, so that user-provided flags will overwrite them.
+ # These CFLAGS are used during the configure script to compile further test programs;
+ # however, $harden_flags is prepended separately to CFLAGS at the end of the script.
+ RUBY_PREPEND_OPTION(hardenflags, $opt)
break
])
])
@@ -985,6 +989,59 @@ test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
}
+# The lines above expand out the $cflags/$optflags/$debugflags/$hardenflags variables into the
+# CFLAGS variable. So, at this point, we have a $CFLAGS var with the actual compiler flags we're
+# going to use.
+# That means this is the right time to check what branch protection flags are going to be in use
+# and define appropriate macros for use in Context.S based on this
+AS_CASE(["$target_cpu"], [aarch64], [
+ AC_CACHE_CHECK([whether __ARM_FEATURE_BTI_DEFAULT is defined],
+ rb_cv_aarch64_bti_enabled,
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ @%:@ifndef __ARM_FEATURE_BTI_DEFAULT
+ @%:@error "__ARM_FEATURE_BTI_DEFAULT not defined"
+ @%:@endif
+ ]])],
+ [rb_cv_aarch64_bti_enabled=yes],
+ [rb_cv_aarch64_bti_enabled=no])
+ )
+ AS_IF([test "$rb_cv_aarch64_bti_enabled" = yes],
+ AC_DEFINE(RUBY_AARCH64_BTI_ENABLED, 1))
+ AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT is defined],
+ rb_cv_aarch64_pac_enabled,
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ @%:@ifndef __ARM_FEATURE_PAC_DEFAULT
+ @%:@error "__ARM_FEATURE_PAC_DEFAULT not defined"
+ @%:@endif
+ ]])],
+ [rb_cv_aarch64_pac_enabled=yes],
+ [rb_cv_aarch64_pac_enabled=no])
+ )
+ AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes],
+ AC_DEFINE(RUBY_AARCH64_PAC_ENABLED, 1))
+ # Context.S will only ever sign its return address with the A-key; it doesn't support
+ # the B-key at the moment.
+ AS_IF([test "$rb_cv_aarch64_pac_enabled" = yes], [
+ AC_CACHE_CHECK([whether __ARM_FEATURE_PAC_DEFAULT specifies the b-key bit 0x02],
+ rb_cv_aarch64_pac_b_key,
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+ @%:@ifdef __ARM_FEATURE_PAC_DEFAULT
+ @%:@if __ARM_FEATURE_PAC_DEFAULT & 0x02
+ @%:@error "__ARM_FEATURE_PAC_DEFAULT specifies B key"
+ @%:@endif
+ @%:@endif
+ ]])],
+ [rb_cv_aarch64_pac_b_key=no],
+ [rb_cv_aarch64_pac_b_key=yes])
+ )
+ AS_IF([test "$rb_cv_aarch64_pac_b_key" = yes],
+ AC_MSG_ERROR(-mbranch-protection flag specified b-key but Ruby's Context.S does not support this yet.))
+ ])
+])
+
AC_CACHE_CHECK([whether compiler has statement and declarations in expressions],
rb_cv_have_stmt_and_decl_in_expr,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[ __extension__ ({ int a = 0; a; }); ]])],
@@ -4215,12 +4272,13 @@ AS_IF([test "${ARCH_FLAG}"], [
rb_cv_warnflags=`echo "$rb_cv_warnflags" | sed 's/^ *//;s/ *$//'`
warnflags="$rb_cv_warnflags"
AC_SUBST(cppflags)dnl
-AC_SUBST(cflags, ["${orig_cflags:+$orig_cflags }"'${optflags} ${debugflags} ${warnflags}'])dnl
+AC_SUBST(cflags, ['${hardenflags} '"${orig_cflags:+$orig_cflags }"' ${optflags} ${debugflags} ${warnflags}'])dnl
AC_SUBST(cxxflags)dnl
AC_SUBST(optflags)dnl
AC_SUBST(debugflags)dnl
AC_SUBST(warnflags)dnl
AC_SUBST(strict_warnflags)dnl
+AC_SUBST(hardenflags)dnl
AC_SUBST(XCFLAGS)dnl
AC_SUBST(XLDFLAGS)dnl
AC_SUBST(EXTLDFLAGS)dnl
@@ -4688,6 +4746,7 @@ config_summary "DLDFLAGS" "$DLDFLAGS"
config_summary "optflags" "$optflags"
config_summary "debugflags" "$debugflags"
config_summary "warnflags" "$warnflags"
+config_summary "hardenflags" "$hardenflags"
config_summary "strip command" "$STRIP"
config_summary "install doc" "$DOCTARGETS"
config_summary "YJIT support" "$YJIT_SUPPORT"
diff --git a/coroutine/arm64/Context.S b/coroutine/arm64/Context.S
index 5251ab214df1f0..54611a247e2f66 100644
--- a/coroutine/arm64/Context.S
+++ b/coroutine/arm64/Context.S
@@ -5,6 +5,8 @@
## Copyright, 2018, by Samuel Williams.
##
+#include "ruby/config.h"
+
#define TOKEN_PASTE(x,y) x##y
#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
@@ -27,10 +29,10 @@
.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
-#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
+#if defined(RUBY_AARCH64_PAC_ENABLED)
# paciasp (it also acts as BTI landing pad, so no need to insert BTI also)
hint #25
-#elif defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT != 0)
+#elif defined(RUBY_AARCH64_BTI_ENABLED)
# For the the case PAC is not enabled but BTI is.
# bti c
hint #34
@@ -73,7 +75,7 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
# Pop stack frame
add sp, sp, 0xa0
-#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
+#if defined(RUBY_AARCH64_PAC_ENABLED)
# autiasp: Authenticate x30 (LR) with SP and key A
hint #29
#endif
@@ -85,18 +87,18 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
.section .note.GNU-stack,"",%progbits
#endif
-#if __ARM_FEATURE_BTI_DEFAULT != 0 || __ARM_FEATURE_PAC_DEFAULT != 0
+#if defined(RUBY_AARCH64_BTI_ENABLED) || defined(RUBY_AARCH64_PAC_ENABLED)
/* See "ELF for the Arm 64-bit Architecture (AArch64)"
https://github.com/ARM-software/abi-aa/blob/2023Q3/aaelf64/aaelf64.rst#program-property */
# define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1<<0)
# define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1<<1)
-# if __ARM_FEATURE_BTI_DEFAULT != 0
+# if defined(RUBY_AARCH64_BTI_ENABLED)
# define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
# else
# define BTI_FLAG 0
# endif
-# if __ARM_FEATURE_PAC_DEFAULT != 0
+# if defined(RUBY_AARCH64_PAC_ENABLED)
# define PAC_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_PAC
# else
# define PAC_FLAG 0
diff --git a/template/Makefile.in b/template/Makefile.in
index 033ac56cb38886..abb4469777ce8a 100644
--- a/template/Makefile.in
+++ b/template/Makefile.in
@@ -89,6 +89,7 @@ cflags = @cflags@
optflags = @optflags@
debugflags = @debugflags@
warnflags = @warnflags@ @strict_warnflags@
+hardenflags = @hardenflags@
cppflags = @cppflags@
incflags = @incflags@
RUBY_DEVEL = @RUBY_DEVEL@ # "yes" or empty
diff --git a/tool/m4/ruby_append_option.m4 b/tool/m4/ruby_append_option.m4
index ff828d2162c22f..98359fa1f95f52 100644
--- a/tool/m4/ruby_append_option.m4
+++ b/tool/m4/ruby_append_option.m4
@@ -3,3 +3,7 @@ AC_DEFUN([RUBY_APPEND_OPTION],
[# RUBY_APPEND_OPTION($1)
AS_CASE([" [$]{$1-} "],
[*" $2 "*], [], [' '], [ $1="$2"], [ $1="[$]$1 $2"])])dnl
+AC_DEFUN([RUBY_PREPEND_OPTION],
+ [# RUBY_APPEND_OPTION($1)
+ AS_CASE([" [$]{$1-} "],
+ [*" $2 "*], [], [' '], [ $1="$2"], [ $1="$2 [$]$1"])])dnl
diff --git a/tool/m4/ruby_try_cflags.m4 b/tool/m4/ruby_try_cflags.m4
index b74718fe5e1cef..b397642aad9ca2 100644
--- a/tool/m4/ruby_try_cflags.m4
+++ b/tool/m4/ruby_try_cflags.m4
@@ -17,3 +17,20 @@ AC_DEFUN([RUBY_TRY_CFLAGS], [
AC_MSG_RESULT(no)])
])
])dnl
+
+AC_DEFUN([_RUBY_TRY_CFLAGS_PREPEND], [
+ RUBY_WERROR_FLAG([
+ CFLAGS="$1 [$]CFLAGS"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$4]], [[$5]])],
+ [$2], [$3])
+ ])dnl
+])dnl
+AC_DEFUN([RUBY_TRY_CFLAGS_PREPEND], [
+ AC_MSG_CHECKING([whether ]$1[ is accepted as CFLAGS])dnl
+ _RUBY_TRY_CFLAGS_PREPEND([$1],
+ [$2
+ AC_MSG_RESULT(yes)],
+ [$3
+ AC_MSG_RESULT(no)],
+ [$4], [$5])
+])dnl

61
ruby.rpmlintrc Normal file
View File

@ -0,0 +1,61 @@
# Keep matching patterns enough not to hide unintended errors and warnings.
# There is no way to implement this with `%{SOURCE0}` without `%{_sourcedir}`.
# The order in the .spec file could be possibly different.
addFilter(r'ruby\.(spec|src):20: E: use-of-RPM_SOURCE_DIR$')
# The used version is not obvious.
addFilter(r'ruby\.(spec|src):\d+: W: unversioned-explicit-provides bundled\(ccan-build_assert\)$')
addFilter(r'ruby\.(spec|src):\d+: W: unversioned-explicit-provides bundled\(ccan-check_type\)$')
addFilter(r'ruby\.(spec|src):\d+: W: unversioned-explicit-provides bundled\(ccan-container_of\)$')
addFilter(r'ruby\.(spec|src):\d+: W: unversioned-explicit-provides bundled\(ccan-list\)$')
# The template files do not have to have executable bits.
addFilter(r'^rubygem-bundler\.noarch: E: non-executable-script /usr/share/gems/gems/bundler-[\d\.]+/lib/bundler/templates/[\w/\.]+ 644 /usr/bin/env ')
# The bundled gem files permissions are overridden as 644 by `make install`.
# https://bugs.ruby-lang.org/issues/17840
# https://github.com/rubygems/rubygems/issues/5255
# https://github.com/ruby/debug/pull/481
# https://github.com/ruby/net-ftp/pull/12
# https://github.com/ruby/net-imap/pull/53
# https://github.com/ruby/net-pop/pull/7
# https://github.com/ruby/prime/pull/16
addFilter(r'^.*: E: non-executable-script /usr/share/gems/gems/(debug|net-(ftp|imap|pop)|prime)-[\d\.]+/bin/\w+ 644 ')
# Ruby provides API to set the cipher list.
addFilter(r'^ruby-libs\.\w+: W: crypto-policy-non-compliance-openssl /usr/lib(64)?/ruby/openssl.so SSL_CTX_set_cipher_list$')
# `gethostbyname` is part of deprecated Ruby API. There is also request to drop the API altogether:
# https://bugs.ruby-lang.org/issues/13097
# https://bugs.ruby-lang.org/issues/17944
addFilter(r'^ruby-libs\.\w+: W: binary-or-shlib-calls-gethostbyname /usr/lib(64)?/ruby/socket.so$')
# Rake ships some examples.
addFilter(r'^rubygem-rake.noarch: W: devel-file-in-non-devel-package /usr/share/gems/gems/rake-[\d\.]+/doc/example/\w+.c$')
# Some executables don't have their manual pages. Is it worth of use help2man?
addFilter(r'^.+: W: no-manual-page-for-binary (bundler|gem|racc|rbs|rdbg|rdoc|ruby-mri|syntax_suggest|typeprof)$')
# Default gems does not come with any documentation.
addFilter(r'^rubygem-(bigdecimal|io-console|json|psych)\.\w+: W: no-documentation$')
# rubygems-devel ships only RPM macros and generators. Their placement is given
# by RPM and can't be modified.
addFilter(r'rubygems-devel.noarch: W: only-non-binary-in-usr-lib$')
# Ignore some spelling false positives.
# Ignore spelling of technical terms
addFilter(r'^ruby-default-gems.noarch: E: spelling-error \(\'gemspec\'')
addFilter(r'^ruby-libs.x86_64: E: spelling-error \(\'libruby\'')
addFilter(r'^rubygem-test-unit.noarch: E: spelling-error \(\'xUnit\'')
addFilter(r'^rubygem-psych.x86_64: E: spelling-error \(\'libyaml\'')
addFilter(r'^rubygem-io-console.x86_64: E: spelling-error \(\'readline\'')
# `pyaml` is part of URL
addFilter(r'^rubygem-psych.x86_64: E: spelling-error \(\'pyyaml\'')
# `de-` is actually prefix
addFilter(r'^rubygem-psych.x86_64: E: spelling-error \(\'de\'')
# It does not seemt to be worth of changing rubygems to archful package due to
# single directory, unless it causes some real troubles.
addFilter(r'^rubygems.noarch: E: noarch-with-lib64$')

1636
ruby.spec

File diff suppressed because it is too large Load Diff

View File

@ -1,167 +0,0 @@
From 912d141a351053d0f6d915b5e7807f6a8f4c0631 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Tue, 4 Feb 2020 17:25:56 +0100
Subject: [PATCH 1/2] Make non "test_" method private
---
test/rubygems/test_require.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index aa2675af5d..d618a93473 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -532,6 +532,8 @@ def test_require_bundler_with_bundler_version
end
end
+ private
+
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, false
yield
From b3944384f44b869985051863d8b05b545d09a585 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Tue, 4 Feb 2020 17:26:28 +0100
Subject: [PATCH 2/2] Fix require issue with file extension priority
If `require "a"` is run when two folders have been specified in the -I
option including a "a.rb" file and a "a.so" file respectively, the ruby
spec says that the ".rb" file should always be preferred. However, the
logic we added in https://github.com/rubygems/rubygems/commit/6b81076d9
to make the -I option always beat default gems does not respect this
spec, creating a difference from the original ruby-core's require.
[the ruby spec says]: https://github.com/ruby/spec/blob/d80a6e2b221d4f17a8cadcac75ef950c59cba901/core/kernel/shared/require.rb#L234-L246
---
lib/rubygems/core_ext/kernel_require.rb | 28 +++++------
test/rubygems/test_require.rb | 62 +++++++++++++++++++++++++
2 files changed, 74 insertions(+), 16 deletions(-)
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 60f4d18712..369f2c743e 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -43,18 +43,18 @@ def require(path)
# https://github.com/rubygems/rubygems/pull/1868
resolved_path = begin
rp = nil
- $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
- safe_lp = lp.dup.tap(&Gem::UNTAINT)
- begin
- if File.symlink? safe_lp # for backward compatibility
- next
+ Gem.suffixes.each do |s|
+ $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
+ safe_lp = lp.dup.tap(&Gem::UNTAINT)
+ begin
+ if File.symlink? safe_lp # for backward compatibility
+ next
+ end
+ rescue SecurityError
+ RUBYGEMS_ACTIVATION_MONITOR.exit
+ raise
end
- rescue SecurityError
- RUBYGEMS_ACTIVATION_MONITOR.exit
- raise
- end
- Gem.suffixes.each do |s|
full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
if File.file?(full_path)
rp = full_path
@@ -67,12 +67,8 @@ def require(path)
end
if resolved_path
- begin
- RUBYGEMS_ACTIVATION_MONITOR.exit
- return gem_original_require(resolved_path)
- rescue LoadError
- RUBYGEMS_ACTIVATION_MONITOR.enter
- end
+ RUBYGEMS_ACTIVATION_MONITOR.exit
+ return gem_original_require(resolved_path)
end
if spec = Gem.find_unresolved_default_spec(path)
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index d618a93473..7cffbfa7fe 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -120,6 +120,24 @@ def test_dash_i_beats_default_gems
Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
end
+ def test_dash_i_respects_default_library_extension_priority
+ skip "extensions don't quite work on jruby" if Gem.java_platform?
+
+ dash_i_ext_arg = util_install_extension_file('a')
+ dash_i_lib_arg = util_install_ruby_file('a')
+
+ lp = $LOAD_PATH.dup
+
+ begin
+ $LOAD_PATH.unshift dash_i_lib_arg
+ $LOAD_PATH.unshift dash_i_ext_arg
+ assert_require 'a'
+ assert_match(/a\.rb$/, $LOADED_FEATURES.last)
+ ensure
+ $LOAD_PATH.replace lp
+ end
+ end
+
def test_concurrent_require
Object.const_set :FILE_ENTERED_LATCH, Latch.new(2)
Object.const_set :FILE_EXIT_LATCH, Latch.new(1)
@@ -541,4 +559,48 @@ def silence_warnings
$VERBOSE = old_verbose
end
+ def util_install_extension_file(name)
+ spec = quick_gem name
+ util_build_gem spec
+
+ spec.extensions << "extconf.rb"
+ write_file File.join(@tempdir, "extconf.rb") do |io|
+ io.write <<-RUBY
+ require "mkmf"
+ create_makefile("#{name}")
+ RUBY
+ end
+
+ write_file File.join(@tempdir, "#{name}.c") do |io|
+ io.write <<-C
+ #include <ruby.h>
+ void Init_#{name}() { }
+ C
+ end
+
+ spec.files += ["extconf.rb", "#{name}.c"]
+
+ so = File.join(spec.gem_dir, "#{name}.#{RbConfig::CONFIG["DLEXT"]}")
+ refute_path_exists so
+
+ path = Gem::Package.build spec
+ installer = Gem::Installer.at path
+ installer.install
+ assert_path_exists so
+
+ spec.gem_dir
+ end
+
+ def util_install_ruby_file(name)
+ dir_lib = Dir.mktmpdir("test_require_lib", @tempdir)
+ dash_i_lib_arg = File.join dir_lib
+
+ a_rb = File.join dash_i_lib_arg, "#{name}.rb"
+
+ FileUtils.mkdir_p File.dirname a_rb
+ File.open(a_rb, 'w') { |f| f.write "# #{name}.rb" }
+
+ dash_i_lib_arg
+ end
+
end

View File

@ -1,324 +0,0 @@
From 00d98eb8a3245fb93a475ecbbbc4c7ec7e6704cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Tue, 19 May 2020 14:00:00 +0200
Subject: [PATCH 1/5] Fix performance regression in `require`
Our check for `-I` paths should not go through all activated gems.
---
lib/rubygems.rb | 10 ++++++++++
lib/rubygems/core_ext/kernel_require.rb | 2 +-
lib/rubygems/test_case.rb | 1 +
test/rubygems/test_require.rb | 11 +++++++++++
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 843cb49e4a..d1a9a1c7e1 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -662,10 +662,20 @@ def self.load_path_insert_index
index
end
+ ##
+ # The number of paths in the `$LOAD_PATH` from activated gems. Used to
+ # prioritize `-I` and `ENV['RUBYLIB`]` entries during `require`.
+
+ def self.activated_gem_paths
+ @activated_gem_paths ||= 0
+ end
+
##
# Add a list of paths to the $LOAD_PATH at the proper place.
def self.add_to_load_path(*paths)
+ @activated_gem_paths = activated_gem_paths + paths.size
+
insert_index = load_path_insert_index
if insert_index
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index ed24111bd5..7625ce1bee 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -47,7 +47,7 @@ def require(path)
load_path_insert_index = Gem.load_path_insert_index
break unless load_path_insert_index
- $LOAD_PATH[0...load_path_insert_index].each do |lp|
+ $LOAD_PATH[0...load_path_insert_index - Gem.activated_gem_paths].each do |lp|
safe_lp = lp.dup.tap(&Gem::UNTAINT)
begin
if File.symlink? safe_lp # for backward compatibility
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index a05a2898d1..53dd495aef 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -385,6 +385,7 @@ def setup
Gem::Security.reset
Gem.loaded_specs.clear
+ Gem.instance_variable_set(:@activated_gem_paths, 0)
Gem.clear_default_specs
Bundler.reset!
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index f36892f8cc..9f2fe3439a 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -382,6 +382,17 @@ def test_default_gem_require_activates_just_once
assert_equal 0, times_called
end
+ def test_second_gem_require_does_not_resolve_path_manually_before_going_through_standard_require
+ a1 = util_spec "a", "1", nil, "lib/test_gem_require_a.rb"
+ install_gem a1
+
+ assert_require "test_gem_require_a"
+
+ stub(:gem_original_require, ->(path) { assert_equal "test_gem_require_a", path }) do
+ require "test_gem_require_a"
+ end
+ end
+
def test_realworld_default_gem
testing_ruby_repo = !ENV["GEM_COMMAND"].nil?
skip "this test can't work under ruby-core setup" if testing_ruby_repo || java_platform?
From ae95885dff6189c5ac59bbdf685cb4ec4751fdef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Tue, 19 May 2020 14:08:19 +0200
Subject: [PATCH 2/5] Refactor `Gem.load_path_insert_index`
---
lib/rubygems.rb | 13 +++----------
lib/rubygems/core_ext/kernel_require.rb | 5 +----
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index d1a9a1c7e1..ca80326459 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -659,7 +659,7 @@ def self.load_path_insert_index
index = $LOAD_PATH.index RbConfig::CONFIG['sitelibdir']
- index
+ index || 0
end
##
@@ -676,15 +676,8 @@ def self.activated_gem_paths
def self.add_to_load_path(*paths)
@activated_gem_paths = activated_gem_paths + paths.size
- insert_index = load_path_insert_index
-
- if insert_index
- # gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(insert_index, *paths)
- else
- # we are probably testing in core, -I and RUBYLIB don't apply
- $LOAD_PATH.unshift(*paths)
- end
+ # gem directories must come after -I and ENV['RUBYLIB']
+ $LOAD_PATH.insert(Gem.load_path_insert_index, *paths)
end
@yaml_loaded = false
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 7625ce1bee..decf4829f1 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -44,10 +44,7 @@ def require(path)
resolved_path = begin
rp = nil
Gem.suffixes.each do |s|
- load_path_insert_index = Gem.load_path_insert_index
- break unless load_path_insert_index
-
- $LOAD_PATH[0...load_path_insert_index - Gem.activated_gem_paths].each do |lp|
+ $LOAD_PATH[0...Gem.load_path_insert_index - Gem.activated_gem_paths].each do |lp|
safe_lp = lp.dup.tap(&Gem::UNTAINT)
begin
if File.symlink? safe_lp # for backward compatibility
From da1492e9d7b28d068fbfbb0ba1cafcc516681567 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Tue, 19 May 2020 14:32:12 +0200
Subject: [PATCH 3/5] Extract a local outside the loop
---
lib/rubygems/core_ext/kernel_require.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index decf4829f1..6a7faaf2d1 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -43,8 +43,9 @@ def require(path)
# https://github.com/rubygems/rubygems/pull/1868
resolved_path = begin
rp = nil
+ load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths
Gem.suffixes.each do |s|
- $LOAD_PATH[0...Gem.load_path_insert_index - Gem.activated_gem_paths].each do |lp|
+ $LOAD_PATH[0...load_path_check_index].each do |lp|
safe_lp = lp.dup.tap(&Gem::UNTAINT)
begin
if File.symlink? safe_lp # for backward compatibility
From 22ad5717c38feda2375b53628d15ae3db2195684 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Thu, 21 May 2020 15:20:57 +0200
Subject: [PATCH 4/5] Fix `$LOADED_FEATURES` cache sometimes not respected
In the cases where the initial manually `-I` path resolution succeeded,
we were passing a full path to the original require effectively skipping
the `$LOADED_FEATURES` cache. With this change, we _only_ do the
resolution when a matching requirable path is found in a default gem. In
that case, we skip activation of the default gem if we detect that the
required file will be picked up for a `-I` path.
---
lib/rubygems/core_ext/kernel_require.rb | 53 +++++++++++--------------
test/rubygems/test_require.rb | 29 ++++++++++++++
2 files changed, 53 insertions(+), 29 deletions(-)
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 6a7faaf2d1..81e37b98bf 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -39,46 +39,41 @@ def require(path)
path = path.to_path if path.respond_to? :to_path
- # Ensure -I beats a default gem
- # https://github.com/rubygems/rubygems/pull/1868
- resolved_path = begin
- rp = nil
- load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths
- Gem.suffixes.each do |s|
- $LOAD_PATH[0...load_path_check_index].each do |lp|
- safe_lp = lp.dup.tap(&Gem::UNTAINT)
- begin
- if File.symlink? safe_lp # for backward compatibility
- next
+ if spec = Gem.find_unresolved_default_spec(path)
+ # Ensure -I beats a default gem
+ # https://github.com/rubygems/rubygems/pull/1868
+ resolved_path = begin
+ rp = nil
+ load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths
+ Gem.suffixes.each do |s|
+ $LOAD_PATH[0...load_path_check_index].each do |lp|
+ safe_lp = lp.dup.tap(&Gem::UNTAINT)
+ begin
+ if File.symlink? safe_lp # for backward compatibility
+ next
+ end
+ rescue SecurityError
+ RUBYGEMS_ACTIVATION_MONITOR.exit
+ raise
end
- rescue SecurityError
- RUBYGEMS_ACTIVATION_MONITOR.exit
- raise
- end
- full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
- if File.file?(full_path)
- rp = full_path
- break
+ full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}"))
+ if File.file?(full_path)
+ rp = full_path
+ break
+ end
end
+ break if rp
end
- break if rp
+ rp
end
- rp
- end
- if resolved_path
- RUBYGEMS_ACTIVATION_MONITOR.exit
- return gem_original_require(resolved_path)
- end
-
- if spec = Gem.find_unresolved_default_spec(path)
begin
Kernel.send(:gem, spec.name, Gem::Requirement.default_prerelease)
rescue Exception
RUBYGEMS_ACTIVATION_MONITOR.exit
raise
- end
+ end unless resolved_path
end
# If there are no unresolved deps, then we can use just try
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index 9f2fe3439a..2b11e26dfe 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -45,6 +45,35 @@ def refute_require(path)
refute require(path), "'#{path}' was not yet required"
end
+ def test_respect_loaded_features_caching_like_standard_require
+ dir = Dir.mktmpdir("test_require", @tempdir)
+
+ lp1 = File.join dir, 'foo1'
+ foo1 = File.join lp1, 'foo.rb'
+
+ FileUtils.mkdir_p lp1
+ File.open(foo1, 'w') { |f| f.write "class Object; HELLO = 'foo1' end" }
+
+ lp = $LOAD_PATH.dup
+
+ $LOAD_PATH.unshift lp1
+ assert_require 'foo'
+ assert_equal "foo1", ::Object::HELLO
+
+ lp2 = File.join dir, 'foo2'
+ foo2 = File.join lp2, 'foo.rb'
+
+ FileUtils.mkdir_p lp2
+ File.open(foo2, 'w') { |f| f.write "class Object; HELLO = 'foo2' end" }
+
+ $LOAD_PATH.unshift lp2
+ refute_require 'foo'
+ assert_equal "foo1", ::Object::HELLO
+ ensure
+ $LOAD_PATH.replace lp
+ Object.send :remove_const, :HELLO if Object.const_defined? :HELLO
+ end
+
# Providing -I on the commandline should always beat gems
def test_dash_i_beats_gems
a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
From db872c7a18d616f4447bdcca3130be6db9e5cb03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Sat, 23 May 2020 20:18:41 +0200
Subject: [PATCH 5/5] Remove direct reference to PR
The code is quite different now, so I think the link might be even
confusing. If you want to know more, use git history.
---
lib/rubygems/core_ext/kernel_require.rb | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 81e37b98bf..115ae0cb50 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -41,7 +41,6 @@ def require(path)
if spec = Gem.find_unresolved_default_spec(path)
# Ensure -I beats a default gem
- # https://github.com/rubygems/rubygems/pull/1868
resolved_path = begin
rp = nil
load_path_check_index = Gem.load_path_insert_index - Gem.activated_gem_paths

View File

@ -1,92 +0,0 @@
From c5197b2ab35ba389f48918e0c773b43b6dca2fa5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Fri, 7 Feb 2020 17:16:05 +0100
Subject: [PATCH 1/3] Tweaks to get test passing more reliably
---
test/rubygems/test_require.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index 7cffbfa7fe..67c55416d4 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -567,18 +567,20 @@ def util_install_extension_file(name)
write_file File.join(@tempdir, "extconf.rb") do |io|
io.write <<-RUBY
require "mkmf"
+ CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
create_makefile("#{name}")
RUBY
end
write_file File.join(@tempdir, "#{name}.c") do |io|
io.write <<-C
- #include <ruby.h>
void Init_#{name}() { }
C
end
- spec.files += ["extconf.rb", "#{name}.c"]
+ write_file File.join(@tempdir, "depend")
+
+ spec.files += ["extconf.rb", "depend", "#{name}.c"]
so = File.join(spec.gem_dir, "#{name}.#{RbConfig::CONFIG["DLEXT"]}")
refute_path_exists so
From 7bfd7319cd751837c3ccaf1d97b02846eaaf39d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Tue, 11 Feb 2020 11:56:06 +0100
Subject: [PATCH 2/3] Fix bug bug calculating $LOAD_PATH's to check in
`require`
In `Gem.load_path_insert_index` is not set, we end up having
`$LOAD_PATH[0...-1]`, unintentionally skipping the last $LOAD_PATH entry
from the check.
The correct thing to do in that case is to not even try since we have no
way of distinguisng default LOAD_PATH entries from those added with -I.
---
lib/rubygems/core_ext/kernel_require.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 369f2c743e..a8d170f13a 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -44,7 +44,10 @@ def require(path)
resolved_path = begin
rp = nil
Gem.suffixes.each do |s|
- $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp|
+ load_path_insert_index = Gem.load_path_insert_index
+ break unless load_path_insert_index
+
+ $LOAD_PATH[0...load_path_insert_index].each do |lp|
safe_lp = lp.dup.tap(&Gem::UNTAINT)
begin
if File.symlink? safe_lp # for backward compatibility
From 4fc0ab21c0f7713829abb522ce3b6d8e24c126b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Fri, 14 Feb 2020 02:03:04 +0100
Subject: [PATCH 3/3] Exclude empty suffix from `-I` require loop
---
lib/rubygems/core_ext/kernel_require.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index a8d170f13a..9712fb6ac0 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -43,7 +43,7 @@ def require(path)
# https://github.com/rubygems/rubygems/pull/1868
resolved_path = begin
rp = nil
- Gem.suffixes.each do |s|
+ Gem.suffixes[1..-1].each do |s|
load_path_insert_index = Gem.load_path_insert_index
break unless load_path_insert_index

View File

@ -1,29 +0,0 @@
From 301e30bf97dd603ca81d52b90186908575c4ddf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@riseup.net>
Date: Tue, 25 Feb 2020 15:01:44 +0100
Subject: [PATCH] Revert "Exclude empty suffix from `-I` require loop"
This reverts commit 4fc0ab21c0f7713829abb522ce3b6d8e24c126b3.
Technically, extensionless ruby files are valid ruby files that can be
required. For example, `bin/bundle` is sometimes required from other
binstubs even if it's also runnable directly.
So, we should technically consider this kind of files too.
---
lib/rubygems/core_ext/kernel_require.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 9712fb6ac0..a8d170f13a 100644
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -43,7 +43,7 @@ def require(path)
# https://github.com/rubygems/rubygems/pull/1868
resolved_path = begin
rp = nil
- Gem.suffixes[1..-1].each do |s|
+ Gem.suffixes.each do |s|
load_path_insert_index = Gem.load_path_insert_index
break unless load_path_insert_index

View File

@ -1 +1 @@
SHA512 (ruby-2.7.2.tar.xz) = 7972278b096aa768c7adf2befd26003e18781a29ca317640317d30d93d6e963ded197724c8e2f1dfe1e838c5647176d414a74732a62e931fb50d6f2e0f777349
SHA512 (ruby-3.3.4.tar.xz) = b26461a13ff82a08a282f10108028bb2a2e4a28da6182a291062fc54089c6655d79c22cc69d59156f9b11cb10a17fe8c69d489343fbae123a45f03361b95c9eb

34
test_openssl_fips.rb Normal file
View File

@ -0,0 +1,34 @@
require 'openssl'
# Run openssl tests in OpenSSL FIPS. See the link below for how to test.
# https://github.com/ruby/openssl/blob/master/.github/workflows/test.yml
# - step name: test on fips module
# Listing the testing files by an array explicitly rather than the `Dir.glob`
# to prevent the test files from not loading unintentionally.
TEST_FILES = %w[
test/openssl/test_fips.rb
test/openssl/test_pkey.rb
].freeze
if ARGV.empty?
puts 'ERROR: Argument base_dir required.'
puts "Usage: #{__FILE__} base_dir [options]"
exit false
end
BASE_DIR = ARGV[0]
abs_test_files = TEST_FILES.map { |file| File.join(BASE_DIR, file) }
# Set Fedora/RHEL downstream OpenSSL downstream environment variable to enable
# FIPS module in non-FIPS OS environment. It is available in Fedora 38 or later
# versions.
# https://src.fedoraproject.org/rpms/openssl/blob/rawhide/f/0009-Add-Kernel-FIPS-mode-flag-support.patch
ENV['OPENSSL_FORCE_FIPS_MODE'] = '1'
# A flag to tell the tests the current environment is FIPS enabled.
# https://github.com/ruby/openssl/blob/master/test/openssl/test_fips.rb
ENV['TEST_RUBY_OPENSSL_FIPS_ENABLED'] = 'true'
abs_test_files.each do |file|
puts "INFO: Loading #{file}."
require file
end