$NetBSD: patch-ad,v 1.5 2009/06/10 21:44:31 minskim Exp $ --- lib/rubygems/installer.rb.orig 2009-03-31 21:06:19.000000000 -0700 +++ lib/rubygems/installer.rb @@ -85,6 +85,9 @@ class Gem::Installer # for a signed-gems-only policy. # :ignore_dependencies:: Don't raise if a dependency is missing. # :install_dir:: The directory to install the gem into. + # :install_root:: The directory to use as a buildroot for "destdir"-style + # installation. All paths during installation are relative + # to the buildroot. # :format_executable:: Format the executable the same as the ruby executable. # If your ruby is ruby18, foo_exec will be installed as # foo_exec18. @@ -100,6 +103,7 @@ class Gem::Installer :exec_format => false, :force => false, :install_dir => Gem.dir, + :install_root => nil, :source_index => Gem.source_index, }.merge options @@ -114,6 +118,11 @@ class Gem::Installer @bin_dir = options[:bin_dir] @development = options[:development] @source_index = options[:source_index] + install_root = options[:install_root] + unless install_root.nil? or install_root == "" + @install_root = File.expand_path install_root + @gem_home = File.join(@install_root, @gem_home) + end begin @format = Gem::Format.from_file_by_path @gem, @security_policy @@ -312,7 +321,11 @@ class Gem::Installer # If the user has asked for the gem to be installed in a directory that is # the system gem directory, then use the system bin directory, else create # (or use) a new bin dir under the gem_home. - bindir = @bin_dir ? @bin_dir : Gem.bindir(@gem_home) + bindir = @bin_dir ? @bin_dir : (Gem.bindir @gem_home, @install_root) + + unless @install_root.nil? or @install_root == "" + bindir = File.join(@install_root, bindir) + end Dir.mkdir bindir unless File.exist? bindir raise Gem::FilePermissionError.new(bindir) unless File.writable? bindir