From 5467bfd5c37b21345ebe91095872ff3a6dbca106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Fri, 9 Oct 2020 13:45:46 +0200 Subject: [PATCH] Fix building rubygem- packages. Fix `Permission denied @ dir_s_mkdir - /usr/share/gems/plugins` issues. https://github.com/rubygems/rubygems/issues/3971 --- ruby.spec | 5 + ...ct-plugins-dir-when-using-build-root.patch | 143 ++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 rubygems-3.2.0-Install-to-correct-plugins-dir-when-using-build-root.patch diff --git a/ruby.spec b/ruby.spec index feda0f8..3c6eb96 100644 --- a/ruby.spec +++ b/ruby.spec @@ -147,6 +147,10 @@ Patch9: ruby-2.3.1-Rely-on-ldd-to-detect-glibc.patch # Fix fortifications on armv7hl. # https://bugs.ruby-lang.org/issues/16762 Patch11: ruby-2.8.0-Annotate-execstack.patch +# Fix `Permission denied @ dir_s_mkdir - /usr/share/gems/plugins` issues +# building rubygem- packages. +# https://github.com/rubygems/rubygems/pull/3972 +Patch12: rubygems-3.2.0-Install-to-correct-plugins-dir-when-using-build-root.patch # Avoid possible timeout errors in TestBugReporter#test_bug_reporter_add. # https://bugs.ruby-lang.org/issues/16492 Patch19: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch @@ -583,6 +587,7 @@ rm -rf ext/fiddle/libffi* %patch6 -p1 %patch9 -p1 %patch11 -p1 +%patch12 -p1 %patch19 -p1 # Provide an example of usage of the tapset: diff --git a/rubygems-3.2.0-Install-to-correct-plugins-dir-when-using-build-root.patch b/rubygems-3.2.0-Install-to-correct-plugins-dir-when-using-build-root.patch new file mode 100644 index 0000000..88a033e --- /dev/null +++ b/rubygems-3.2.0-Install-to-correct-plugins-dir-when-using-build-root.patch @@ -0,0 +1,143 @@ +From c3995fb9f5b520f05936ea6ec99d8d4fad18f024 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?David=20Rodr=C3=ADguez?= +Date: Mon, 28 Sep 2020 11:46:15 +0200 +Subject: [PATCH 1/3] Add tests for build_root ui messages + +--- + test/rubygems/test_gem_installer.rb | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb +index 1424b140d24..034a187fc0f 100644 +--- a/test/rubygems/test_gem_installer.rb ++++ b/test/rubygems/test_gem_installer.rb +@@ -1781,13 +1781,22 @@ def test_process_options + + def test_process_options_build_root + build_root = File.join @tempdir, 'build_root' ++ bin_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'bin') ++ gem_home = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, '')) + + @gem = setup_base_gem +- installer = Gem::Installer.at @gem, :build_root => build_root ++ installer = use_ui(@ui) { Gem::Installer.at @gem, :build_root => build_root } + + assert_equal Pathname(build_root), installer.build_root +- assert_equal File.join(build_root, @gemhome, 'bin'), installer.bin_dir +- assert_equal File.join(build_root, @gemhome), installer.gem_home ++ assert_equal bin_dir, installer.bin_dir ++ assert_equal gem_home, installer.gem_home ++ ++ errors = @ui.error.split("\n") ++ ++ assert_equal "WARNING: You build with buildroot.", errors.shift ++ assert_equal " Build root: #{build_root}", errors.shift ++ assert_equal " Bin dir: #{bin_dir}", errors.shift ++ assert_equal " Gem home: #{gem_home}", errors.shift + end + + def test_shebang_arguments + +From e1528db2c7dc8c7e5850e0754a7bb6e6dbc9009e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?David=20Rodr=C3=ADguez?= +Date: Mon, 28 Sep 2020 11:48:52 +0200 +Subject: [PATCH 2/3] Correctly set plugins dir when using `--build-root` + +--- + lib/rubygems/installer.rb | 1 + + test/rubygems/test_gem_installer.rb | 25 +++++++++++++++++++++++++ + 2 files changed, 26 insertions(+) + +diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb +index f4c4be4ac93..e982d2fd2ce 100644 +--- a/lib/rubygems/installer.rb ++++ b/lib/rubygems/installer.rb +@@ -697,6 +697,7 @@ def process_options # :nodoc: + @build_root = Pathname.new(@build_root).expand_path + @bin_dir = File.join(@build_root, options[:bin_dir] || Gem.bindir(@gem_home)) + @gem_home = File.join(@build_root, @gem_home) ++ @plugins_dir = File.join(@build_root, @plugins_dir.gsub(/^[a-zA-Z]:/, '')) + alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}" + end + end +diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb +index 034a187fc0f..ef6003c28fb 100644 +--- a/test/rubygems/test_gem_installer.rb ++++ b/test/rubygems/test_gem_installer.rb +@@ -798,6 +798,31 @@ def test_generate_plugins_with_user_install + assert File.exist?(user_path), 'plugin not written to user plugins_dir' + end + ++ def test_generate_plugins_with_build_root ++ spec = quick_gem 'a' do |s| ++ write_file File.join(@tempdir, 'lib', 'rubygems_plugin.rb') do |io| ++ io.write "puts __FILE__" ++ end ++ ++ s.files += %w[lib/rubygems_plugin.rb] ++ end ++ ++ util_build_gem spec ++ ++ File.chmod(0555, Gem.plugindir) ++ system_path = File.join(Gem.plugindir, 'a_plugin.rb') ++ ++ build_root = File.join(@tempdir, 'build_root') ++ build_root_path = File.join(build_root, Gem.plugindir.gsub(/^[a-zA-Z]:/, ''), 'a_plugin.rb') ++ ++ installer = Gem::Installer.at spec.cache_file, :build_root => build_root ++ ++ assert_equal spec, installer.install ++ ++ assert !File.exist?(system_path), 'plugin written incorrect written to system plugins_dir' ++ assert File.exist?(build_root_path), 'plugin not written to build_root' ++ end ++ + def test_keeps_plugins_up_to_date + # NOTE: version a-2 is already installed by setup hooks + + +From ba4df51949474a09479baf84374131ca095eda98 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?David=20Rodr=C3=ADguez?= +Date: Mon, 28 Sep 2020 11:51:00 +0200 +Subject: [PATCH 3/3] Also print plugins dir when using `--build-root` + +For consistency. +--- + lib/rubygems/installer.rb | 2 +- + test/rubygems/test_gem_installer.rb | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb +index e982d2fd2ce..b1c2ae4f237 100644 +--- a/lib/rubygems/installer.rb ++++ b/lib/rubygems/installer.rb +@@ -698,7 +698,7 @@ def process_options # :nodoc: + @bin_dir = File.join(@build_root, options[:bin_dir] || Gem.bindir(@gem_home)) + @gem_home = File.join(@build_root, @gem_home) + @plugins_dir = File.join(@build_root, @plugins_dir.gsub(/^[a-zA-Z]:/, '')) +- alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}" ++ alert_warning "You build with buildroot.\n Build root: #{@build_root}\n Bin dir: #{@bin_dir}\n Gem home: #{@gem_home}\n Plugins dir: #{@plugins_dir}" + end + end + +diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb +index ef6003c28fb..0a9a2e38dd8 100644 +--- a/test/rubygems/test_gem_installer.rb ++++ b/test/rubygems/test_gem_installer.rb +@@ -1808,6 +1808,7 @@ def test_process_options_build_root + build_root = File.join @tempdir, 'build_root' + bin_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'bin') + gem_home = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, '')) ++ plugins_dir = File.join(build_root, @gemhome.gsub(/^[a-zA-Z]:/, ''), 'plugins') + + @gem = setup_base_gem + installer = use_ui(@ui) { Gem::Installer.at @gem, :build_root => build_root } +@@ -1822,6 +1823,7 @@ def test_process_options_build_root + assert_equal " Build root: #{build_root}", errors.shift + assert_equal " Bin dir: #{bin_dir}", errors.shift + assert_equal " Gem home: #{gem_home}", errors.shift ++ assert_equal " Plugins dir: #{plugins_dir}", errors.shift + end + + def test_shebang_arguments