Upstream fix adding -C flag instead of changing directory for gem build.

This commit is contained in:
Vít Ondruch 2019-01-24 17:18:59 +01:00
parent 1e60df6dc1
commit b610699f35
3 changed files with 89 additions and 96 deletions

View File

@ -1,95 +0,0 @@
From 5168efc9ba0a0644c4fd1dbe09c1799f71301e42 Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Tue, 8 Jan 2019 14:51:46 +0100
Subject: [PATCH] Revert 90e676886e681e16e34ef58e078bf0a0aae8b54f
---
lib/rubygems/commands/build_command.rb | 26 ++++++-------
.../test_gem_commands_build_command.rb | 37 -------------------
2 files changed, 12 insertions(+), 51 deletions(-)
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index e59471e976..3120236f9f 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -60,20 +60,18 @@ def execute
end
if File.exist? gemspec
- Dir.chdir(File.dirname(gemspec)) do
- spec = Gem::Specification.load File.basename(gemspec)
-
- if spec
- Gem::Package.build(
- spec,
- options[:force],
- options[:strict],
- options[:output]
- )
- else
- alert_error "Error loading gemspec. Aborting."
- terminate_interaction 1
- end
+ spec = Gem::Specification.load gemspec
+
+ if spec
+ Gem::Package.build(
+ spec,
+ options[:force],
+ options[:strict],
+ options[:output]
+ )
+ else
+ alert_error "Error loading gemspec. Aborting."
+ terminate_interaction 1
end
else
alert_error "Gemspec file not found: #{gemspec}"
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index ac82a408c7..fa5e7454f3 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -192,43 +192,6 @@ def test_execute_missing_file
assert_equal "ERROR: Gemspec file not found: some_gem\n", @ui.error
end
- def test_execute_outside_dir
- gemspec_dir = File.join @tempdir, 'build_command_gem'
- gemspec_file = File.join gemspec_dir, @gem.spec_name
- readme_file = File.join gemspec_dir, 'README.md'
-
- FileUtils.mkdir_p gemspec_dir
-
- File.open readme_file, 'w' do |f|
- f.write "My awesome gem"
- end
-
- File.open gemspec_file, 'w' do |gs|
- gs.write @gem.to_ruby
- end
-
- @cmd.options[:args] = [gemspec_file]
-
- use_ui @ui do
- @cmd.execute
- end
-
- output = @ui.output.split "\n"
- assert_equal " Successfully built RubyGem", output.shift
- assert_equal " Name: some_gem", output.shift
- assert_equal " Version: 2", output.shift
- assert_equal " File: some_gem-2.gem", output.shift
- assert_equal [], output
-
- gem_file = File.join gemspec_dir, File.basename(@gem.cache_file)
- assert File.exist?(gem_file)
-
- spec = Gem::Package.new(gem_file).spec
-
- assert_equal "some_gem", spec.name
- assert_equal "this is a summary", spec.summary
- end
-
def test_can_find_gemspecs_without_dot_gemspec
gemspec_file = File.join(@tempdir, @gem.spec_name)

View File

@ -146,7 +146,7 @@ Patch10: ruby-2.6.0-Try-to-update-cert.patch
# `gem build ../foo.gemspec` changes directory, which does not play well with
# gems unpacked by setup macro.
# https://github.com/rubygems/rubygems/issues/2587
Patch11: ruby-2.6.0-No-chdir-for-build.patch
Patch11: rubygems-3.0.3-Restore-gem-build-behavior-and-introdcue-the-C-flag-to-gem-build.patch
# This allows to loosen the RDoc dependency again.
# https://github.com/rubygems/rubygems/pull/2604
Patch12: rubygems-3.0.3-Avoid-rdoc-hook-when-its-failed-to-load-rdoc-library.patch

View File

@ -0,0 +1,88 @@
From f4061357d812e9033f07ae3f8f44c4e26839f1e5 Mon Sep 17 00:00:00 2001
From: bronzdoc <lsagastume1990@gmail.com>
Date: Mon, 14 Jan 2019 09:46:29 -0600
Subject: [PATCH] Restore gem build behavior and introdcue the "-C" flag to gem
build
---
lib/rubygems/commands/build_command.rb | 41 +++++++++++++------
.../test_gem_commands_build_command.rb | 1 +
2 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/lib/rubygems/commands/build_command.rb b/lib/rubygems/commands/build_command.rb
index e59471e976..761b80ee94 100644
--- a/lib/rubygems/commands/build_command.rb
+++ b/lib/rubygems/commands/build_command.rb
@@ -18,6 +18,10 @@ def initialize
add_option '-o', '--output FILE', 'output gem with the given filename' do |value, options|
options[:output] = value
end
+
+ add_option '-C PATH', '', 'Run as if gem build was started in <PATH> instead of the current working directory.' do |value, options|
+ options[:build_path] = value
+ end
end
def arguments # :nodoc:
@@ -60,25 +64,36 @@ def execute
end
if File.exist? gemspec
- Dir.chdir(File.dirname(gemspec)) do
- spec = Gem::Specification.load File.basename(gemspec)
-
- if spec
- Gem::Package.build(
- spec,
- options[:force],
- options[:strict],
- options[:output]
- )
- else
- alert_error "Error loading gemspec. Aborting."
- terminate_interaction 1
+ spec = Gem::Specification.load(gemspec)
+
+ if options[:build_path]
+ Dir.chdir(File.dirname(gemspec)) do
+ spec = Gem::Specification.load File.basename(gemspec)
+ build_package(spec)
end
+ else
+ build_package(spec)
end
+
else
alert_error "Gemspec file not found: #{gemspec}"
terminate_interaction 1
end
end
+ private
+
+ def build_package(spec)
+ if spec
+ Gem::Package.build(
+ spec,
+ options[:force],
+ options[:strict],
+ options[:output]
+ )
+ else
+ alert_error "Error loading gemspec. Aborting."
+ terminate_interaction 1
+ end
+ end
end
diff --git a/test/rubygems/test_gem_commands_build_command.rb b/test/rubygems/test_gem_commands_build_command.rb
index ac82a408c7..02d1b98e8f 100644
--- a/test/rubygems/test_gem_commands_build_command.rb
+++ b/test/rubygems/test_gem_commands_build_command.rb
@@ -207,6 +207,7 @@ def test_execute_outside_dir
gs.write @gem.to_ruby
end
+ @cmd.options[:build_path] = gemspec_dir
@cmd.options[:args] = [gemspec_file]
use_ui @ui do