Relocatable install patch

Hi,

This follows on from my “Tricky install question” earlier. This patch
allows “make” to supply different values at build time and install time
for key paths. So a

./configure --prefix=/foo
make
make PREFIX=/bar install

will install ruby under /bar, but looking for it’s libraries under /foo.

So when the contents of /bar get moved to /foo it all works.

This makes a minor change to mkconfig.rb and adds some more logic to
instruby.rb. It does exactly the same as before for a plain ‘make
install’.

To install the patch:
cd ruby-1.6.8; patch -p1 < /path/to/install.patch

Patch follows after sig. Comments welcome.

Cheers,
Mike

···


Mike Wyer mike@wyer.org www.wyer.org/mike 07974 254007

"I want to die peacefully in my sleep like my Grandfather...

… not screaming and yelling like the passengers in his car"

Patch starts here

— ruby-1.6.8/instruby.rb Mon Dec 2 16:53:03 2002
+++ ruby-1.6.8-0/instruby.rb Fri Apr 4 14:57:46 2003
@@ -1,9 +1,33 @@
#!./miniruby

+File.umask(0)
+CONFIG_NO_EXPAND = 1
load "./rbconfig.rb"
include Config

-File.umask(0)
-destdir = ARGV[0] || ‘’
+makevars = {}
+ENV[“MAKEFLAGS”].split(’ ').each do

  • |pair|
  • key,value = *pair.split(’=’)
  • $stderr.puts “Found #{key} = #{value}”
  • makevars[key.downcase] = value
    +end

+destdir = ARGV[0] || makevars[‘destdir’] || ‘’
+
+if makevars[“prefix”]

  • CONFIG[“prefix”] = makevars[“prefix”]
    +elsif ENV[“prefix”]
  • CONFIG[“prefix”] = ENV[“prefix”]
    +end
    +prefix = CONFIG[“prefix”]

+if makevars[“exec_prefix”]

  • CONFIG[“exec_prefix”] = makevars[“exec_prefix”]
    +elsif ENV[“exec_prefix”]
  • CONFIG[“exec_prefix”] = ENV[“exec_prefix”]
    +end

+Config::expand_all

$:.unshift CONFIG[“srcdir”]+"/lib"
@@ -12,9 +36,4 @@

exeext = CONFIG[“EXEEXT”]
-if ENV[“prefix”]

  • prefix = ENV[“prefix”]
    -else
  • prefix = CONFIG[“prefix”]
    -end

ruby_install_name = CONFIG[“ruby_install_name”]
@@ -22,11 +41,11 @@
arch = “/”+CONFIG[“arch”]

-bindir = destdir+CONFIG[“bindir”]
-libdir = destdir+CONFIG[“libdir”]
-rubylibdir = destdir+CONFIG[“prefix”]+"/lib/ruby"+version
-archlibdir = rubylibdir+arch
-sitelibdir = destdir+CONFIG[“sitedir”]+version
-sitearchlibdir = sitelibdir+arch
-mandir = destdir+CONFIG[“mandir”] + “/man1”
+bindir = makevars[“bindir”] || destdir+CONFIG[“bindir”]
+libdir = makevars[“libdir”] || destdir+CONFIG[“libdir”]
+rubylibdir = makevars[“rubylibdir”] || destdir+prefix+"/lib/ruby"+version
+archlibdir = makevars[“archlibdir”] || rubylibdir+arch
+sitelibdir = makevars[“sitelibdir”] || destdir+CONFIG[“sitedir”]+version
+sitearchlibdir = makevars[“sitearchlibdir”] || sitelibdir+arch
+mandir = makevars[“mandir”] || destdir+CONFIG[“mandir”] + "/man1"
wdir = Dir.getwd

diff -U2 -r ruby-1.6.8/mkconfig.rb ruby-1.6.8-0/mkconfig.rb
— ruby-1.6.8/mkconfig.rb Thu Oct 31 18:40:10 2002
+++ ruby-1.6.8-0/mkconfig.rb Fri Apr 4 14:58:37 2003
@@ -108,7 +108,10 @@
val
end

  • CONFIG.each_value do |val|
  • Config::expand(val)
  • def Config::expand_all
  • CONFIG.each_value do |val|
  •  Config::expand(val)
    
  • end
    end
  • Config::expand_all unless CONFIG_NO_EXPAND
    end
    EOS

First problem: it fails for ext/
I forgot about extmk.rb. Hopefully I should have something better soon :slight_smile:

Cheers,
Mike

···

On Fri, 4 Apr 2003, Mike Wyer wrote:

Hi,

This follows on from my “Tricky install question” earlier. This patch
allows “make” to supply different values at build time and install time
for key paths. So a

./configure --prefix=/foo
make
make PREFIX=/bar install


Mike Wyer mike@wyer.org www.wyer.org/mike 07974 254007

"I want to die peacefully in my sleep like my Grandfather...

… not screaming and yelling like the passengers in his car"

Hi,

This follows on from my “Tricky install question” earlier. This patch
allows “make” to supply different values at build time and install time
for key paths. So a

./configure --prefix=/foo
make
make PREFIX=/bar install

First problem: it fails for ext/
I forgot about extmk.rb. Hopefully I should have something better soon :slight_smile:

This is in the right direction for what I need, a binary install.
I would like to make ruby on machine A and install on
machine B.

A; make
now tar it up and send it to B
B make PREFIX=/onB install
but I want the whole install tree below /onB
and I want it to look for libraries on /onB.

Is this possible?

···

On Friday, 4 April 2003 at 23:23:23 +0900, Mike Wyer wrote:

On Fri, 4 Apr 2003, Mike Wyer wrote:
A: ./configure --prefix=/onA


Jim Freeze

What good is having someone who can walk on water if you don’t follow
in his footsteps?

I’m not sure what I’m working towards will help you much. My scenario is:

B: ./configure --prefix=/onA/foo/ruby
B: make
B: make PREFIX=/onB/bar/ruby/install install

So the code always expects to run from /onA/foo even though it is being
built and installed on B.

Lots of the distributions are packaging ruby these days (SuSE for one).
They may already have solved the binary-relocation problem.

Cheers,
Mike

···

On Fri, 4 Apr 2003, Jim Freeze wrote:

On Friday, 4 April 2003 at 23:23:23 +0900, Mike Wyer wrote:

On Fri, 4 Apr 2003, Mike Wyer wrote:

Hi,

This follows on from my “Tricky install question” earlier. This patch
allows “make” to supply different values at build time and install time
for key paths. So a

./configure --prefix=/foo
make
make PREFIX=/bar install

First problem: it fails for ext/
I forgot about extmk.rb. Hopefully I should have something better soon :slight_smile:

This is in the right direction for what I need, a binary install.
I would like to make ruby on machine A and install on
machine B.

A: ./configure --prefix=/onA
A; make
now tar it up and send it to B
B make PREFIX=/onB install
but I want the whole install tree below /onB
and I want it to look for libraries on /onB.

Is this possible?


Mike Wyer mike@wyer.org www.wyer.org/mike 07974 254007

"I want to die peacefully in my sleep like my Grandfather...

… not screaming and yelling like the passengers in his car"