summaryrefslogtreecommitdiff
path: root/lib/rubygems/commands/setup_command.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/commands/setup_command.rb')
-rw-r--r--lib/rubygems/commands/setup_command.rb43
1 files changed, 29 insertions, 14 deletions
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 7844e9d199..579776df7e 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -17,6 +17,7 @@ class Gem::Commands::SetupCommand < Gem::Command
super 'setup', 'Install RubyGems',
:format_executable => true, :document => %w[ri],
+ :force => true,
:site_or_vendor => 'sitelibdir',
:destdir => '', :prefix => '', :previous_version => '',
:regenerate_binstubs => true
@@ -88,6 +89,11 @@ class Gem::Commands::SetupCommand < Gem::Command
options[:regenerate_binstubs] = value
end
+ add_option '-f', '--[no-]force',
+ 'Forcefully overwrite binstubs' do |value, options|
+ options[:force] = value
+ end
+
add_option('-E', '--[no-]env-shebang',
'Rewrite executables with a shebang',
'of /usr/bin/env') do |value, options|
@@ -199,10 +205,10 @@ By default, this RubyGems will install gem as:
say
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
- 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 "to remove it by hand."
say
@@ -235,8 +241,6 @@ By default, this RubyGems will install gem as:
end
def install_executables(bin_dir)
- @bin_file_names = []
-
prog_mode = options[:prog_mode] || 0755
executables = { 'gem' => 'bin' }
@@ -249,13 +253,7 @@ By default, this RubyGems will install gem as:
bin_files -= %w[update_rubygems]
bin_files.each do |bin_file|
- bin_file_formatted = if options[:format_executable]
- Gem.default_exec_format % bin_file
- else
- bin_file
- end
-
- dest_file = File.join bin_dir, bin_file_formatted
+ dest_file = target_bin_path(bin_dir, bin_file)
bin_tmp_file = File.join Dir.tmpdir, "#{bin_file}.#{$$}"
begin
@@ -267,7 +265,7 @@ By default, this RubyGems will install gem as:
end
install bin_tmp_file, dest_file, :mode => prog_mode
- @bin_file_names << dest_file
+ bin_file_names << dest_file
ensure
rm bin_tmp_file
end
@@ -429,13 +427,15 @@ By default, this RubyGems will install gem as:
Dir.chdir("bundler") do
built_gem = Gem::Package.build(bundler_spec)
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
ensure
FileUtils.rm_f built_gem
end
end
+ bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
+
say "Bundler #{bundler_spec.version} installed"
end
@@ -592,7 +592,7 @@ abort "#{deprecation_message}"
history_string = ""
until versions.length == 0 or
- versions.shift < options[:previous_version] do
+ versions.shift <= options[:previous_version] do
history_string += version_lines.shift + text.shift
end
@@ -626,4 +626,19 @@ abort "#{deprecation_message}"
command.invoke(*args)
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