diff options
author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-07-13 14:45:18 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2022-09-03 15:54:07 +0900 |
commit | 7ef68dd74af151a340a592869c28a0f78d2f11fb (patch) | |
tree | 8d4f2d245d055e6074650ce0389f0e28e102254c /lib | |
parent | a01f5ad1ec2455e97e27eb2758588ff5e63c4131 (diff) |
Merge RubyGems-3.3.17 and Bundler-2.3.17
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli.rb | 8 | ||||
-rw-r--r-- | lib/bundler/cli/cache.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/install.rb | 2 | ||||
-rw-r--r-- | lib/bundler/current_ruby.rb | 2 | ||||
-rw-r--r-- | lib/bundler/dependency.rb | 2 | ||||
-rw-r--r-- | lib/bundler/friendly_errors.rb | 7 | ||||
-rw-r--r-- | lib/bundler/gem_helpers.rb | 1 | ||||
-rw-r--r-- | lib/bundler/index.rb | 6 | ||||
-rw-r--r-- | lib/bundler/installer/standalone.rb | 31 | ||||
-rw-r--r-- | lib/bundler/lazy_specification.rb | 4 | ||||
-rw-r--r-- | lib/bundler/man/bundle-add.1 | 2 | ||||
-rw-r--r-- | lib/bundler/man/bundle-add.1.ronn | 2 | ||||
-rw-r--r-- | lib/bundler/match_platform.rb | 1 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 2 | ||||
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 11 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 2 | ||||
-rw-r--r-- | lib/bundler/spec_set.rb | 19 | ||||
-rw-r--r-- | lib/bundler/version.rb | 2 | ||||
-rw-r--r-- | lib/rubygems.rb | 5 | ||||
-rw-r--r-- | lib/rubygems/commands/environment_command.rb | 7 | ||||
-rw-r--r-- | lib/rubygems/ext/builder.rb | 11 | ||||
-rw-r--r-- | lib/rubygems/ext/cargo_builder.rb | 29 | ||||
-rw-r--r-- | lib/rubygems/ext/ext_conf_builder.rb | 87 | ||||
-rw-r--r-- | lib/rubygems/indexer.rb | 2 |
24 files changed, 133 insertions, 114 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 3d93ce5e6f..e1c284130b 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -251,7 +251,9 @@ module Bundler remembered_negative_flag_deprecation("no-deployment") require_relative "cli/install" - Install.new(options.dup).run + Bundler.settings.temporary(:no_install => false) do + Install.new(options.dup).run + end end map aliases_for("install") @@ -297,7 +299,9 @@ module Bundler def update(*gems) SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") require_relative "cli/update" - Update.new(options, gems).run + Bundler.settings.temporary(:no_install => false) do + Update.new(options, gems).run + end end desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem" diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb index eb5dd23092..c8698ed7e3 100644 --- a/lib/bundler/cli/cache.rb +++ b/lib/bundler/cli/cache.rb @@ -14,7 +14,7 @@ module Bundler Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"] setup_cache_all - install unless Bundler.settings[:no_install] + install # TODO: move cache contents here now that all bundles are locked custom_path = Bundler.settings[:path] if options[:path] diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index acf92f28ad..e9b85f7f6f 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -161,6 +161,8 @@ module Bundler Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"] + Bundler.settings.set_command_option_if_given :no_install, options["no-install"] + Bundler.settings.set_command_option_if_given :clean, options["clean"] normalize_groups if options[:without] || options[:with] diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb index 27997982c0..36f26b7ab4 100644 --- a/lib/bundler/current_ruby.rb +++ b/lib/bundler/current_ruby.rb @@ -78,7 +78,7 @@ module Bundler end def x64_mingw? - Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64" + Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os.start_with?("mingw") && Bundler.local_platform.cpu == "x64" end (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version| diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index 018a3182b9..472363c72c 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -122,7 +122,7 @@ module Bundler end def expanded_platforms - @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq + @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq end def should_include? diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index ff6cdc4123..d0d2a6679a 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -29,8 +29,11 @@ module Bundler Bundler.ui.error error.message Bundler.ui.trace error.orig_exception when BundlerError - Bundler.ui.error error.message, :wrap => true - Bundler.ui.trace error + if Bundler.ui.debug? + Bundler.ui.trace error + else + Bundler.ui.error error.message, :wrap => true + end when Thor::Error Bundler.ui.error error.message when LoadError diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb index 632698482f..d85d23f0db 100644 --- a/lib/bundler/gem_helpers.rb +++ b/lib/bundler/gem_helpers.rb @@ -10,6 +10,7 @@ module Bundler [Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")], [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")], [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")], + [Gem::Platform.new("x64-mingw-ucrt"), Gem::Platform.new("x64-mingw-ucrt")], [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")], ].freeze diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb index 8930fca6d0..5bc24fc0b2 100644 --- a/lib/bundler/index.rb +++ b/lib/bundler/index.rb @@ -192,11 +192,7 @@ module Bundler specs += base if base found = specs.select do |spec| next true if spec.source.is_a?(Source::Gemspec) - if base # allow all platforms when searching from a lockfile - dependency.matches_spec?(spec) - else - dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec) - end + dependency.matches_spec?(spec) end found diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb index e8494b4bcd..248b677233 100644 --- a/lib/bundler/installer/standalone.rb +++ b/lib/bundler/installer/standalone.rb @@ -12,6 +12,7 @@ module Bundler end File.open File.join(bundler_path, "setup.rb"), "w" do |file| file.puts "require 'rbconfig'" + file.puts define_path_helpers file.puts reverse_rubygems_kernel_mixin paths.each do |path| if Pathname.new(path).absolute? @@ -29,14 +30,20 @@ module Bundler @specs.map do |spec| next if spec.name == "bundler" Array(spec.require_paths).map do |path| - gem_path(path, spec).sub(version_dir, '#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}') + gem_path(path, spec). + sub(version_dir, '#{RUBY_ENGINE}/#{Gem.ruby_api_version}'). + sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}') # This is a static string intentionally. It's interpolated at a later time. end end.flatten.compact end def version_dir - "#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}" + "#{RUBY_ENGINE}/#{Gem.ruby_api_version}" + end + + def extensions_dir + %r{extensions/(?<platform>[^/]+)/#{Regexp.escape(Gem.extension_api_version)}} end def bundler_path @@ -55,6 +62,26 @@ module Bundler raise Gem::InvalidSpecificationException.new(error_message) end + def define_path_helpers + <<~'END' + unless defined?(Gem) + module Gem + def self.ruby_api_version + RbConfig::CONFIG["ruby_version"] + end + + def self.extension_api_version + if 'no' == RbConfig::CONFIG['ENABLE_SHARED'] + "#{ruby_api_version}-static" + else + ruby_api_version + end + end + end + end + END + end + def reverse_rubygems_kernel_mixin <<~END kernel = (class << ::Kernel; self; end) diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 198906b987..8430b86988 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -84,7 +84,7 @@ module Bundler else ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version) end - platform_object = Gem::Platform.new(platform) + platform_object = ruby_platform_materializes_to_ruby_platform? ? Gem::Platform.new(platform) : Gem::Platform.local candidates = source.specs.search(search_object) same_platform_candidates = candidates.select do |spec| MatchPlatform.platforms_match?(spec.platform, platform_object) @@ -152,7 +152,7 @@ module Bundler # explicitly add a more specific platform. # def ruby_platform_materializes_to_ruby_platform? - !Bundler.most_specific_locked_platform?(Gem::Platform::RUBY) || Bundler.settings[:force_ruby_platform] + !Bundler.most_specific_locked_platform?(generic_local_platform) || Bundler.settings[:force_ruby_platform] end end end diff --git a/lib/bundler/man/bundle-add.1 b/lib/bundler/man/bundle-add.1 index 5ed5cf6f68..821c253ff2 100644 --- a/lib/bundler/man/bundle-add.1 +++ b/lib/bundler/man/bundle-add.1 @@ -41,7 +41,7 @@ Specify version requirements(s) for the added gem\. Specify the group(s) for the added gem\. Multiple groups should be separated by commas\. . .TP -\fB\-\-source\fR, , \fB\-s\fR +\fB\-\-source\fR, \fB\-s\fR Specify the source for the added gem\. . .TP diff --git a/lib/bundler/man/bundle-add.1.ronn b/lib/bundler/man/bundle-add.1.ronn index 7571a431ab..8eead9c569 100644 --- a/lib/bundler/man/bundle-add.1.ronn +++ b/lib/bundler/man/bundle-add.1.ronn @@ -27,7 +27,7 @@ bundle add rails --group "development, test" * `--group`, `-g`: Specify the group(s) for the added gem. Multiple groups should be separated by commas. -* `--source`, , `-s`: +* `--source`, `-s`: Specify the source for the added gem. * `--require`, `-r`: diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb index 69074925a6..7f7e8227f9 100644 --- a/lib/bundler/match_platform.rb +++ b/lib/bundler/match_platform.rb @@ -15,7 +15,6 @@ module Bundler return true if Gem::Platform::RUBY == gemspec_platform return true if local_platform == gemspec_platform gemspec_platform = Gem::Platform.new(gemspec_platform) - return true if GemHelpers.generic(gemspec_platform) === local_platform return true if gemspec_platform === local_platform false diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 18eb18160d..fc4d7cb15d 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -284,7 +284,7 @@ module Bundler if specs_matching_requirement.any? specs = specs_matching_requirement matching_part = requirement_label - requirement_label = "#{requirement_label} #{requirement.__platform}" + requirement_label = "#{requirement_label}' with platform '#{requirement.__platform}" end message = String.new("Could not find gem '#{requirement_label}'#{extra_message} in #{source}#{cache_message}.\n") diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index af669d7d0b..a47692d1f2 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -216,11 +216,12 @@ module Gem require "rubygems/platform" class Platform - JAVA = Gem::Platform.new("java") unless defined?(JAVA) - MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN) - MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64) - MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW) - X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW) + JAVA = Gem::Platform.new("java") + MSWIN = Gem::Platform.new("mswin32") + MSWIN64 = Gem::Platform.new("mswin64") + MINGW = Gem::Platform.new("x86-mingw32") + X64_MINGW = [Gem::Platform.new("x64-mingw32"), + Gem::Platform.new("x64-mingw-ucrt")].freeze end Platform.singleton_class.module_eval do diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index f78e6a443b..04ba4a654c 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -160,6 +160,8 @@ module Bundler raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path end + return if Bundler.settings[:no_install] + if requires_sudo? install_path = Bundler.tmp(spec.full_name) bin_path = install_path.join("bin") diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb index 0dfaed9807..2df14fbb09 100644 --- a/lib/bundler/spec_set.rb +++ b/lib/bundler/spec_set.rb @@ -12,17 +12,19 @@ module Bundler end def for(dependencies, check = false, match_current_platform = false) - handled = [] + # dep.name => [list, of, deps] + handled = Hash.new {|h, k| h[k] = [] } deps = dependencies.dup specs = [] loop do break unless dep = deps.shift - next if handled.any? {|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler" + next if handled[dep.name].any? {|d| match_current_platform || d.__platform == dep.__platform } || dep.name == "bundler" - handled << dep + # use a hash here to ensure constant lookup time in the `any?` call above + handled[dep.name] << dep - specs_for_dep = spec_for_dependency(dep, match_current_platform) + specs_for_dep = specs_for_dependency(dep, match_current_platform) if specs_for_dep.any? specs.concat(specs_for_dep) @@ -171,12 +173,13 @@ module Bundler @specs.sort_by(&:name).each {|s| yield s } end - def spec_for_dependency(dep, match_current_platform) - specs_for_platforms = lookup[dep.name] + def specs_for_dependency(dep, match_current_platform) + specs_for_name = lookup[dep.name] if match_current_platform - GemHelpers.select_best_platform_match(specs_for_platforms.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform) + GemHelpers.select_best_platform_match(specs_for_name.select {|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform) else - GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform) + specs_for_name_and_platform = GemHelpers.select_best_platform_match(specs_for_name, dep.__platform) + specs_for_name_and_platform.any? ? specs_for_name_and_platform : specs_for_name end end diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index a9a2934be8..efb0162ea3 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.3.16".freeze + VERSION = "2.3.17".freeze def self.bundler_major_version @bundler_major_version ||= VERSION.split(".").first.to_i diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 1dd8e27486..00169ba587 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -8,7 +8,7 @@ require 'rbconfig' module Gem - VERSION = "3.3.16".freeze + VERSION = "3.3.17".freeze end # Must be first since it unloads the prelude from 1.9.2 @@ -1323,8 +1323,9 @@ begin rescue LoadError # Ignored rescue StandardError => e + path = e.backtrace_locations.reverse.find {|l| l.path.end_with?("rubygems/defaults/operating_system.rb") }.path msg = "#{e.message}\n" \ - "Loading the rubygems/defaults/operating_system.rb file caused an error. " \ + "Loading the #{path} file caused an error. " \ "This file is owned by your OS, not by rubygems upstream. " \ "Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \ "the problem and ask for help." diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb index b6eeb620bd..b6b3d3812c 100644 --- a/lib/rubygems/commands/environment_command.rb +++ b/lib/rubygems/commands/environment_command.rb @@ -8,8 +8,9 @@ class Gem::Commands::EnvironmentCommand < Gem::Command def arguments # :nodoc: args = <<-EOF - gemdir display the path where gems are installed - gempath display path used to search for gems + home display the path where gems are installed. Aliases: gemhome, gemdir, GEM_HOME + path display path used to search for gems. Aliases: gempath, GEM_PATH + user_gemhome display the path where gems are installed when `--user-install` is given. Aliases: user_gemdir version display the gem format version remotesources display the remote gem servers platform display the supported gem platforms @@ -80,6 +81,8 @@ lib/rubygems/defaults/operating_system.rb Gem.dir when /^gempath/, /^path/, /^GEM_PATH/ then Gem.path.join(File::PATH_SEPARATOR) + when /^user_gemdir/, /^user_gemhome/ then + Gem.user_dir when /^remotesources/ then Gem.sources.to_a.join("\n") when /^platform/ then diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb index e9986a3fc8..99dd2c162c 100644 --- a/lib/rubygems/ext/builder.rb +++ b/lib/rubygems/ext/builder.rb @@ -17,7 +17,7 @@ class Gem::Ext::Builder $1.downcase end - def self.make(dest_path, results, make_dir = Dir.pwd) + def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil) unless File.exist? File.join(make_dir, 'Makefile') raise Gem::InstallError, 'Makefile not found' end @@ -33,11 +33,18 @@ class Gem::Ext::Builder # The installation of the bundled gems is failed when DESTDIR is empty in mswin platform. destdir = (/\bnmake/i !~ make_program_name || ENV['DESTDIR'] && ENV['DESTDIR'] != "") ? 'DESTDIR=%s' % ENV['DESTDIR'] : '' + env = [destdir] + + if sitedir + env << 'sitearchdir=%s' % sitedir + env << 'sitelibdir=%s' % sitedir + end + ['clean', '', 'install'].each do |target| # Pass DESTDIR via command line to override what's in MAKEFLAGS cmd = [ *make_program, - destdir, + *env, target, ].reject(&:empty?) begin diff --git a/lib/rubygems/ext/cargo_builder.rb b/lib/rubygems/ext/cargo_builder.rb index 8465e9ef05..232c0a313d 100644 --- a/lib/rubygems/ext/cargo_builder.rb +++ b/lib/rubygems/ext/cargo_builder.rb @@ -268,29 +268,22 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder tmp_dest = Dir.mktmpdir(".gem.", extension_dir) # Some versions of `mktmpdir` return absolute paths, which will break make - # if the paths contain spaces. However, on Ruby 1.9.x on Windows, relative - # paths cause all C extension builds to fail. + # if the paths contain spaces. # - # As such, we convert to a relative path unless we are using Ruby 1.9.x on - # Windows. This means that when using Ruby 1.9.x on Windows, paths with - # spaces do not work. - # - # Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940 + # As such, we convert to a relative path. tmp_dest_relative = get_relative_path(tmp_dest.clone, extension_dir) - if tmp_dest_relative - full_tmp_dest = File.join(extension_dir, tmp_dest_relative) + full_tmp_dest = File.join(extension_dir, tmp_dest_relative) - # TODO: remove in RubyGems 3 - if Gem.install_extension_in_lib && lib_dir - FileUtils.mkdir_p lib_dir - FileUtils.cp_r ext_path, lib_dir, remove_destination: true - end + # TODO: remove in RubyGems 4 + if Gem.install_extension_in_lib && lib_dir + FileUtils.mkdir_p lib_dir + FileUtils.cp_r ext_path, lib_dir, remove_destination: true + end - FileUtils::Entry_.new(full_tmp_dest).traverse do |ent| - destent = ent.class.new(dest_path, ent.rel) - destent.exist? || FileUtils.mv(ent.path, destent.path) - end + FileUtils::Entry_.new(full_tmp_dest).traverse do |ent| + destent = ent.class.new(dest_path, ent.rel) + destent.exist? || FileUtils.mv(ent.path, destent.path) end ensure FileUtils.rm_rf tmp_dest if tmp_dest diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 3e8aa950c9..2f0183fe2f 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -13,75 +13,50 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder tmp_dest = Dir.mktmpdir(".gem.", extension_dir) # Some versions of `mktmpdir` return absolute paths, which will break make - # if the paths contain spaces. However, on Ruby 1.9.x on Windows, relative - # paths cause all C extension builds to fail. + # if the paths contain spaces. # - # As such, we convert to a relative path unless we are using Ruby 1.9.x on - # Windows. This means that when using Ruby 1.9.x on Windows, paths with - # spaces do not work. - # - # Details: https://github.com/rubygems/rubygems/issues/977#issuecomment-171544940 + # As such, we convert to a relative path. tmp_dest_relative = get_relative_path(tmp_dest.clone, extension_dir) - Tempfile.open %w[siteconf .rb], extension_dir do |siteconf| - siteconf.puts "require 'rbconfig'" - siteconf.puts "dest_path = #{tmp_dest_relative.dump}" - %w[sitearchdir sitelibdir].each do |dir| - siteconf.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path" - siteconf.puts "RbConfig::CONFIG['#{dir}'] = dest_path" - end - - siteconf.close + destdir = ENV["DESTDIR"] - destdir = ENV["DESTDIR"] + begin + require "shellwords" + cmd = Gem.ruby.shellsplit << "-I" << File.expand_path('../..', __dir__) << File.basename(extension) + cmd.push(*args) - begin - # workaround for https://github.com/oracle/truffleruby/issues/2115 - siteconf_path = RUBY_ENGINE == "truffleruby" ? siteconf.path.dup : siteconf.path - require "shellwords" - cmd = Gem.ruby.shellsplit << "-I" << File.expand_path('../..', __dir__) << - "-r" << get_relative_path(siteconf_path, extension_dir) << File.basename(extension) - cmd.push(*args) - - begin - run(cmd, results, class_name, extension_dir) do |s, r| - mkmf_log = File.join(extension_dir, 'mkmf.log') - if File.exist? mkmf_log - unless s.success? - r << "To see why this extension failed to compile, please check" \ - " the mkmf.log which can be found here:\n" - r << " " + File.join(dest_path, 'mkmf.log') + "\n" - end - FileUtils.mv mkmf_log, dest_path - end + run(cmd, results, class_name, extension_dir) do |s, r| + mkmf_log = File.join(extension_dir, 'mkmf.log') + if File.exist? mkmf_log + unless s.success? + r << "To see why this extension failed to compile, please check" \ + " the mkmf.log which can be found here:\n" + r << " " + File.join(dest_path, 'mkmf.log') + "\n" end - siteconf.unlink + FileUtils.mv mkmf_log, dest_path end + end - ENV["DESTDIR"] = nil + ENV["DESTDIR"] = nil - make dest_path, results, extension_dir + make dest_path, results, extension_dir, tmp_dest_relative - if tmp_dest_relative - full_tmp_dest = File.join(extension_dir, tmp_dest_relative) + full_tmp_dest = File.join(extension_dir, tmp_dest_relative) - # TODO remove in RubyGems 3 - if Gem.install_extension_in_lib and lib_dir - FileUtils.mkdir_p lib_dir - entries = Dir.entries(full_tmp_dest) - %w[. ..] - entries = entries.map {|entry| File.join full_tmp_dest, entry } - FileUtils.cp_r entries, lib_dir, :remove_destination => true - end + # TODO remove in RubyGems 4 + if Gem.install_extension_in_lib and lib_dir + FileUtils.mkdir_p lib_dir + entries = Dir.entries(full_tmp_dest) - %w[. ..] + entries = entries.map {|entry| File.join full_tmp_dest, entry } + FileUtils.cp_r entries, lib_dir, :remove_destination => true + end - FileUtils::Entry_.new(full_tmp_dest).traverse do |ent| - destent = ent.class.new(dest_path, ent.rel) - destent.exist? or FileUtils.mv(ent.path, destent.path) - end - end - ensure - ENV["DESTDIR"] = destdir - siteconf.close! + FileUtils::Entry_.new(full_tmp_dest).traverse do |ent| + destent = ent.class.new(dest_path, ent.rel) + destent.exist? or FileUtils.mv(ent.path, destent.path) end + ensure + ENV["DESTDIR"] = destdir end results diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb index 6e8dade640..a5a86f4111 100644 --- a/lib/rubygems/indexer.rb +++ b/lib/rubygems/indexer.rb @@ -401,6 +401,8 @@ class Gem::Indexer File.utime newest_mtime, newest_mtime, dst_name end + ensure + FileUtils.rm_rf @directory end ## |