diff options
Diffstat (limited to 'lang/ruby27/files/patch-tool_rbinstall.rb')
-rw-r--r-- | lang/ruby27/files/patch-tool_rbinstall.rb | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/lang/ruby27/files/patch-tool_rbinstall.rb b/lang/ruby27/files/patch-tool_rbinstall.rb new file mode 100644 index 000000000000..f3d2c7585883 --- /dev/null +++ b/lang/ruby27/files/patch-tool_rbinstall.rb @@ -0,0 +1,142 @@ +--- tool/rbinstall.rb.orig 2019-12-25 09:50:58 UTC ++++ tool/rbinstall.rb +@@ -790,139 +790,6 @@ end + + # :startdoc: + +-install?(:ext, :comm, :gem, :'default-gems', :'default-gems-comm') do +- install_default_gem('lib', srcdir) +-end +-install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do +- install_default_gem('ext', srcdir) +-end +- +-def load_gemspec(file) +- file = File.realpath(file) +- code = File.read(file, encoding: "utf-8:-") +- code.gsub!(/`git.*?`/m, '""') +- code.gsub!(/%x\[git.*?\]/m, '""') +- spec = eval(code, binding, file) +- unless Gem::Specification === spec +- raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)." +- end +- 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) +- prepare "default gems from #{dir}", gem_dir, directories +- +- spec_dir = File.join(gem_dir, directories.grep(/^spec/)[0]) +- default_spec_dir = "#{spec_dir}/default" +- makedirs(default_spec_dir) +- +- gems = Dir.glob("#{srcdir}/#{dir}/**/*.gemspec").map {|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| +- old_gemspecs = Dir[File.join(with_destdir(default_spec_dir), "#{gemspec.name}-*.gemspec")] +- if old_gemspecs.size > 0 +- old_gemspecs.each {|spec| FileUtils.rm spec } +- end +- +- full_name = "#{gemspec.name}-#{gemspec.version}" +- +- puts "#{INDENT}#{gemspec.name} #{gemspec.version}" +- gemspec_path = File.join(default_spec_dir, "#{full_name}.gemspec") +- open_for_install(gemspec_path, $data_mode) do +- gemspec.to_ruby.gsub(/.*\0.*\n/, '') +- end +- +- specific_gem_dir = File.join(gem_dir, 'gems', full_name) +- +- makedirs(specific_gem_dir) +- +- unless gemspec.executables.empty? then +- bin_dir = File.join(specific_gem_dir, gemspec.bindir) +- makedirs(bin_dir) +- +- gemspec.executables.map {|exec| +- install File.join(srcdir, 'libexec', exec), +- File.join(bin_dir, exec) +- } +- end +- end +-end +- +-install?(:ext, :comm, :gem, :'bundled-gems') do +- gem_dir = Gem.default_dir +- directories = Gem.ensure_gem_subdirectories(gem_dir, :mode => $dir_mode) +- prepare "bundled gems", gem_dir, directories +- install_dir = with_destdir(gem_dir) +- installed_gems = {} +- options = { +- :install_dir => install_dir, +- :bin_dir => with_destdir(bindir), +- :domain => :local, +- :ignore_dependencies => true, +- :dir_mode => $dir_mode, +- :data_mode => $data_mode, +- :prog_mode => $prog_mode, +- :wrappers => true, +- :format_executable => true, +- } +- gem_ext_dir = "#$extout/gems/#{CONFIG['arch']}" +- extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir +- dirs = Gem::Util.glob_files_in_dir "*/", "#{srcdir}/gems" +- Gem::Specification.each_gemspec(dirs) do |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}" +- if File.directory?(ext = "#{gem_ext_dir}/#{spec.full_name}") +- spec.extensions[0] ||= "-" +- end +- ins = RbInstall::UnpackedInstaller.new(spec, options) +- puts "#{INDENT}#{spec.name} #{spec.version}" +- ins.install +- File.chmod($data_mode, File.join(install_dir, "specifications", "#{spec.full_name}.gemspec")) +- unless spec.extensions.empty? +- install_recursive(ext, spec.extension_dir) +- end +- installed_gems[spec.full_name] = true +- end +- installed_gems, gems = Dir.glob(srcdir+'/gems/*.gem').partition {|gem| installed_gems.key?(File.basename(gem, '.gem'))} +- unless installed_gems.empty? +- install installed_gems, gem_dir+"/cache" +- end +- next if gems.empty? +- if defined?(Zlib) +- Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name))) +- silent = Gem::SilentUI.new +- gems.each do |gem| +- inst = Gem::Installer.new(gem, options) +- inst.spec.extension_dir = with_destdir(inst.spec.extension_dir) +- begin +- Gem::DefaultUserInteraction.use_ui(silent) {inst.install} +- rescue Gem::InstallError +- next +- end +- gemname = File.basename(gem) +- puts "#{INDENT}#{gemname}" +- end +- # fix directory permissions +- # TODO: Gem.install should accept :dir_mode option or something +- File.chmod($dir_mode, *Dir.glob(install_dir+"/**/")) +- # fix .gemspec permissions +- File.chmod($data_mode, *Dir.glob(install_dir+"/specifications/*.gemspec")) +- else +- puts "skip installing bundled gems because of lacking zlib" +- end +-end +- + parse_args() + + include FileUtils |