diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-05 22:30:13 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-05 22:30:13 +0000 |
commit | ec50e32dbdd78e7f44783e1bd1d53dfde81ad61d (patch) | |
tree | ca23fd1dbc6d5099c5550048731bf2ae5928901d /tool | |
parent | 41a25b855a9ba8a3659cc031427567789e384a31 (diff) | |
download | ruby-ec50e32dbdd78e7f44783e1bd1d53dfde81ad61d.tar.gz |
* tool/rbinstall.rb (bin-comm): prepend prolog shell script if
necessary.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/rbinstall.rb | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index de5319829d..eec790b3ee 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -302,6 +302,7 @@ lib = CONFIG["LIBRUBY"] arc = CONFIG["LIBRUBY_A"] major = CONFIG["MAJOR"] minor = CONFIG["MINOR"] +load_relative = configure_args.include?("--enable-load-relative") install?(:local, :arch, :bin, :'bin-arch') do prepare "binary commands", bindir @@ -381,6 +382,23 @@ install?(:doc, :capi) do install_recursive "doc/capi", capidir, :mode => $data_mode end +if load_relative + PROLOG_SCRIPT = <<EOS +#!/bin/sh\n# -*- ruby -*- +bindir=`#{CONFIG["CHDIR"]} "${0%/*}" 2>/dev/null; pwd` +EOS + if CONFIG["LIBRUBY_RELATIVE"] != 'yes' and libpathenv = CONFIG["LIBPATHENV"] + pathsep = File::PATH_SEPARATOR + PROLOG_SCRIPT << <<EOS +prefix="${bindir%/bin}" +export #{libpathenv}="$prefix/lib${#{libpathenv}#{pathsep}+#{pathsep}$#{libpathenv}}" +EOS + end + PROLOG_SCRIPT << %Q[exec "$bindir/#{ruby_install_name}" -x "$0" "$@"\n] +else + PROLOG_SCRIPT = nil +end + install?(:local, :comm, :bin, :'bin-comm') do prepare "command scripts", bindir @@ -426,7 +444,11 @@ install?(:local, :comm, :bin, :'bin-comm') do shebang = f.gets body = f.read end - shebang.sub!(/^\#!.*?ruby\b/) {"#!" + ruby_shebang} + if PROLOG_SCRIPT + shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")} + else + shebang.sub!(/\A\#!.*?ruby\b/) {"#!" + ruby_shebang} + end shebang.sub!(/\r$/, '') body.gsub!(/\r$/, '') |