diff --git a/ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch b/ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch new file mode 100644 index 0000000..42f47a9 --- /dev/null +++ b/ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch @@ -0,0 +1,91 @@ +From 29d9f866f686e81818fb9cf402c4fb479decb282 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= + +Date: Thu, 23 Jan 2020 15:33:42 +0900 +Subject: [PATCH 1/2] brace the fact that lchmod(2) can EOPNOTSUPP + +Musl libc has this function as a tiny wrapper of fchmodat(3posix). On +the other hand Linux kernel does not support changing modes of a symlink. +The operation always fails with EOPNOTSUPP. This fchmodat behaviour is +defined in POSIX. We have to take care of such exceptions. +--- + lib/fileutils.rb | 3 ++- + test/pathname/test_pathname.rb | 2 +- + test/ruby/test_notimp.rb | 19 ++++++++++++------- + 3 files changed, 15 insertions(+), 9 deletions(-) + +diff --git a/lib/fileutils.rb b/lib/fileutils.rb +index f56d7f9cb9..1a02d5435e 100644 +--- a/lib/fileutils.rb ++++ b/lib/fileutils.rb +@@ -1242,6 +1242,7 @@ def chmod(mode) + else + File.chmod mode, path() + end ++ rescue Errno::EOPNOTSUPP + end + + def chown(uid, gid) +@@ -1317,7 +1318,7 @@ def copy_metadata(path) + if st.symlink? + begin + File.lchmod mode, path +- rescue NotImplementedError ++ rescue NotImplementedError, Errno::EOPNOTSUPP + end + else + File.chmod mode, path +diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb +index 8a72b8026d..e381d3fa58 100644 +--- a/test/pathname/test_pathname.rb ++++ b/test/pathname/test_pathname.rb +@@ -823,7 +823,7 @@ def test_lchmod + old = path.lstat.mode + begin + path.lchmod(0444) +- rescue NotImplementedError ++ rescue NotImplementedError, Errno::EOPNOTSUPP + next + end + assert_equal(0444, path.lstat.mode & 0777) +diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb +index ddebb657bf..daa5a82d7b 100644 +--- a/test/ruby/test_notimp.rb ++++ b/test/ruby/test_notimp.rb +@@ -13,11 +13,11 @@ def test_respond_to_fork + + def test_respond_to_lchmod + assert_include(File.methods, :lchmod) +- if /linux/ =~ RUBY_PLATFORM +- assert_equal(false, File.respond_to?(:lchmod)) +- end +- if /freebsd/ =~ RUBY_PLATFORM ++ case RUBY_PLATFORM ++ when /freebsd/, /linux-musl/ + assert_equal(true, File.respond_to?(:lchmod)) ++ when /linux/ ++ assert_equal(false, File.respond_to?(:lchmod)) + end + end + +@@ -57,9 +57,14 @@ def test_call_lchmod + File.open(f, "w") {} + File.symlink f, g + newmode = 0444 +- File.lchmod newmode, "#{d}/g" +- snew = File.lstat(g) +- assert_equal(newmode, snew.mode & 0777) ++ begin ++ File.lchmod newmode, "#{d}/g" ++ rescue Errno::EOPNOTSUPP ++ skip $! ++ else ++ snew = File.lstat(g) ++ assert_equal(newmode, snew.mode & 0777) ++ end + } + end + end +-- +2.26.2 + diff --git a/ruby-2.8.0-Moved-not-implemented-method-tests.patch b/ruby-2.8.0-Moved-not-implemented-method-tests.patch new file mode 100644 index 0000000..8202043 --- /dev/null +++ b/ruby-2.8.0-Moved-not-implemented-method-tests.patch @@ -0,0 +1,130 @@ +From 5400fc3c67446e2f7f35ea317c596e71f0cb1ca4 Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Fri, 28 Feb 2020 21:15:37 +0900 +Subject: [PATCH 2/2] Moved not-implemented method tests [Bug #16662] + +Test not-implemented method with the dedicated methods, instead of +platform dependent features. +--- + test/-ext-/test_notimplement.rb | 7 +++ + test/ruby/test_notimp.rb | 90 --------------------------------- + 2 files changed, 7 insertions(+), 90 deletions(-) + delete mode 100644 test/ruby/test_notimp.rb + +diff --git a/test/-ext-/test_notimplement.rb b/test/-ext-/test_notimplement.rb +index 0eba7bdaf8..be8c3623cc 100644 +--- a/test/-ext-/test_notimplement.rb ++++ b/test/-ext-/test_notimplement.rb +@@ -10,6 +10,13 @@ def test_funcall_notimplement + end + + def test_respond_to ++ assert_include(Bug.methods(false), :notimplement) ++ assert_include(Bug::NotImplement.instance_methods(false), :notimplement) + assert_not_respond_to(Bug, :notimplement) + end ++ ++ def test_method_inspect_notimplement ++ assert_match(/not-implemented/, Bug.method(:notimplement).inspect) ++ assert_match(/not-implemented/, Bug::NotImplement.instance_method(:notimplement).inspect) ++ end + end +diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb +deleted file mode 100644 +index daa5a82d7b..0000000000 +--- a/test/ruby/test_notimp.rb ++++ /dev/null +@@ -1,90 +0,0 @@ +-# frozen_string_literal: false +-require 'test/unit' +-require 'timeout' +-require 'tmpdir' +- +-class TestNotImplement < Test::Unit::TestCase +- def test_respond_to_fork +- assert_include(Process.methods, :fork) +- if /linux/ =~ RUBY_PLATFORM +- assert_equal(true, Process.respond_to?(:fork)) +- end +- end +- +- def test_respond_to_lchmod +- assert_include(File.methods, :lchmod) +- case RUBY_PLATFORM +- when /freebsd/, /linux-musl/ +- assert_equal(true, File.respond_to?(:lchmod)) +- when /linux/ +- assert_equal(false, File.respond_to?(:lchmod)) +- end +- end +- +- def test_call_fork +- GC.start +- pid = nil +- ps = +- case RUBY_PLATFORM +- when /linux/ # assume Linux Distribution uses procps +- proc {`ps -eLf #{pid}`} +- when /freebsd/ +- proc {`ps -lH #{pid}`} +- when /darwin/ +- proc {`ps -lM #{pid}`} +- else +- proc {`ps -l #{pid}`} +- end +- assert_nothing_raised(Timeout::Error, ps) do +- Timeout.timeout(EnvUtil.apply_timeout_scale(5)) { +- pid = fork {} +- Process.wait pid +- pid = nil +- } +- end +- ensure +- if pid +- Process.kill(:KILL, pid) +- Process.wait pid +- end +- end if Process.respond_to?(:fork) +- +- def test_call_lchmod +- if File.respond_to?(:lchmod) +- Dir.mktmpdir {|d| +- f = "#{d}/f" +- g = "#{d}/g" +- File.open(f, "w") {} +- File.symlink f, g +- newmode = 0444 +- begin +- File.lchmod newmode, "#{d}/g" +- rescue Errno::EOPNOTSUPP +- skip $! +- else +- snew = File.lstat(g) +- assert_equal(newmode, snew.mode & 0777) +- end +- } +- end +- end +- +- def test_method_inspect_fork +- m = Process.method(:fork) +- if Process.respond_to?(:fork) +- assert_not_match(/not-implemented/, m.inspect) +- else +- assert_match(/not-implemented/, m.inspect) +- end +- end +- +- def test_method_inspect_lchmod +- m = File.method(:lchmod) +- if File.respond_to?(:lchmod) +- assert_not_match(/not-implemented/, m.inspect) +- else +- assert_match(/not-implemented/, m.inspect) +- end +- end +- +-end +-- +2.26.2 + diff --git a/ruby.spec b/ruby.spec index ac104dc..40d9cf4 100644 --- a/ruby.spec +++ b/ruby.spec @@ -154,6 +154,11 @@ Patch22: ruby-2.6.0-config-support-include-directive.patch # Use larger keys to prevent test failures. # https://github.com/ruby/openssl/pull/217 Patch23: ruby-2.6.0-use-larger-keys-for-SSL-tests.patch +# Fix lchmod test failures. +# https://github.com/ruby/ruby/commit/a19228f878d955eaf2cce086bcf53f46fdf894b9 +Patch41: ruby-2.8.0-Brace-the-fact-that-lchmod-can-EOPNOTSUPP.patch +# https://github.com/ruby/ruby/commit/72c02aa4b79731c7f25c9267f74b347f1946c704 +Patch42: ruby-2.8.0-Moved-not-implemented-method-tests.patch Requires: %{name}-libs%{?_isa} = %{version}-%{release} Suggests: rubypick @@ -543,6 +548,8 @@ rm -rf ext/fiddle/libffi* %patch22 -p1 %patch23 -p1 %patch24 -p1 +%patch41 -p1 +%patch42 -p1 # Provide an example of usage of the tapset: cp -a %{SOURCE3} . @@ -770,7 +777,12 @@ sed -i '/def test_mdns_each_address$/,/^ end$/ s/^/#/' test/resolv/test_mdns.rb # https://github.com/rubygems/rubygems/issues/2388 DISABLE_TESTS="$DISABLE_TESTS -n !/test_do_not_allow_invalid_client_cert_auth_connection/" -make check TESTS="-v $DISABLE_TESTS" +# Disable File.lchmod specs, which fails when building against glibc 2.31.9000. +# https://bugs.ruby-lang.org/issues/16749 +MSPECOPTS="$MSPECOPTS -P 'File.lchmod returns false from \#respond_to?'" +MSPECOPTS="$MSPECOPTS -P 'File.lchmod raises a NotImplementedError when called'" + +make check TESTS="-v $DISABLE_TESTS" MSPECOPT="-fs $MSPECOPTS" %files %license BSDL @@ -1091,6 +1103,7 @@ make check TESTS="-v $DISABLE_TESTS" %changelog * Wed Oct 14 2020 Jun Aruga - 2.5.5-106 - Fix checksec 2.0+ compatibility. +- Fix FTBFS due to glibc 2.31.9000 implementing lchmod(2). * Tue Apr 30 2019 Jun Aruga - 2.5.5-105 - Update to Ruby 2.5.5.