--- tool/rbinstall.rb.orig	2022-11-24 10:20:31 UTC
+++ tool/rbinstall.rb
@@ -930,170 +930,6 @@ end
 
 # :startdoc:
 
-install?(:ext, :comm, :gem, :'default-gems', :'default-gems-comm') do
-  install_default_gem('lib', srcdir, bindir)
-end
-install?(:ext, :arch, :gem, :'default-gems', :'default-gems-arch') do
-  install_default_gem('ext', srcdir, bindir)
-end
-
-def load_gemspec(file, base = nil)
-  file = File.realpath(file)
-  code = File.read(file, encoding: "utf-8:-")
-  code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\([^\)]*\)/m) do
-    files = []
-    if base
-      Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
-        case File.basename(n); when ".", ".."; next; end
-        next if File.directory?(File.join(base, n))
-        files << n.dump
-      end
-    end
-    "[" + files.join(", ") + "]"
-  end
-  spec = eval(code, binding, file)
-  unless Gem::Specification === spec
-    raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
-  end
-  spec.loaded_from = base ? File.join(base, File.basename(file)) : file
-  spec.files.reject! {|n| n.end_with?(".gemspec") or n.start_with?(".git")}
-
-  spec
-end
-
-def install_default_gem(dir, srcdir, bindir)
-  gem_dir = Gem.default_dir
-  install_dir = with_destdir(gem_dir)
-  prepare "default gems from #{dir}", gem_dir
-  RbInstall.no_write do
-    makedirs(Gem.ensure_default_gem_subdirectories(install_dir, $dir_mode).map {|d| File.join(gem_dir, d)})
-  end
-
-  options = {
-    :install_dir => with_destdir(gem_dir),
-    :bin_dir => with_destdir(bindir),
-    :ignore_dependencies => true,
-    :dir_mode => $dir_mode,
-    :data_mode => $data_mode,
-    :prog_mode => $script_mode,
-    :wrappers => true,
-    :format_executable => true,
-    :install_as_default => true,
-  }
-  default_spec_dir = Gem.default_specifications_dir
-
-  gems = Dir.glob("#{srcdir}/#{dir}/**/*.gemspec").map {|src|
-    spec = load_gemspec(src)
-    file_collector = RbInstall::Specs::FileCollector.new(src)
-    files = file_collector.collect
-    if file_collector.skip_install?(files)
-      next
-    end
-    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| rm spec }
-    end
-
-    full_name = "#{gemspec.name}-#{gemspec.version}"
-
-    gemspec.loaded_from = File.join srcdir, gemspec.spec_name
-
-    package = RbInstall::DirPackage.new gemspec, {gemspec.bindir => 'libexec'}
-    ins = RbInstall::UnpackedInstaller.new(package, options)
-    puts "#{INDENT}#{gemspec.name} #{gemspec.version}"
-    ins.install
-  end
-end
-
-install?(:ext, :comm, :gem, :'bundled-gems') do
-  gem_dir = Gem.default_dir
-  install_dir = with_destdir(gem_dir)
-  prepare "bundled gems", gem_dir
-  RbInstall.no_write do
-    makedirs(Gem.ensure_gem_subdirectories(install_dir, $dir_mode).map {|d| File.join(gem_dir, d)})
-  end
-
-  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 => $script_mode,
-    :wrappers => true,
-    :format_executable => true,
-  }
-
-  extensions_dir = Gem::StubSpecification.gemspec_stub("", gem_dir, gem_dir).extensions_dir
-  specifications_dir = File.join(gem_dir, "specifications")
-  build_dir = Gem::StubSpecification.gemspec_stub("", ".bundle", ".bundle").extensions_dir
-
-  # We are about to build extensions, and want to configure extensions with the
-  # newly installed ruby.
-  Gem.instance_variable_set(:@ruby, with_destdir(File.join(bindir, ruby_install_name)))
-  # Prevent fake.rb propagation. It conflicts with the natural mkmf configs of
-  # the newly installed ruby.
-  ENV.delete('RUBYOPT')
-
-  File.foreach("#{srcdir}/gems/bundled_gems") do |name|
-    next if /^\s*(?:#|$)/ =~ name
-    next unless /^(\S+)\s+(\S+).*/ =~ name
-    gem_name = "#$1-#$2"
-    path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
-    unless File.exist?(path)
-      path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec"
-      next unless File.exist?(path)
-    end
-    spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}")
-    next unless spec.platform == Gem::Platform::RUBY
-    next unless spec.full_name == gem_name
-    spec.extension_dir = "#{extensions_dir}/#{spec.full_name}"
-    package = RbInstall::DirPackage.new spec
-    ins = RbInstall::UnpackedInstaller.new(package, options)
-    puts "#{INDENT}#{spec.name} #{spec.version}"
-    ins.install
-    install_recursive("#{build_dir}/#{gem_name}", "#{extensions_dir}/#{gem_name}") do |src, dest|
-      # puts "#{INDENT}    #{dest[extensions_dir.size+gem_name.size+2..-1]}"
-      install src, dest, :mode => (File.executable?(src) ? $prog_mode : $data_mode)
-    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?
-    prepare "bundled gem cache", gem_dir+"/cache"
-    install installed_gems, gem_dir+"/cache"
-  end
-  next if gems.empty?
-  if defined?(Zlib)
-    silent = Gem::SilentUI.new
-    gems.each do |gem|
-      package = Gem::Package.new(gem)
-      inst = RbInstall::GemInstaller.new(package, options)
-      inst.spec.extension_dir = "#{extensions_dir}/#{inst.spec.full_name}"
-      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
