diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-02 11:48:18 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-02 11:48:18 +0000 |
commit | f28be7e02d113bd26c33cb94e65004055576c065 (patch) | |
tree | 48b87f5a2b647e1207bae5e29f40d6d5b526978d /lib/rubygems/commands | |
parent | 537024433720d7c54cba9bab4596638f59fbadc9 (diff) |
Merge rubygems/rubygems from upstream.
The current master branch is
https://github.com/rubygems/rubygems/commit/97b264f0fa248c864b6ee9a23d3ff1cdd217dddb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/commands')
-rw-r--r-- | lib/rubygems/commands/cert_command.rb | 1 | ||||
-rw-r--r-- | lib/rubygems/commands/pristine_command.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/commands/setup_command.rb | 19 | ||||
-rw-r--r-- | lib/rubygems/commands/uninstall_command.rb | 22 |
4 files changed, 25 insertions, 19 deletions
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb index 5695460d94..72400f3edd 100644 --- a/lib/rubygems/commands/cert_command.rb +++ b/lib/rubygems/commands/cert_command.rb @@ -319,5 +319,4 @@ For further reading on signing gems see `ri Gem::Security`. email =~ /\A.+@.+\z/ end - end if defined?(OpenSSL::SSL) diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index 95e9ed0a15..a25b690afc 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -104,7 +104,7 @@ extensions will be restored. end.flatten end - specs = specs.select{|spec| spec.platform == RUBY_ENGINE } + specs = specs.select{|spec| RUBY_ENGINE == spec.platform || Gem::Platform.local === spec.platform } if specs.to_a.empty? raise Gem::Exception, diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb index 975eca593d..e3afc8cff8 100644 --- a/lib/rubygems/commands/setup_command.rb +++ b/lib/rubygems/commands/setup_command.rb @@ -165,7 +165,7 @@ By default, this RubyGems will install gem as: remove_old_lib_files lib_dir - install_default_bundler_gem + install_default_bundler_gem bin_dir if mode = options[:dir_mode] @mkdirs.uniq! @@ -234,21 +234,19 @@ By default, this RubyGems will install gem as: end end - def install_executables(bin_dir) @bin_file_names = [] prog_mode = options[:prog_mode] || 0755 executables = { 'gem' => 'bin' } - executables['bundler'] = 'bundler/exe' if Gem::USE_BUNDLER_FOR_GEMDEPS executables.each do |tool, path| say "Installing #{tool} executable" if @verbose Dir.chdir path do bin_files = Dir['*'] - bin_files -= %w[update_rubygems bundler bundle_ruby] + bin_files -= %w[update_rubygems] bin_files.each do |bin_file| bin_file_formatted = if options[:format_executable] @@ -383,7 +381,7 @@ By default, this RubyGems will install gem as: return false end - def install_default_bundler_gem + def install_default_bundler_gem(bin_dir) return unless Gem::USE_BUNDLER_FOR_GEMDEPS specs_dir = Gem::Specification.default_specifications_dir @@ -428,13 +426,12 @@ By default, this RubyGems will install gem as: cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e) end - if Gem.win_platform? - require 'rubygems/installer' + require 'rubygems/installer' - installer = Gem::Installer.for_spec bundler_spec - bundler_spec.executables.each do |e| - installer.generate_windows_script e, bundler_spec.bin_dir - end + Dir.chdir("bundler") do + built_gem = Gem::Package.build(bundler_spec) + installer = Gem::Installer.at(built_gem, env_shebang: options[:env_shebang], install_as_default: true, bin_dir: bin_dir, wrappers: true) + installer.install end say "Bundler #{bundler_spec.version} installed" diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index 698ff4b555..68e048c010 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -148,10 +148,13 @@ that is a dependency of an existing gem. You can use the def uninstall_specific deplist = Gem::DependencyList.new + original_gem_version = {} get_all_gem_names_and_versions.each do |name, version| - requirement = Array(version || options[:version]) - gem_specs = Gem::Specification.find_all_by_name(name, *requirement) + original_gem_version[name] = version || options[:version] + + gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name]) + say("Gem '#{name}' is not installed") if gem_specs.empty? gem_specs.each do |spec| deplist.add spec @@ -160,16 +163,23 @@ that is a dependency of an existing gem. You can use the deps = deplist.strongly_connected_components.flatten.reverse + gems_to_uninstall = {} + deps.each do |dep| - options[:version] = dep.version - uninstall_gem(dep.name) + unless gems_to_uninstall[dep.name] + gems_to_uninstall[dep.name] = true + + unless original_gem_version[dep.name] == Gem::Requirement.default + options[:version] = dep.version + end + + uninstall_gem(dep.name) + end end end def uninstall_gem(gem_name) uninstall(gem_name) - rescue Gem::InstallError - nil rescue Gem::GemNotInHomeException => e spec = e.spec alert("In order to remove #{spec.name}, please execute:\n" + |