diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-04 06:33:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-04 06:33:48 +0000 |
commit | a95a87c0bc0ee694e880b680865072babe168802 (patch) | |
tree | 08e0ab2efb124e70540bc14a0278c5ee2f95cb48 /lib/rubygems/ext | |
parent | a5a4963018590c80019c361c5fe2701fc8606dae (diff) | |
download | ruby-a95a87c0bc0ee694e880b680865072babe168802.tar.gz |
ext_conf_builder.rb: install via temporary directory
* lib/rubygems/ext/ext_conf_builder.rb (Gem::Ext::ExtConfBuilder.build):
fix for unusal cases again. install to a temporary directory once
and move instaled files to the destination directory, if it is same
as the current directory. [Bug #7698]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/ext')
-rw-r--r-- | lib/rubygems/ext/ext_conf_builder.rb | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb index 7babf409a0..2977cf0207 100644 --- a/lib/rubygems/ext/ext_conf_builder.rb +++ b/lib/rubygems/ext/ext_conf_builder.rb @@ -10,26 +10,14 @@ require 'fileutils' require 'tempfile' class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder - - def self.hack_for_obsolete_style_gems(directory) - return unless directory and File.identical?(directory, ".") - mf = Gem.read_binary 'Makefile' - changed = false - changed |= mf.gsub!(/^(install-rb-default:)(.*)/) { - "#$1#{$2.gsub(/(?:^|\s+)\$\(RUBY(?:ARCH|LIB)DIR\)\/\S+(?=\s|$)/, '')}" - } - changed |= mf.gsub!(/^(install-so:.*DLLIB.*\n)((?:\t.*\n)+)/) { - "#$1#{$2.gsub(/.*INSTALL.*DLLIB.*\n/, '')}" - } - if changed - File.open('Makefile', 'wb') {|f| f.print mf} - end - end + FileEntry = FileUtils::Entry_ # :nodoc: def self.build(extension, directory, dest_path, results, args=[]) + tmp_dest = (Dir.mktmpdir(".gem.", ".") if File.identical?(dest_path, ".")) + siteconf = Tempfile.open(%w"siteconf .rb", ".") do |f| f.puts "require 'rbconfig'" - f.puts "dest_path = #{dest_path.dump}" + f.puts "dest_path = #{(tmp_dest || dest_path).dump}" %w[sitearchdir sitelibdir].each do |dir| f.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path" f.puts "RbConfig::CONFIG['#{dir}'] = dest_path" @@ -43,14 +31,20 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder run cmd, results - hack_for_obsolete_style_gems directory - make dest_path, results + if tmp_dest + FileEntry.new(tmp_dest).traverse do |ent| + destent = ent.class.new(dest_path, ent.rel) + destent.exist? or File.rename(ent.path, destent.path) + end + end + results ensure ENV["RUBYOPT"] = rubyopt siteconf.close(true) if siteconf + FileUtils.rm_rf tmp_dest if tmp_dest end end |