From 47f0248b0858898dd24d1e654cedf174059ca677 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 9 Jul 2013 23:21:36 +0000 Subject: * lib/rubygems: Import RubyGems 2.1 * test/rubygems: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/commands/cert_command.rb | 40 +++++++++++++++++++++------- lib/rubygems/commands/cleanup_command.rb | 4 +-- lib/rubygems/commands/environment_command.rb | 21 +++++++++++---- lib/rubygems/commands/help_command.rb | 20 +++++++++++--- lib/rubygems/commands/install_command.rb | 17 +++++++++--- lib/rubygems/commands/owner_command.rb | 6 +++++ lib/rubygems/commands/pristine_command.rb | 19 ++++++++++--- lib/rubygems/commands/sources_command.rb | 2 +- lib/rubygems/commands/uninstall_command.rb | 6 +++++ 9 files changed, 108 insertions(+), 27 deletions(-) (limited to 'lib/rubygems/commands') diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb index 5a9320f9c4..99e9690755 100644 --- a/lib/rubygems/commands/cert_command.rb +++ b/lib/rubygems/commands/cert_command.rb @@ -1,6 +1,11 @@ require 'rubygems/command' require 'rubygems/security' -require 'openssl' +begin + require 'openssl' +rescue LoadError => e + raise unless (e.respond_to?(:path) && e.path == 'openssl') || + e.message =~ / -- openssl$/ +end class Gem::Commands::CertCommand < Gem::Command @@ -21,7 +26,8 @@ class Gem::Commands::CertCommand < Gem::Command OptionParser.accept OpenSSL::PKey::RSA do |key_file| begin - key = OpenSSL::PKey::RSA.new File.read key_file + passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] + key = OpenSSL::PKey::RSA.new File.read(key_file), passphrase rescue Errno::ENOENT raise OptionParser::InvalidArgument, "#{key_file}: does not exist" rescue OpenSSL::PKey::RSAError @@ -115,16 +121,31 @@ class Gem::Commands::CertCommand < Gem::Command end def build name - key = options[:key] || Gem::Security.create_key + if options[:key] + key = options[:key] + else + passphrase = ask_for_password 'Passphrase for your Private Key:' + say "\n" + + passphrase_confirmation = ask_for_password 'Please repeat the passphrase for your Private Key:' + say "\n" - cert = Gem::Security.create_cert_email name, key + raise Gem::CommandLineError, + "Passphrase and passphrase confirmation don't match" unless passphrase == passphrase_confirmation + + key = Gem::Security.create_key + key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase + end - key_path = Gem::Security.write key, "gem-private_key.pem" + cert = Gem::Security.create_cert_email name, key cert_path = Gem::Security.write cert, "gem-public_cert.pem" say "Certificate: #{cert_path}" - say "Private Key: #{key_path}" - say "Don't forget to move the key file to somewhere private!" + + if key_path + say "Private Key: #{key_path}" + say "Don't forget to move the key file to somewhere private!" + end end def certificates_matching filter @@ -198,7 +219,8 @@ For further reading on signing gems see `ri Gem::Security`. def load_default_key key_file = File.join Gem.default_key_path key = File.read key_file - options[:key] = OpenSSL::PKey::RSA.new key + passphrase = ENV['GEM_PRIVATE_KEY_PASSPHRASE'] + options[:key] = OpenSSL::PKey::RSA.new key, passphrase rescue Errno::ENOENT alert_error \ "--private-key not specified and ~/.gem/gem-private_key.pem does not exist" @@ -225,5 +247,5 @@ For further reading on signing gems see `ri Gem::Security`. Gem::Security.write cert, cert_file, permissions end -end +end if defined?(OpenSSL::SSL) diff --git a/lib/rubygems/commands/cleanup_command.rb b/lib/rubygems/commands/cleanup_command.rb index 61f189e449..cacfe89404 100644 --- a/lib/rubygems/commands/cleanup_command.rb +++ b/lib/rubygems/commands/cleanup_command.rb @@ -9,7 +9,8 @@ class Gem::Commands::CleanupCommand < Gem::Command 'Clean up old versions of installed gems in the local repository', :force => false, :install_dir => Gem.dir - add_option('-d', '--dryrun', "") do |value, options| + add_option('-n', '-d', '--dryrun', + 'Do not uninstall gems') do |value, options| options[:dryrun] = true end @@ -162,4 +163,3 @@ are not removed. end end - diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb index 40e71cf094..39d52e7f01 100644 --- a/lib/rubygems/commands/environment_command.rb +++ b/lib/rubygems/commands/environment_command.rb @@ -99,6 +99,8 @@ lib/rubygems/defaults/operating_system.rb out << " - EXECUTABLE DIRECTORY: #{Gem.bindir}\n" + out << " - SPEC CACHE DIRECTORY: #{Gem.spec_cache_dir}\n" + out << " - RUBYGEMS PLATFORMS:\n" Gem.platforms.each do |platform| out << " - #{platform}\n" @@ -107,11 +109,9 @@ lib/rubygems/defaults/operating_system.rb out << " - GEM PATHS:\n" out << " - #{Gem.dir}\n" - path = Gem.path.dup - path.delete Gem.dir - path.each do |p| - out << " - #{p}\n" - end + gem_path = Gem.path.dup + gem_path.delete Gem.dir + add_path out, gem_path out << " - GEM CONFIGURATION:\n" Gem.configuration.each do |name, value| @@ -124,6 +124,11 @@ lib/rubygems/defaults/operating_system.rb out << " - #{s}\n" end + out << " - SHELL PATH:\n" + + shell_path = ENV['PATH'].split(File::PATH_SEPARATOR) + add_path out, shell_path + else raise Gem::CommandLineError, "Unknown environment option [#{arg}]" end @@ -131,5 +136,11 @@ lib/rubygems/defaults/operating_system.rb true end + def add_path out, path + path.each do |component| + out << " - #{component}\n" + end + end + end diff --git a/lib/rubygems/commands/help_command.rb b/lib/rubygems/commands/help_command.rb index 7f1fb486e0..9f0ebc087f 100644 --- a/lib/rubygems/commands/help_command.rb +++ b/lib/rubygems/commands/help_command.rb @@ -46,6 +46,10 @@ Some examples of 'gem' usage. * Update all gems on your system: gem update + +* Update your local version of RubyGems + + gem update --system EOF PLATFORMS = <<-'EOF' @@ -55,8 +59,9 @@ your current platform by running `gem environment`. RubyGems matches platforms as follows: - * The CPU must match exactly, unless one of the platforms has - "universal" as the CPU. + * The CPU must match exactly unless one of the platforms has + "universal" as the CPU or the local CPU starts with "arm" and the gem's + CPU is exactly "arm" (for gems that support generic ARM architecture). * The OS must match exactly. * The versions must match exactly unless one of the versions is nil. @@ -66,11 +71,20 @@ you pass must match "#{cpu}-#{os}" or "#{cpu}-#{os}-#{version}". On mswin platforms, the version is the compiler version, not the OS version. (Ruby compiled with VC6 uses "60" as the compiler version, VC8 uses "80".) +For the ARM architecture, gems with a platform of "arm-linux" should run on a +reasonable set of ARM CPUs and not depend on instructions present on a limited +subset of the architecture. For example, the binary should run on platforms +armv5, armv6hf, armv6l, armv7, etc. If you use the "arm-linux" platform +please test your gem on a variety of ARM hardware before release to ensure it +functions correctly. + Example platforms: x86-freebsd # Any FreeBSD version on an x86 CPU universal-darwin-8 # Darwin 8 only gems that run on any CPU x86-mswin32-80 # Windows gems compiled with VC8 + armv7-linux # Gem complied for an ARMv7 CPU running linux + arm-linux # Gem compiled for any ARM CPU running linux When building platform gems, set the platform in the gem specification to Gem::Platform::CURRENT. This will correctly mark the gem with your ruby's @@ -119,7 +133,7 @@ platform. if command then command.summary else - "[No command found for #{cmd_name}, bug?]" + "[No command found for #{cmd_name}]" end summary = wrap(summary, summary_width).split "\n" diff --git a/lib/rubygems/commands/install_command.rb b/lib/rubygems/commands/install_command.rb index 0b58fa665e..ac78764af5 100644 --- a/lib/rubygems/commands/install_command.rb +++ b/lib/rubygems/commands/install_command.rb @@ -4,8 +4,6 @@ require 'rubygems/dependency_installer' require 'rubygems/local_remote_options' require 'rubygems/validator' require 'rubygems/version_option' -require 'rubygems/install_message' # must come before rdoc for messaging -require 'rubygems/rdoc' ## # Gem installer command line tool @@ -39,6 +37,12 @@ class Gem::Commands::InstallCommand < Gem::Command 'install the listed gems') do |v,o| o[:gemdeps] = v end + + add_option(:"Install/Update", '--default', + 'Add the gem\'s full specification to', + 'specifications/default and extract only its bin') do |v,o| + o[:install_as_default] = v + end @installed_specs = nil end @@ -153,7 +157,14 @@ to write the specification by hand. For example: alert_error "Can't use --version w/ multiple gems. Use name:ver instead." terminate_interaction 1 end - + + # load post-install hooks appropriate to options + if options[:install_as_default] + require 'rubygems/install_default_message' + else + require 'rubygems/install_message' + end + require 'rubygems/rdoc' get_all_gem_names_and_versions.each do |gem_name, gem_version| gem_version ||= options[:version] diff --git a/lib/rubygems/commands/owner_command.rb b/lib/rubygems/commands/owner_command.rb index 11e6e026fd..c1c0a570d6 100644 --- a/lib/rubygems/commands/owner_command.rb +++ b/lib/rubygems/commands/owner_command.rb @@ -31,9 +31,15 @@ class Gem::Commands::OwnerCommand < Gem::Command add_option '-r', '--remove EMAIL', 'Remove an owner' do |value, options| options[:remove] << value end + + add_option '-h', '--host HOST', 'Use another gemcutter-compatible host' do |value, options| + options[:host] = value + end end def execute + @host = options[:host] + sign_in name = get_one_gem_name diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index f22fe11769..0a7f315a0a 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -30,6 +30,12 @@ class Gem::Commands::PristineCommand < Gem::Command options[:only_executables] = value end + add_option('-E', '--[no-]env-shebang', + 'Rewrite executables with a shebang', + 'of /usr/bin/env') do |value, options| + options[:env_shebang] = value + end + add_version_option('restore to', 'pristine condition') end @@ -104,16 +110,21 @@ with extensions. Gem::RemoteFetcher.fetcher.download_to_cache dep end - # TODO use installer options - install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install'] - installer_env_shebang = install_defaults.to_s['--env-shebang'] + env_shebang = + if options.include? :env_shebang then + options[:env_shebang] + else + install_defaults = Gem::ConfigFile::PLATFORM_DEFAULTS['install'] + install_defaults.to_s['--env-shebang'] + end installer = Gem::Installer.new(gem, :wrappers => true, :force => true, :install_dir => spec.base_dir, - :env_shebang => installer_env_shebang, + :env_shebang => env_shebang, :build_args => spec.build_args) + if options[:only_executables] then installer.generate_bin else diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb index f4cc3e57ae..82bb1f62eb 100644 --- a/lib/rubygems/commands/sources_command.rb +++ b/lib/rubygems/commands/sources_command.rb @@ -48,7 +48,7 @@ class Gem::Commands::SourcesCommand < Gem::Command options[:update]) if options[:clear_all] then - path = File.join Gem.user_home, '.gem', 'specs' + path = Gem.spec_cache_dir FileUtils.rm_rf path unless File.exist? path then diff --git a/lib/rubygems/commands/uninstall_command.rb b/lib/rubygems/commands/uninstall_command.rb index 56aa8ee57f..68d170acb1 100644 --- a/lib/rubygems/commands/uninstall_command.rb +++ b/lib/rubygems/commands/uninstall_command.rb @@ -67,6 +67,12 @@ class Gem::Commands::UninstallCommand < Gem::Command options[:force] = value end + add_option('--[no-]abort-on-dependent', + 'Prevent uninstalling gems that are', + 'depended on by other gems.') do |value, options| + options[:abort_on_dependent] = value + end + add_version_option add_platform_option end -- cgit v1.2.3