ruby-changes:31219
From: drbrain <ko1@a...>
Date: Wed, 16 Oct 2013 09:14:34 +0900 (JST)
Subject: [ruby-changes:31219] drbrain:r43298 (trunk): * lib/rubygems: Update to RubyGems master commit 2a74263. This fixes
drbrain 2013-10-16 09:14:16 +0900 (Wed, 16 Oct 2013) New Revision: 43298 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43298 Log: * lib/rubygems: Update to RubyGems master commit 2a74263. This fixes several bugs in RubyGems 2.2.0.preview.1. * test/rubygems: ditto. Added files: trunk/lib/rubygems/ext/build_error.rb trunk/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem trunk/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem trunk/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem trunk/test/rubygems/test_bundled_ca.rb trunk/test/rubygems/test_gem_source_fetch_problem.rb Removed files: trunk/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem trunk/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem trunk/lib/rubygems/ssl_certs/GeoTrust_Global_CA.pem trunk/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem trunk/lib/rubygems/ssl_certs/ca-bundle.pem Modified files: trunk/ChangeLog trunk/lib/rubygems/basic_specification.rb trunk/lib/rubygems/commands/query_command.rb trunk/lib/rubygems/commands/sources_command.rb trunk/lib/rubygems/commands/update_command.rb trunk/lib/rubygems/compatibility.rb trunk/lib/rubygems/config_file.rb trunk/lib/rubygems/core_ext/kernel_require.rb trunk/lib/rubygems/dependency_installer.rb trunk/lib/rubygems/dependency_resolver/index_set.rb trunk/lib/rubygems/dependency_resolver/index_specification.rb trunk/lib/rubygems/dependency_resolver/installer_set.rb trunk/lib/rubygems/doctor.rb trunk/lib/rubygems/errors.rb trunk/lib/rubygems/ext/builder.rb trunk/lib/rubygems/ext/cmake_builder.rb trunk/lib/rubygems/ext.rb trunk/lib/rubygems/indexer.rb trunk/lib/rubygems/installer.rb trunk/lib/rubygems/package.rb trunk/lib/rubygems/request.rb trunk/lib/rubygems/request_set.rb trunk/lib/rubygems/source/local.rb trunk/lib/rubygems/spec_fetcher.rb trunk/lib/rubygems/specification.rb trunk/lib/rubygems/stub_specification.rb trunk/lib/rubygems/uninstaller.rb trunk/lib/rubygems/uri_formatter.rb trunk/lib/rubygems/version.rb trunk/lib/rubygems.rb trunk/test/rubygems/test_gem.rb trunk/test/rubygems/test_gem_commands_build_command.rb trunk/test/rubygems/test_gem_commands_pristine_command.rb trunk/test/rubygems/test_gem_commands_query_command.rb trunk/test/rubygems/test_gem_commands_sources_command.rb trunk/test/rubygems/test_gem_commands_update_command.rb trunk/test/rubygems/test_gem_dependency_installer.rb trunk/test/rubygems/test_gem_dependency_resolver_index_specification.rb trunk/test/rubygems/test_gem_ext_builder.rb trunk/test/rubygems/test_gem_ext_cmake_builder.rb trunk/test/rubygems/test_gem_ext_configure_builder.rb trunk/test/rubygems/test_gem_ext_ext_conf_builder.rb trunk/test/rubygems/test_gem_ext_rake_builder.rb trunk/test/rubygems/test_gem_indexer.rb trunk/test/rubygems/test_gem_package.rb trunk/test/rubygems/test_gem_request.rb trunk/test/rubygems/test_gem_specification.rb trunk/test/rubygems/test_gem_stub_specification.rb trunk/test/rubygems/test_gem_uninstaller.rb trunk/test/rubygems/test_gem_uri_formatter.rb trunk/test/rubygems/test_gem_version.rb trunk/test/rubygems/test_require.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43297) +++ ChangeLog (revision 43298) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Oct 16 09:12:23 2013 Eric Hodel <drbrain@s...> + + * lib/rubygems: Update to RubyGems master commit 2a74263. This fixes + several bugs in RubyGems 2.2.0.preview.1. + + * test/rubygems: ditto. + Wed Oct 16 07:25:02 2013 Aman Gupta <ruby@t...> * gc.c (gc_mark_roots): rename roots to be categories Index: lib/rubygems/basic_specification.rb =================================================================== --- lib/rubygems/basic_specification.rb (revision 43297) +++ lib/rubygems/basic_specification.rb (revision 43298) @@ -38,11 +38,12 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L38 # Return true if this spec can require +file+. def contains_requirable_file? file - root = full_gem_path + build_extensions + suffixes = Gem.suffixes - require_paths.any? do |lib| - base = "#{root}/#{lib}/#{file}" + full_require_paths.any? do |dir| + base = "#{dir}/#{file}" suffixes.any? { |suf| File.file? "#{base}#{suf}" } end end @@ -52,6 +53,27 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L53 File.dirname(loaded_from) == self.class.default_specifications_dir end + ## + # The directory the named +extension+ was installed into after being built. + # + # Usage: + # + # spec.extensions.each do |ext| + # puts spec.extension_install_dir ext + # end + + def extension_install_dir + ruby_api_version = + if 'no' == RbConfig::CONFIG['ENABLE_SHARED'] then + "#{Gem.ruby_api_version}-static" + else + Gem.ruby_api_version + end + + File.join base_dir, 'extensions', Gem::Platform.local.to_s, + ruby_api_version, full_name + end + def find_full_gem_path # :nodoc: # TODO: also, shouldn't it default to full_name if it hasn't been written? path = File.expand_path File.join(gems_dir, full_name) @@ -84,6 +106,28 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L106 end ## + # Full paths in the gem to add to <code>$LOAD_PATH</code> when this gem is + # activated. + + def full_require_paths + full_paths = @require_paths.map do |path| + File.join full_gem_path, path + end + + full_paths << extension_install_dir unless @extensions.empty? + + full_paths + end + + ## + # Returns the full path to this spec's gem directory. + # eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0 + + def gem_dir + @gem_dir ||= File.expand_path File.join(gems_dir, full_name) + end + + ## # Returns the full path to the gems directory containing this spec's # gem directory. eg: /usr/local/lib/ruby/1.8/gems @@ -119,10 +163,30 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L163 end ## - # Require paths of the gem + # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is + # activated. + # + # See also #require_paths= + # + # If you have an extension you do not need to add <code>"ext"</code> to the + # require path, the extension build process will copy the extension files + # into "lib" for you. + # + # The default value is <code>"lib"</code> + # + # Usage: + # + # # If all library files are in the root directory... + # spec.require_path = '.' def require_paths - raise NotImplementedError + return @require_paths if @extensions.empty? + + relative_extension_install_dir = + File.join '..', '..', '..', 'extensions', Gem::Platform.local.to_s, + Gem.ruby_api_version, full_name + + @require_paths + [relative_extension_install_dir] end ## Index: lib/rubygems/spec_fetcher.rb =================================================================== --- lib/rubygems/spec_fetcher.rb (revision 43297) +++ lib/rubygems/spec_fetcher.rb (revision 43298) @@ -225,13 +225,14 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L225 tuples = begin - cache[source.uri] ||= source.load_specs(type) + cache[source.uri] ||= + source.load_specs(type).sort_by { |tup| tup.name } rescue Gem::RemoteFetcher::FetchError raise unless gracefully_ignore [] end - tuples.sort_by { |tup| tup.name } + tuples end end Index: lib/rubygems/dependency_installer.rb =================================================================== --- lib/rubygems/dependency_installer.rb (revision 43297) +++ lib/rubygems/dependency_installer.rb (revision 43298) @@ -74,12 +74,6 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L74 @only_install_dir = !!options[:install_dir] @install_dir = options[:install_dir] || Gem.dir - if options[:install_dir] then - # HACK shouldn't change the global settings, needed for -i behavior - # maybe move to the install command? See also github #442 - Gem::Specification.dirs = @install_dir - end - options = DEFAULT_OPTIONS.merge options @bin_dir = options[:bin_dir] @@ -409,7 +403,9 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L403 request_set.soft_missing = true end - request_set.resolve Gem::DependencyResolver.compose_sets(as, installer_set) + composed_set = Gem::DependencyResolver.compose_sets as, installer_set + + request_set.resolve composed_set request_set end Index: lib/rubygems/dependency_resolver/index_set.rb =================================================================== --- lib/rubygems/dependency_resolver/index_set.rb (revision 43297) +++ lib/rubygems/dependency_resolver/index_set.rb (revision 43298) @@ -30,7 +30,7 @@ class Gem::DependencyResolver::IndexSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/index_set.rb#L30 name = req.dependency.name @all[name].each do |uri, n| - if req.dependency.match? n + if req.dependency.match? n then res << Gem::DependencyResolver::IndexSpecification.new( self, n.name, n.version, uri, n.platform) end Index: lib/rubygems/dependency_resolver/index_specification.rb =================================================================== --- lib/rubygems/dependency_resolver/index_specification.rb (revision 43297) +++ lib/rubygems/dependency_resolver/index_specification.rb (revision 43298) @@ -13,12 +13,12 @@ class Gem::DependencyResolver::IndexSpec https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/index_specification.rb#L13 attr_reader :version - def initialize set, name, version, source, plat + def initialize set, name, version, source, platform @set = set @name = name @version = version @source = source - @platform = plat + @platform = platform.to_s @spec = nil end Index: lib/rubygems/dependency_resolver/installer_set.rb =================================================================== --- lib/rubygems/dependency_resolver/installer_set.rb (revision 43297) +++ lib/rubygems/dependency_resolver/installer_set.rb (revision 43298) @@ -87,7 +87,11 @@ class Gem::DependencyResolver::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/installer_set.rb#L87 end def inspect # :nodoc: - '#<%s domain: %s specs: %p>' % [ self.class, @domain, @specs.keys ] + always_install = @always_install.map { |s| s.full_name } + + '#<%s domain: %s specs: %p always install: %p>' % [ + self.class, @domain, @specs.keys, always_install, + ] end ## @@ -131,5 +135,20 @@ class Gem::DependencyResolver::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver/installer_set.rb#L135 def prefetch(reqs) end + def pretty_print q # :nodoc: + q.group 2, '[InstallerSet', ']' do + q.breakable + q.text "domain: #{@domain}" + + q.breakable + q.text 'specs: ' + q.pp @specs.keys + + q.breakable + q.text 'always install: ' + q.pp @always_install + end + end + end Index: lib/rubygems/ext/builder.rb =================================================================== --- lib/rubygems/ext/builder.rb (revision 43297) +++ lib/rubygems/ext/builder.rb (revision 43298) @@ -19,6 +19,11 @@ class Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L19 CHDIR_MUTEX = Mutex.new # :nodoc: + ## + # `make` targets to run when building the extension + + MAKE_TARGETS = ['clean', '', 'install'] # :nodoc: + attr_accessor :build_args # :nodoc: def self.class_name @@ -28,7 +33,7 @@ class Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L33 def self.make(dest_path, results) unless File.exist? 'Makefile' then - raise Gem::InstallError, "Makefile not found:\n\n#{results.join "\n"}" + raise Gem::InstallError, 'Makefile not found' end # try to find make program from Ruby configure arguments first @@ -40,7 +45,7 @@ class Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L45 destdir = '"DESTDIR=%s"' % ENV['DESTDIR'] if RUBY_VERSION > '2.0' - ['', 'install'].each do |target| + self::MAKE_TARGETS.each do |target| # Pass DESTDIR via command line to override what's in MAKEFLAGS cmd = [ make_program, @@ -74,15 +79,24 @@ class Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L79 unless $?.success? then results << "Building has failed. See above output for more information on the failure." if verbose - raise Gem::InstallError, "#{command_name || class_name} failed:\n\n#{results.join "\n"}" + + exit_reason = + if $?.exited? then + ", exit code #{$?.exitstatus}" + elsif $?.signaled? then + ", uncaught signal #{$?.termsig}" + end + + raise Gem::InstallError, "#{command_name || class_name} failed#{exit_reason}" end end ## - # Creates a new extension builder for +spec+ using the given +build_args+. - # The gem for +spec+ is unpacked in +gem_dir+. + # Creates a new extension builder for +spec+. If the +spec+ does not yet + # have build arguments, saved, set +build_args+ which is an ARGV-style + # array. - def initialize spec, build_args + def initialize spec, build_args = spec.build_args @spec = spec @build_args = build_args @gem_dir = spec.gem_dir @@ -113,12 +127,10 @@ class Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L127 end ## - # Logs the build +output+ in +build_dir+, then raises ExtensionBuildError. + # Logs the build +output+ in +build_dir+, then raises Gem::Ext::BuildError. def build_error build_dir, output, backtrace = nil # :nodoc: - gem_make_out = File.join build_dir, 'gem_make.out' - - open gem_make_out, 'wb' do |io| io.puts output end + gem_make_out = write_gem_make_out output message = <<-EOF ERROR: Failed to build gem native extension. @@ -129,14 +141,15 @@ Gem files will remain installed in #{@ge https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L141 Results logged to #{gem_make_out} EOF - raise Gem::Installer::ExtensionBuildError, message, backtrace + raise Gem::Ext::BuildError, message, backtrace end def build_extension extension, dest_path # :nodoc: results = [] extension ||= '' # I wish I knew why this line existed - extension_dir = File.join @gem_dir, File.dirname(extension) + extension_dir = + File.expand_path File.join @gem_dir, File.dirname(extension) builder = builder_for extension @@ -151,7 +164,10 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L164 say results.join("\n") if Gem.configuration.really_verbose end end - rescue + + write_gem_make_out results.join "\n" + rescue => e + results << e.message build_error extension_dir, results.join("\n"), $@ end end @@ -170,7 +186,9 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L186 say "This could take a while..." end - dest_path = File.join @gem_dir, @spec.require_paths.first + dest_path = @spec.extension_install_dir + + FileUtils.rm_f @spec.gem_build_complete_path @ran_rake = false # only run rake once @@ -179,6 +197,21 @@ EOF https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/builder.rb#L197 build_extension extension, dest_path end + + FileUtils.touch @spec.gem_build_complete_path + end + + ## + # Writes +output+ to gem_make.out in the extension install directory. + + def write_gem_make_out output # :nodoc: + destination = File.join @spec.extension_install_dir, 'gem_make.out' + + FileUtils.mkdir_p @spec.extension_install_dir + + open destination, 'wb' do |io| io.puts output end + + destination end end Index: lib/rubygems/ext/cmake_builder.rb =================================================================== --- lib/rubygems/ext/cmake_builder.rb (revision 43297) +++ lib/rubygems/ext/cmake_builder.rb (revision 43298) @@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/cmake_builder.rb#L1 class Gem::Ext::CmakeBuilder < Gem::Ext::Builder + + MAKE_TARGETS = ['', 'install'] # :nodoc: + def self.build(extension, directory, dest_path, results) unless File.exist?('Makefile') then cmd = "cmake . -DCMAKE_INSTALL_PREFIX=#{dest_path}" Index: lib/rubygems/ext/build_error.rb =================================================================== --- lib/rubygems/ext/build_error.rb (revision 0) +++ lib/rubygems/ext/build_error.rb (revision 43298) @@ -0,0 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/build_error.rb#L1 +## +# Raised when there is an error while building extensions. + +class Gem::Ext::BuildError < Gem::InstallError +end + Property changes on: lib/rubygems/ext/build_error.rb ___________________________________________________________________ Added: svn:eol-style + LF Index: lib/rubygems/request_set.rb =================================================================== --- lib/rubygems/request_set.rb (revision 43297) +++ lib/rubygems/request_set.rb (revision 43298) @@ -60,10 +60,13 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L60 specs = [] sorted_requests.each do |req| - if req.installed? and - @always_install.none? { |spec| spec == req.spec.spec } then - yield req, nil if block_given? - next + if req.installed? then + req.spec.spec.build_extensions + + if @always_install.none? { |spec| spec == req.spec.spec } then + yield req, nil if block_given? + next + end end path = req.download cache_dir Index: lib/rubygems/config_file.rb =================================================================== --- lib/rubygems/config_file.rb (revision 43297) +++ lib/rubygems/config_file.rb (revision 43298) @@ -5,6 +5,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/config_file.rb#L5 #++ require 'rubygems/user_interaction' +require 'rbconfig' ## # Gem::ConfigFile RubyGems options and gem command options from gemrc. Index: lib/rubygems/compatibility.rb =================================================================== --- lib/rubygems/compatibility.rb (revision 43297) +++ lib/rubygems/compatibility.rb (revision 43298) @@ -34,6 +34,9 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems/compatibility.rb#L34 RubyGemsVersion = VERSION RbConfigPriorities = %w[ + MAJOR + MINOR + TEENY EXEEXT RUBY_SO_NAME arch bindir datadir libdir ruby_install_name ruby_version rubylibprefix sitedir sitelibdir vendordir vendorlibdir rubylibdir Index: lib/rubygems/errors.rb =================================================================== --- lib/rubygems/errors.rb (revision 43297) +++ lib/rubygems/errors.rb (revision 43298) @@ -85,5 +85,10 @@ module Gem https://github.com/ruby/ruby/blob/trunk/lib/rubygems/errors.rb#L85 def wordy "Unable to download data from #{@source.uri} - #{@error.message}" end + + ## + # The "exception" alias allows you to call raise on a SourceFetchProblem. + + alias exception error end end Index: lib/rubygems/specification.rb =================================================================== --- lib/rubygems/specification.rb (revision 43297) +++ lib/rubygems/specification.rb (revision 43298) @@ -35,18 +35,8 @@ class Date; end https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L35 # end # # Starting in RubyGems 2.0, a Specification can hold arbitrary -# metadata. This metadata is accessed via Specification#metadata -# and has the following restrictions: -# -# * Must be a Hash object -# * All keys and values must be Strings -# * Keys can be a maximum of 128 bytes and values can be a -# maximum of 1024 bytes -# * All strings must be UTF8, no binary data is allowed -# -# For example, to add metadata for the location of a bugtracker: -# -# s.metadata = { "bugtracker" => "http://somewhere.com/blah" } +# metadata. See #metadata for restrictions on the format and size of metadata +# items you may add to a specification. class Gem::Specification < Gem::BasicSpecification @@ -209,6 +199,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L199 # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is # activated. # + # See also #require_paths + # # If you have an extension you do not need to add <code>"ext"</code> to the # require path, the extension build process will copy the extension files # into "lib" for you. @@ -220,7 +212,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L212 # # If all library files are in the root directory... # spec.require_path = '.' - attr_accessor :require_paths + attr_writer :require_paths ## # The version of RubyGems used to create this gem. @@ -398,10 +390,21 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L390 ## # :attr_accessor: metadata # - # Arbitrary metadata for this gem. An instance of Hash. + # The metadata holds extra data for this gem that may be useful to other + # consumers and is settable by gem authors without requiring an update to + # the rubygems software. + # + # Metadata items have the following restrictions: + # + # * The metadata must be a Hash object + # * All keys and values must be Strings + # * Keys can be a maximum of 128 bytes and values can be a maximum of 1024 + # bytes + # * All strings must be UTF-8, no binary data is allowed + # + # To add metadata for the location of a issue tracker: # - # metadata is simply a Symbol => String association that contains arbitary - # data that could be useful to other consumers. + # s.metadata = { "issue_tracker" => "https://example/issues" } attr_accessor :metadata @@ -510,6 +513,9 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L513 # This should just be the name of your license. The full # text of the license should be inside of the gem when you build it. # + # See http://opensource.org/licenses/alpha (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/