Currently, gem install --user-install fails if run as non-root, since it
uses install -o root -g bin to copy the file from the extension
directory to the lib directory inside the gem.  Since --user-install is
primarly used so that you don't need to be root to install gems, this
makes it not very helpful.

This patch should fix things by making the --user-install option change
the INSTALL_PROG in the gem extension's Makefile to use cp -p, which
will work as a regular user.  I've tested it on amd64 and i386 with
both the --user-install option present and absent.

While here, let's regen the patches.

OK to commit?

Jeremy

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/ruby-gems/Makefile,v
retrieving revision 1.19
diff -N -u -p Makefile
--- Makefile    28 Sep 2010 21:07:14 -0000      1.19
+++ Makefile    6 Oct 2010 17:35:04 -0000
@@ -5,7 +5,7 @@ COMMENT=        package management framework for the Ruby lan
 V=             1.3.7
 DISTNAME=      rubygems-$V
 PKGNAME=       ruby-gems-$V
-#REVISION =    0
+REVISION =     0
 CATEGORIES=    devel
 
 HOMEPAGE=      http://docs.rubygems.org/
Index: patches/patch-lib_rubygems_commands_setup_command_rb
===================================================================
RCS file: 
/cvs/ports/devel/ruby-gems/patches/patch-lib_rubygems_commands_setup_command_rb,v
retrieving revision 1.1
diff -N -u -p patches/patch-lib_rubygems_commands_setup_command_rb
--- patches/patch-lib_rubygems_commands_setup_command_rb        12 Oct 2009 
17:18:00 -0000      1.1
+++ patches/patch-lib_rubygems_commands_setup_command_rb        6 Oct 2010 
17:35:04 -0000
@@ -1,7 +1,7 @@
 $OpenBSD: patch-lib_rubygems_commands_setup_command_rb,v 1.1 2009/10/12 
17:18:00 bernd Exp $
---- lib/rubygems/commands/setup_command.rb.orig        Tue Sep  8 18:24:06 2009
-+++ lib/rubygems/commands/setup_command.rb     Tue Sep  8 18:24:45 2009
-@@ -280,7 +280,7 @@ TEXT
+--- lib/rubygems/commands/setup_command.rb.orig        Mon Apr 19 23:47:36 2010
++++ lib/rubygems/commands/setup_command.rb     Wed Oct  6 10:26:54 2010
+@@ -281,7 +281,7 @@ TEXT
           lib_dir = Gem::ConfigMap[site_or_vendor]
           bin_dir = Gem::ConfigMap[:bindir]
        else
Index: patches/patch-lib_rubygems_config_file_rb
===================================================================
RCS file: /cvs/ports/devel/ruby-gems/patches/patch-lib_rubygems_config_file_rb,v
retrieving revision 1.2
diff -N -u -p patches/patch-lib_rubygems_config_file_rb
--- patches/patch-lib_rubygems_config_file_rb   12 Oct 2009 17:18:00 -0000      
1.2
+++ patches/patch-lib_rubygems_config_file_rb   6 Oct 2010 17:35:04 -0000
@@ -1,7 +1,7 @@
 $OpenBSD: patch-lib_rubygems_config_file_rb,v 1.2 2009/10/12 17:18:00 bernd 
Exp $
---- lib/rubygems/config_file.rb.orig   Thu Jun 25 14:37:14 2009
-+++ lib/rubygems/config_file.rb        Tue Sep  8 18:20:58 2009
-@@ -47,7 +47,7 @@ class Gem::ConfigFile
+--- lib/rubygems/config_file.rb.orig   Mon Feb 15 20:14:16 2010
++++ lib/rubygems/config_file.rb        Wed Oct  6 10:26:54 2010
+@@ -63,7 +63,7 @@ class Gem::ConfigFile
  
        path.strip
      rescue LoadError
Index: patches/patch-lib_rubygems_dependency_installer_rb
===================================================================
RCS file: 
/cvs/ports/devel/ruby-gems/patches/patch-lib_rubygems_dependency_installer_rb,v
retrieving revision 1.4
diff -N -u -p patches/patch-lib_rubygems_dependency_installer_rb
--- patches/patch-lib_rubygems_dependency_installer_rb  12 Oct 2009 17:18:00 
-0000      1.4
+++ patches/patch-lib_rubygems_dependency_installer_rb  6 Oct 2010 17:35:04 
-0000
@@ -2,8 +2,8 @@ $OpenBSD: patch-lib_rubygems_dependency_installer_rb,v
 
 This is for GEM_SKIPDEPENDS in ruby.port.mk.
 
---- lib/rubygems/dependency_installer.rb.orig  Mon Jun 22 15:54:36 2009
-+++ lib/rubygems/dependency_installer.rb       Tue Sep  8 18:26:36 2009
+--- lib/rubygems/dependency_installer.rb.orig  Wed Apr 21 21:43:02 2010
++++ lib/rubygems/dependency_installer.rb       Wed Oct  6 10:26:54 2010
 @@ -23,6 +23,7 @@ class Gem::DependencyInstaller
      :prerelease => false,
      :security_policy => nil, # HACK NoSecurity requires OpenSSL.  AlmostNo? 
Low?
@@ -29,7 +29,7 @@ This is for GEM_SKIPDEPENDS in ruby.port.mk.
  
      @installed_gems = []
  
-@@ -247,7 +249,8 @@ class Gem::DependencyInstaller
+@@ -272,7 +274,8 @@ class Gem::DependencyInstaller
                                  :security_policy     => @security_policy,
                                  :source_index        => @source_index,
                                  :user_install        => @user_install,
Index: patches/patch-lib_rubygems_ext_builder_rb
===================================================================
RCS file: patches/patch-lib_rubygems_ext_builder_rb
diff -N -u -p patches/patch-lib_rubygems_ext_builder_rb
--- /dev/null   6 Oct 2010 11:35:04 -0000
+++ patches/patch-lib_rubygems_ext_builder_rb   6 Oct 2010 17:35:04 -0000
@@ -0,0 +1,20 @@
+$OpenBSD$
+
+Ugly hack to make --user-install option work.  Without this, when
+a user uses gem install --user-install without sudo, it attempts
+to do /usr/bin/install -o root -g bin, which fails due to
+permission issues.
+
+Gem::Installer.path_warning is only set if --user-install is used,
+according to a grep of the sources.
+
+--- lib/rubygems/ext/builder.rb.orig   Wed Oct  6 10:27:31 2010
++++ lib/rubygems/ext/builder.rb        Wed Oct  6 10:28:16 2010
+@@ -19,6 +19,7 @@ class Gem::Ext::Builder
+     mf = File.read('Makefile')
+     mf = mf.gsub(/^RUBYARCHDIR\s*=\s*\$[^$]*/, "RUBYARCHDIR = #{dest_path}")
+     mf = mf.gsub(/^RUBYLIBDIR\s*=\s*\$[^$]*/, "RUBYLIBDIR = #{dest_path}")
++    mf = mf.gsub(/^INSTALL_PROG\s*=.*$/, "INSTALL_PROG = /bin/cp -p") if 
Gem::Installer.path_warning
+ 
+     File.open('Makefile', 'wb') {|f| f.print mf}
+ 
Index: patches/patch-lib_rubygems_install_update_options_rb
===================================================================
RCS file: 
/cvs/ports/devel/ruby-gems/patches/patch-lib_rubygems_install_update_options_rb,v
retrieving revision 1.4
diff -N -u -p patches/patch-lib_rubygems_install_update_options_rb
--- patches/patch-lib_rubygems_install_update_options_rb        12 Oct 2009 
17:18:00 -0000      1.4
+++ patches/patch-lib_rubygems_install_update_options_rb        6 Oct 2010 
17:35:04 -0000
@@ -2,11 +2,11 @@ $OpenBSD: patch-lib_rubygems_install_update_options_rb
 
 This is for GEM_SKIPDEPENDS in ruby.port.mk.
 
---- lib/rubygems/install_update_options.rb.orig        Mon Jun 22 15:54:36 2009
-+++ lib/rubygems/install_update_options.rb     Tue Sep  8 18:20:58 2009
-@@ -112,6 +112,16 @@ module Gem::InstallUpdateOptions
-                "prereleases.") do |value, options|
-       options[:prerelease] = true
+--- lib/rubygems/install_update_options.rb.orig        Mon Apr 19 22:13:19 2010
++++ lib/rubygems/install_update_options.rb     Wed Oct  6 10:26:54 2010
+@@ -104,6 +104,16 @@ module Gem::InstallUpdateOptions
+                 "dependencies") do |value, options|
+       options[:development] = true
      end
 +
 +    add_option(:"Install/Update", '-S', '--skip-dependencies DEPENDENCIES',
Index: patches/patch-lib_rubygems_installer_rb
===================================================================
RCS file: /cvs/ports/devel/ruby-gems/patches/patch-lib_rubygems_installer_rb,v
retrieving revision 1.8
diff -N -u -p patches/patch-lib_rubygems_installer_rb
--- patches/patch-lib_rubygems_installer_rb     12 Oct 2009 17:18:00 -0000      
1.8
+++ patches/patch-lib_rubygems_installer_rb     6 Oct 2010 17:35:04 -0000
@@ -2,9 +2,9 @@ $OpenBSD: patch-lib_rubygems_installer_rb,v 1.8 2009/1
 
 This is for GEM_SKIPDEPENDS in ruby.port.mk.
 
---- lib/rubygems/installer.rb.orig     Mon Jun 22 15:54:36 2009
-+++ lib/rubygems/installer.rb  Tue Sep  8 18:23:08 2009
-@@ -114,6 +114,7 @@ class Gem::Installer
+--- lib/rubygems/installer.rb.orig     Mon Apr 19 23:47:36 2010
++++ lib/rubygems/installer.rb  Wed Oct  6 10:26:54 2010
+@@ -113,6 +113,7 @@ class Gem::Installer
      @bin_dir             = options[:bin_dir]
      @development         = options[:development]
      @source_index        = options[:source_index]
@@ -12,7 +12,7 @@ This is for GEM_SKIPDEPENDS in ruby.port.mk.
  
      begin
        @format = Gem::Format.from_file_by_path @gem, @security_policy
-@@ -199,7 +200,12 @@ class Gem::Installer
+@@ -178,7 +179,12 @@ class Gem::Installer
          deps |= @spec.development_dependencies if @development
  
          deps.each do |dep_gem|

Reply via email to