File rubygems-1.3.1_buildroot.patch of Package rubygems

Index: lib/rubygems/install_update_options.rb
===================================================================
--- lib/rubygems/install_update_options.rb.orig	2008-06-24 20:56:30.000000000 +0200
+++ lib/rubygems/install_update_options.rb	2009-03-06 19:38:11.000000000 +0100
@@ -31,6 +31,12 @@ module Gem::InstallUpdateOptions
       options[:bin_dir] = File.expand_path(value)
     end
 
+    add_option(:"Install", '-B', '--build-root DIR',
+      'Temporary installation root. Useful for building',
+      'packages. Do not use this when installing remote gems.') do |value, options|
+      options[:build_root] = File.expand_path(value)
+    end
+
     add_option(:"Install/Update", '-d', '--[no-]rdoc',
                'Generate RDoc documentation for the gem on',
                'install') do |value, options|
Index: lib/rubygems/installer.rb
===================================================================
--- lib/rubygems/installer.rb.orig	2008-10-10 20:22:39.000000000 +0200
+++ lib/rubygems/installer.rb	2009-03-24 14:51:17.388303000 +0100
@@ -109,6 +109,7 @@ class Gem::Installer
     @bin_dir = options[:bin_dir]
     @development = options[:development]
     @source_index = options[:source_index]
+    @build_root = options[:build_root]
 
     begin
       @format = Gem::Format.from_file_by_path @gem, @security_policy
@@ -122,10 +123,10 @@ class Gem::Installer
       # We'll divert to ~/.gems below
     end
 
-    if not File.writable? @gem_home or
+    if @build_root.nil? and (not File.writable? @gem_home or
         # TODO: Shouldn't have to test for existence of bindir; tests need it.
         (@gem_home.to_s == Gem.dir and File.exist? Gem.bindir and
-         not File.writable? Gem.bindir) then
+         not File.writable? Gem.bindir)) then
       if options[:user_install] == false then # You don't want to use ~
         raise Gem::FilePermissionError, @gem_home
       elsif options[:user_install].nil? then
@@ -153,6 +154,13 @@ class Gem::Installer
       raise Gem::FilePermissionError, @gem_home unless File.writable? @gem_home
     end
 
+    unless @build_root.nil?
+      @build_root = Pathname.new(@build_root).expand_path
+      @bin_dir = File.join(@build_root, options[:bin_dir] || Gem.bindir(@gem_home))
+      @gem_home = File.join(@build_root,@gem_home)
+      alert_warning "You build with buildroot.\n  Build root: #{@build_root}\n  Bin dir: #{@bin_dir}\n  Gem home: #{@gem_home}"
+    end
+
     @spec = @format.spec
 
     @gem_dir = File.join(@gem_home, "gems", @spec.full_name).untaint
Index: lib/rubygems/commands/install_command.rb
===================================================================
--- lib/rubygems/commands/install_command.rb.orig	2008-09-10 23:55:28.000000000 +0200
+++ lib/rubygems/commands/install_command.rb	2009-03-06 19:38:11.000000000 +0100
@@ -72,6 +72,7 @@ version is also installed.
       :format_executable => options[:format_executable],
       :ignore_dependencies => options[:ignore_dependencies],
       :install_dir => options[:install_dir],
+      :build_root => options[:build_root],
       :security_policy => options[:security_policy],
       :wrappers => options[:wrappers],
       :bin_dir => options[:bin_dir],
Index: lib/rubygems/dependency_installer.rb
===================================================================
--- lib/rubygems/dependency_installer.rb.orig	2008-08-12 23:50:22.000000000 +0200
+++ lib/rubygems/dependency_installer.rb	2009-03-06 19:38:11.000000000 +0100
@@ -65,6 +65,7 @@ class Gem::DependencyInstaller
     @installed_gems = []
 
     @install_dir = options[:install_dir] || Gem.dir
+    @build_root = options[:build_root]
     @cache_dir = options[:cache_dir] || @install_dir
   end
 
@@ -241,6 +242,7 @@ class Gem::DependencyInstaller
                                 :format_executable   => @format_executable,
                                 :ignore_dependencies => @ignore_dependencies,
                                 :install_dir         => @install_dir,
+                                :build_root          => @build_root,
                                 :security_policy     => @security_policy,
                                 :source_index        => @source_index,
                                 :user_install        => @user_install,
openSUSE Build Service is sponsored by