Merge RubyGems 3.1.2
This commit is contained in:
parent
fac60be324
commit
e672494cd7
@ -9,7 +9,7 @@
|
|||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
module Gem
|
module Gem
|
||||||
VERSION = "3.1.1".freeze
|
VERSION = "3.1.2".freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
# Must be first since it unloads the prelude from 1.9.2
|
# Must be first since it unloads the prelude from 1.9.2
|
||||||
|
@ -17,6 +17,7 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|||||||
|
|
||||||
super 'setup', 'Install RubyGems',
|
super 'setup', 'Install RubyGems',
|
||||||
:format_executable => true, :document => %w[ri],
|
:format_executable => true, :document => %w[ri],
|
||||||
|
:force => true,
|
||||||
:site_or_vendor => 'sitelibdir',
|
:site_or_vendor => 'sitelibdir',
|
||||||
:destdir => '', :prefix => '', :previous_version => '',
|
:destdir => '', :prefix => '', :previous_version => '',
|
||||||
:regenerate_binstubs => true
|
:regenerate_binstubs => true
|
||||||
@ -88,6 +89,11 @@ class Gem::Commands::SetupCommand < Gem::Command
|
|||||||
options[:regenerate_binstubs] = value
|
options[:regenerate_binstubs] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_option '-f', '--[no-]force',
|
||||||
|
'Forcefully overwrite binstubs' do |value, options|
|
||||||
|
options[:force] = value
|
||||||
|
end
|
||||||
|
|
||||||
add_option('-E', '--[no-]env-shebang',
|
add_option('-E', '--[no-]env-shebang',
|
||||||
'Rewrite executables with a shebang',
|
'Rewrite executables with a shebang',
|
||||||
'of /usr/bin/env') do |value, options|
|
'of /usr/bin/env') do |value, options|
|
||||||
@ -199,10 +205,10 @@ By default, this RubyGems will install gem as:
|
|||||||
say
|
say
|
||||||
|
|
||||||
say "RubyGems installed the following executables:"
|
say "RubyGems installed the following executables:"
|
||||||
say @bin_file_names.map { |name| "\t#{name}\n" }
|
say bin_file_names.map { |name| "\t#{name}\n" }
|
||||||
say
|
say
|
||||||
|
|
||||||
unless @bin_file_names.grep(/#{File::SEPARATOR}gem$/)
|
unless bin_file_names.grep(/#{File::SEPARATOR}gem$/)
|
||||||
say "If `gem` was installed by a previous RubyGems installation, you may need"
|
say "If `gem` was installed by a previous RubyGems installation, you may need"
|
||||||
say "to remove it by hand."
|
say "to remove it by hand."
|
||||||
say
|
say
|
||||||
@ -235,8 +241,6 @@ By default, this RubyGems will install gem as:
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install_executables(bin_dir)
|
def install_executables(bin_dir)
|
||||||
@bin_file_names = []
|
|
||||||
|
|
||||||
prog_mode = options[:prog_mode] || 0755
|
prog_mode = options[:prog_mode] || 0755
|
||||||
|
|
||||||
executables = { 'gem' => 'bin' }
|
executables = { 'gem' => 'bin' }
|
||||||
@ -249,13 +253,7 @@ By default, this RubyGems will install gem as:
|
|||||||
bin_files -= %w[update_rubygems]
|
bin_files -= %w[update_rubygems]
|
||||||
|
|
||||||
bin_files.each do |bin_file|
|
bin_files.each do |bin_file|
|
||||||
bin_file_formatted = if options[:format_executable]
|
dest_file = target_bin_path(bin_dir, bin_file)
|
||||||
Gem.default_exec_format % bin_file
|
|
||||||
else
|
|
||||||
bin_file
|
|
||||||
end
|
|
||||||
|
|
||||||
dest_file = File.join bin_dir, bin_file_formatted
|
|
||||||
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
|
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -267,7 +265,7 @@ By default, this RubyGems will install gem as:
|
|||||||
end
|
end
|
||||||
|
|
||||||
install bin_tmp_file, dest_file, :mode => prog_mode
|
install bin_tmp_file, dest_file, :mode => prog_mode
|
||||||
@bin_file_names << dest_file
|
bin_file_names << dest_file
|
||||||
ensure
|
ensure
|
||||||
rm bin_tmp_file
|
rm bin_tmp_file
|
||||||
end
|
end
|
||||||
@ -429,13 +427,15 @@ By default, this RubyGems will install gem as:
|
|||||||
Dir.chdir("bundler") do
|
Dir.chdir("bundler") do
|
||||||
built_gem = Gem::Package.build(bundler_spec)
|
built_gem = Gem::Package.build(bundler_spec)
|
||||||
begin
|
begin
|
||||||
installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], format_executable: options[:format_executable], install_as_default: true, bin_dir: bin_dir, wrappers: true)
|
installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], format_executable: options[:format_executable], force: options[:force], install_as_default: true, bin_dir: bin_dir, wrappers: true)
|
||||||
installer.install
|
installer.install
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_f built_gem
|
FileUtils.rm_f built_gem
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
|
||||||
|
|
||||||
say "Bundler #{bundler_spec.version} installed"
|
say "Bundler #{bundler_spec.version} installed"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -592,7 +592,7 @@ abort "#{deprecation_message}"
|
|||||||
history_string = ""
|
history_string = ""
|
||||||
|
|
||||||
until versions.length == 0 or
|
until versions.length == 0 or
|
||||||
versions.shift < options[:previous_version] do
|
versions.shift <= options[:previous_version] do
|
||||||
history_string += version_lines.shift + text.shift
|
history_string += version_lines.shift + text.shift
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -626,4 +626,19 @@ abort "#{deprecation_message}"
|
|||||||
command.invoke(*args)
|
command.invoke(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def target_bin_path(bin_dir, bin_file)
|
||||||
|
bin_file_formatted = if options[:format_executable]
|
||||||
|
Gem.default_exec_format % bin_file
|
||||||
|
else
|
||||||
|
bin_file
|
||||||
|
end
|
||||||
|
File.join bin_dir, bin_file_formatted
|
||||||
|
end
|
||||||
|
|
||||||
|
def bin_file_names
|
||||||
|
@bin_file_names ||= []
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -164,6 +164,50 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Sets the bindir entry in RbConfig::CONFIG to +value+ and restores the
|
||||||
|
# original value when the block ends
|
||||||
|
#
|
||||||
|
def bindir(value)
|
||||||
|
bindir = RbConfig::CONFIG['bindir']
|
||||||
|
|
||||||
|
if value
|
||||||
|
RbConfig::CONFIG['bindir'] = value
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'bindir'
|
||||||
|
end
|
||||||
|
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
if bindir
|
||||||
|
RbConfig::CONFIG['bindir'] = bindir
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'bindir'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Sets the EXEEXT entry in RbConfig::CONFIG to +value+ and restores the
|
||||||
|
# original value when the block ends
|
||||||
|
#
|
||||||
|
def exeext(value)
|
||||||
|
exeext = RbConfig::CONFIG['EXEEXT']
|
||||||
|
|
||||||
|
if value
|
||||||
|
RbConfig::CONFIG['EXEEXT'] = value
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'EXEEXT'
|
||||||
|
end
|
||||||
|
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
if exeext
|
||||||
|
RbConfig::CONFIG['EXEEXT'] = exeext
|
||||||
|
else
|
||||||
|
RbConfig::CONFIG.delete 'EXEEXT'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: move to minitest
|
# TODO: move to minitest
|
||||||
def refute_path_exists(path, msg = nil)
|
def refute_path_exists(path, msg = nil)
|
||||||
msg = message(msg) { "Expected path '#{path}' to not exist" }
|
msg = message(msg) { "Expected path '#{path}' to not exist" }
|
||||||
|
@ -1917,16 +1917,11 @@ You may need to `gem install -g` to install missing gems
|
|||||||
end
|
end
|
||||||
|
|
||||||
def with_bindir_and_exeext(bindir, exeext)
|
def with_bindir_and_exeext(bindir, exeext)
|
||||||
orig_bindir = RbConfig::CONFIG['bindir']
|
bindir(bindir) do
|
||||||
orig_exe_ext = RbConfig::CONFIG['EXEEXT']
|
exeext(exeext) do
|
||||||
|
yield
|
||||||
RbConfig::CONFIG['bindir'] = bindir
|
end
|
||||||
RbConfig::CONFIG['EXEEXT'] = exeext
|
end
|
||||||
|
|
||||||
yield
|
|
||||||
ensure
|
|
||||||
RbConfig::CONFIG['bindir'] = orig_bindir
|
|
||||||
RbConfig::CONFIG['EXEEXT'] = orig_exe_ext
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_clean_path_to_ruby
|
def with_clean_path_to_ruby
|
||||||
|
@ -123,6 +123,18 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||||||
assert_equal "I changed it!\n", File.read(gem_bin_path)
|
assert_equal "I changed it!\n", File.read(gem_bin_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_execute_informs_about_installed_executables
|
||||||
|
use_ui @ui do
|
||||||
|
@cmd.execute
|
||||||
|
end
|
||||||
|
|
||||||
|
out = @ui.output.split "\n"
|
||||||
|
|
||||||
|
exec_line = out.shift until exec_line == "RubyGems installed the following executables:"
|
||||||
|
assert_equal "\t#{default_gem_bin_path}", out.shift
|
||||||
|
assert_equal "\t#{default_bundle_bin_path}", out.shift
|
||||||
|
end
|
||||||
|
|
||||||
def test_env_shebang_flag
|
def test_env_shebang_flag
|
||||||
gem_bin_path = gem_install 'a'
|
gem_bin_path = gem_install 'a'
|
||||||
write_file gem_bin_path do |io|
|
write_file gem_bin_path do |io|
|
||||||
@ -133,10 +145,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||||||
@cmd.options[:env_shebang] = true
|
@cmd.options[:env_shebang] = true
|
||||||
@cmd.execute
|
@cmd.execute
|
||||||
|
|
||||||
gem_exec = sprintf Gem.default_exec_format, 'gem'
|
|
||||||
default_gem_bin_path = File.join @install_dir, 'bin', gem_exec
|
|
||||||
bundle_exec = sprintf Gem.default_exec_format, 'bundle'
|
|
||||||
default_bundle_bin_path = File.join @install_dir, 'bin', bundle_exec
|
|
||||||
ruby_exec = sprintf Gem.default_exec_format, 'ruby'
|
ruby_exec = sprintf Gem.default_exec_format, 'ruby'
|
||||||
|
|
||||||
if Gem.win_platform?
|
if Gem.win_platform?
|
||||||
@ -212,10 +220,41 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||||||
|
|
||||||
# TODO: We need to assert to remove same version of bundler on gem_dir directory(It's not site_ruby dir)
|
# TODO: We need to assert to remove same version of bundler on gem_dir directory(It's not site_ruby dir)
|
||||||
|
|
||||||
# expect to not remove bundler-* direcotyr.
|
# expect to not remove bundler-* directory.
|
||||||
assert_path_exists 'default/gems/bundler-audit-1.0.0'
|
assert_path_exists 'default/gems/bundler-audit-1.0.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_install_default_bundler_gem_with_force_flag
|
||||||
|
@cmd.extend FileUtils
|
||||||
|
|
||||||
|
bin_dir = File.join(@gemhome, 'bin')
|
||||||
|
bundle_bin = File.join(bin_dir, 'bundle')
|
||||||
|
|
||||||
|
write_file bundle_bin do |f|
|
||||||
|
f.puts '#!/usr/bin/ruby'
|
||||||
|
f.puts ''
|
||||||
|
f.puts 'echo "hello"'
|
||||||
|
end
|
||||||
|
|
||||||
|
bindir(bin_dir) do
|
||||||
|
@cmd.options[:force] = true
|
||||||
|
|
||||||
|
@cmd.install_default_bundler_gem bin_dir
|
||||||
|
|
||||||
|
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
|
||||||
|
default_spec_path = File.join(Gem.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
|
||||||
|
spec = Gem::Specification.load(default_spec_path)
|
||||||
|
|
||||||
|
spec.executables.each do |e|
|
||||||
|
if Gem.win_platform?
|
||||||
|
assert_path_exists File.join(bin_dir, "#{e}.bat")
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_path_exists File.join bin_dir, Gem.default_exec_format % e
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_remove_old_lib_files
|
def test_remove_old_lib_files
|
||||||
lib = File.join @install_dir, 'lib'
|
lib = File.join @install_dir, 'lib'
|
||||||
lib_rubygems = File.join lib, 'rubygems'
|
lib_rubygems = File.join lib, 'rubygems'
|
||||||
@ -308,11 +347,6 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||||||
* Fixed release note display for LANG=C when installing rubygems
|
* Fixed release note display for LANG=C when installing rubygems
|
||||||
* π is tasty
|
* π is tasty
|
||||||
|
|
||||||
=== 2.0.2 / 2013-03-06
|
|
||||||
|
|
||||||
* Bug fixes:
|
|
||||||
* Other bugs fixed
|
|
||||||
|
|
||||||
EXPECTED
|
EXPECTED
|
||||||
|
|
||||||
output = @ui.output
|
output = @ui.output
|
||||||
@ -323,4 +357,16 @@ class TestGemCommandsSetupCommand < Gem::TestCase
|
|||||||
@ui.outs.set_encoding @default_external if @default_external
|
@ui.outs.set_encoding @default_external if @default_external
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def default_gem_bin_path
|
||||||
|
gem_exec = sprintf Gem.default_exec_format, 'gem'
|
||||||
|
File.join @install_dir, 'bin', gem_exec
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_bundle_bin_path
|
||||||
|
bundle_exec = sprintf Gem.default_exec_format, 'bundle'
|
||||||
|
File.join @install_dir, 'bin', bundle_exec
|
||||||
|
end
|
||||||
|
|
||||||
end unless Gem.java_platform?
|
end unless Gem.java_platform?
|
||||||
|
@ -104,32 +104,19 @@ end
|
|||||||
def test_check_executable_overwrite_default_bin_dir
|
def test_check_executable_overwrite_default_bin_dir
|
||||||
installer = setup_base_installer
|
installer = setup_base_installer
|
||||||
|
|
||||||
if defined?(RUBY_FRAMEWORK_VERSION)
|
bindir(Gem.bindir) do
|
||||||
orig_RUBY_FRAMEWORK_VERSION = RUBY_FRAMEWORK_VERSION
|
util_conflict_executable false
|
||||||
Object.send :remove_const, :RUBY_FRAMEWORK_VERSION
|
|
||||||
end
|
|
||||||
orig_bindir = RbConfig::CONFIG['bindir']
|
|
||||||
RbConfig::CONFIG['bindir'] = Gem.bindir
|
|
||||||
|
|
||||||
util_conflict_executable false
|
ui = Gem::MockGemUi.new "n\n"
|
||||||
|
use_ui ui do
|
||||||
|
e = assert_raises Gem::InstallError do
|
||||||
|
installer.generate_bin
|
||||||
|
end
|
||||||
|
|
||||||
ui = Gem::MockGemUi.new "n\n"
|
conflicted = File.join @gemhome, 'bin', 'executable'
|
||||||
use_ui ui do
|
assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
|
||||||
e = assert_raises Gem::InstallError do
|
e.message
|
||||||
installer.generate_bin
|
|
||||||
end
|
end
|
||||||
|
|
||||||
conflicted = File.join @gemhome, 'bin', 'executable'
|
|
||||||
assert_match %r%\A"executable" from a conflicts with (?:#{Regexp.quote(conflicted)}|installed executable from conflict)\z%,
|
|
||||||
e.message
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
|
|
||||||
orig_RUBY_FRAMEWORK_VERSION
|
|
||||||
if orig_bindir
|
|
||||||
RbConfig::CONFIG['bindir'] = orig_bindir
|
|
||||||
else
|
|
||||||
RbConfig::CONFIG.delete 'bindir'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user