Installation of gems containing C extensions via gem install has been
broken since the change the run the fake step without root.  This is
because ruby hard codes the path to the install program used, and it
hard codes a path that doesn't exist unless you have a ports checkout.

Ruby hard codes a value for an install program because this is part of
the ruby API.  In ruby, RbConfig::CONFIG['INSTALL'] and similar should
point to a valid command line for installing a file.  This is used
by extconf.rb/mkmf to build C extensions.

This patch restores the previous default value for
RbConfig::CONFIG['INSTALL'] (which calls /usr/bin/install).  However,
if the BSD_INSTALL_* environment variables are set, it uses those in
preference to the default.  This way the ports system still works and
can still run fake without root, but installing gems with C extensions
via gem install also works.

This change also makes FAKE_AS_ROOT = always-wrap unnecessary, so that
can be removed.

Tested with a bulk build of the ruby ports on amd64.  Will be committing
in a few days unless I hear objections.

Thanks,
Jeremy

Index: Makefile.inc
===================================================================
RCS file: /cvs/ports/lang/ruby/Makefile.inc,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile.inc
--- Makefile.inc        16 Sep 2014 09:09:46 -0000      1.10
+++ Makefile.inc        12 Oct 2014 18:09:22 -0000
@@ -26,4 +26,9 @@ CONFIGURE_ENV +=      PREFIX="${PREFIX}" \
 REV ?=                 ${VERSION:R}
 SUB ?=                 ${MACHINE_ARCH:S/amd64/x86_64/}-openbsd
 SUBST_VARS +=          SUB REV
-FAKE_AS_ROOT = always-wrap
+FILESDIR ?=            ${.CURDIR}/../files
+
+post-install:
+       sed 's/INSTALL_ARGS/-c -o ${BINOWN} -g ${BINGRP}/' < \
+               ${FILESDIR}/rbconfig_fix.rb >> \
+               ${PREFIX}/lib/ruby/${RUBYLIBREV}/${SUB}/rbconfig.rb
Index: ruby.port.mk
===================================================================
RCS file: /cvs/ports/lang/ruby/ruby.port.mk,v
retrieving revision 1.76
diff -u -p -r1.76 ruby.port.mk
--- ruby.port.mk        11 Oct 2014 19:52:10 -0000      1.76
+++ ruby.port.mk        13 Oct 2014 00:34:18 -0000
@@ -293,7 +293,7 @@ LIB_DEPENDS+=       ${MODRUBY_LIB_DEPENDS}
 
 .if ${CONFIGURE_STYLE:L:Mextconf}
 CONFIGURE_STYLE=       simple
-CONFIGURE_SCRIPT=      ${RUBY} extconf.rb
+CONFIGURE_SCRIPT=      ${SETENV} ${MAKE_ENV} ${RUBY} extconf.rb
 .elif ${CONFIGURE_STYLE:L:Mgem}
 # All gems should be in the same directory on rubygems.org.
 MASTER_SITES?= ${MASTER_SITE_RUBYGEMS}
Index: 1.8/Makefile
===================================================================
RCS file: /cvs/ports/lang/ruby/1.8/Makefile,v
retrieving revision 1.30
diff -u -p -r1.30 Makefile
--- 1.8/Makefile        25 Nov 2013 14:16:23 -0000      1.30
+++ 1.8/Makefile        12 Oct 2014 18:14:28 -0000
@@ -8,6 +8,7 @@ COMMENT-ri_docs=        ri documentation files 
 
 VERSION=               1.8.7
 PATCHLEVEL=            374
+RUBYLIBREV=            1.8
 
 SHARED_LIBS=           ruby18 0.0
 PKGNAME-main=          ruby-${VERSION}.${PATCHLEVEL}
@@ -19,7 +20,7 @@ PKGNAME-ri_docs=      ruby-ri_docs-${VERSION}
 PKG_ARCH-ri_docs=      *
 PKGSPEC-main=          ruby->=1.8,<1.9
 
-REVISION-main=         0
+REVISION-main=         1
 
 CONFIGURE_ARGS=                --program-suffix=18 \
                        --enable-ipv6 \
Index: 1.9/Makefile
===================================================================
RCS file: /cvs/ports/lang/ruby/1.9/Makefile,v
retrieving revision 1.45
diff -u -p -r1.45 Makefile
--- 1.9/Makefile        25 Jun 2014 15:38:39 -0000      1.45
+++ 1.9/Makefile        12 Oct 2014 18:14:37 -0000
@@ -18,7 +18,7 @@ PKGNAME-gdbm =                ruby-gdbm-${VERSION}.${P
 PKGNAME-dbm =          ruby-dbm-${VERSION}.${PATCHLEVEL}
 PKGNAME-tk =           ruby-tk-${VERSION}.${PATCHLEVEL}
 PKGNAME-ri_docs =      ruby-ri_docs-${VERSION}.${PATCHLEVEL}
-REVISION-main =                0
+REVISION-main =                1
 
 PKG_ARCH-ri_docs =     *
 WANTLIB-ri_docs =      # empty
Index: 2.0/Makefile
===================================================================
RCS file: /cvs/ports/lang/ruby/2.0/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- 2.0/Makefile        22 Sep 2014 15:14:48 -0000      1.14
+++ 2.0/Makefile        13 Oct 2014 03:12:11 -0000
@@ -15,6 +15,7 @@ PKGNAME-main =                ruby-${VERSION}.${PATCHL
 PKGNAME-gdbm =         ruby20-gdbm-${VERSION}.${PATCHLEVEL}
 PKGNAME-tk =           ruby20-tk-${VERSION}.${PATCHLEVEL}
 PKGNAME-ri_docs =      ruby20-ri_docs-${VERSION}.${PATCHLEVEL}
+REVISION-main =                0
 
 PKG_ARCH-ri_docs =     *
 WANTLIB-ri_docs =      # empty
@@ -87,8 +88,6 @@ TEST_DEPENDS =                ${FULLPKGNAME-main}:${BU
 
 pre-install:
        find ${WRKSRC} -name '*.orig' -print0 | xargs -0 rm
-
-post-install:
        ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ruby
 
 do-test:
Index: 2.1/Makefile
===================================================================
RCS file: /cvs/ports/lang/ruby/2.1/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- 2.1/Makefile        22 Sep 2014 15:15:41 -0000      1.8
+++ 2.1/Makefile        12 Oct 2014 20:49:37 -0000
@@ -18,6 +18,7 @@ PKGNAME-main =                ruby-${VERSION}
 PKGNAME-gdbm =         ruby21-gdbm-${VERSION}
 PKGNAME-tk =           ruby21-tk-${VERSION}
 PKGNAME-ri_docs =      ruby21-ri_docs-${VERSION}
+REVISION-main =                0
 
 PKG_ARCH-ri_docs =     *
 WANTLIB-ri_docs =      # empty
@@ -92,8 +93,6 @@ TEST_DEPENDS =                ${FULLPKGNAME-main}:${BU
 
 pre-install:
        find ${WRKSRC} -name '*.orig' -print0 | xargs -0 rm
-
-post-install:
        ${INSTALL_DATA_DIR} ${PREFIX}/share/doc/ruby
 
 do-test:
Index: files/rbconfig_fix.rb
===================================================================
RCS file: files/rbconfig_fix.rb
diff -N files/rbconfig_fix.rb
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/rbconfig_fix.rb       12 Oct 2014 18:09:12 -0000
@@ -0,0 +1,20 @@
+install = '/usr/bin/install INSTALL_ARGS'  
+c = RbConfig::CONFIG 
+m = RbConfig::MAKEFILE_CONFIG
+if v = ENV['BSD_INSTALL_SCRIPT']
+  m['INSTALL'] = c['INSTALL'] = v.sub('-m 755', '')
+  m['INSTALL_SCRIPT'] = c['INSTALL_SCRIPT'] = v
+else
+  m['INSTALL'] = c['INSTALL'] = "#{install}"
+  m['INSTALL_SCRIPT'] = c['INSTALL_SCRIPT'] = "#{install} -m 755"
+end
+if v = ENV['BSD_INSTALL_PROGRAM']
+  m['INSTALL_PROGRAM'] = c['INSTALL_PROGRAM'] = v
+else
+  m['INSTALL_PROGRAM'] = c['INSTALL_PROGRAM'] = "#{install} -s -m 755"
+end
+if v = ENV['BSD_INSTALL_DATA']
+  m['INSTALL_DATA'] = c['INSTALL_DATA'] = v
+else
+  m['INSTALL_DATA'] = c['INSTALL_DATA'] = "#{install} -m 644"
+end

Reply via email to