ruby-changes:46212
From: nobu <ko1@a...>
Date: Wed, 12 Apr 2017 17:39:24 +0900 (JST)
Subject: [ruby-changes:46212] nobu:r58327 (trunk): rbinstall.rb: purge `git ls-files`
nobu 2017-04-12 17:39:19 +0900 (Wed, 12 Apr 2017) New Revision: 58327 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58327 Log: rbinstall.rb: purge `git ls-files` * tool/rbinstall.rb (load_gemspec): purge `git ls-files` generated by bundle. it is not available always everywhere everytime. [ruby-dev:50068] [Bug #13423] Modified files: trunk/tool/rbinstall.rb Index: tool/rbinstall.rb =================================================================== --- tool/rbinstall.rb (revision 58326) +++ tool/rbinstall.rb (revision 58327) @@ -763,6 +763,20 @@ install?(:ext, :arch, :gem, :'default-ge https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L763 install_default_gem('ext', srcdir) end +def load_gemspec(file) + code = File.read(file, encoding: "utf-8:-") + code.gsub!(/`git.*?`/m, '""') + begin + spec = eval(code, binding, file) + rescue SignalException, SystemExit + raise + rescue SyntaxError, Exception + end + raise("invalid spec in #{file}") unless spec + spec.loaded_from = file + spec +end + def install_default_gem(dir, srcdir) gem_dir = Gem.default_dir directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) @@ -773,10 +787,11 @@ def install_default_gem(dir, srcdir) https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L787 makedirs(default_spec_dir) gems = Dir.glob("#{srcdir}/#{dir}/**/*.gemspec").map {|src| - spec = Gem::Specification.load(src) || raise("invalid spec in #{src}") + spec = load_gemspec(src) file_collector = RbInstall::Specs::FileCollector.new(src) files = file_collector.collect next if files.empty? + spec.files = files spec } gems.compact.sort_by(&:name).each do |gemspec| @@ -820,10 +835,7 @@ install?(:ext, :comm, :gem, :'bundle-gem https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L835 gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}" extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir Gem::Specification.each_gemspec([srcdir+'/gems/*']) do |path| - dir = File.dirname(path) - spec = Dir.chdir(dir) { - Gem::Specification.load(File.basename(path)) - } + spec = load_gemspec(path) next unless spec.platform == Gem::Platform::RUBY next unless spec.full_name == path[srcdir.size..-1][/\A\/gems\/([^\/]+)/, 1] spec.extension_dir = "#{extensions_dir}/#{spec.full_name}" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/