зеркало из https://github.com/github/ruby.git
fix prolog in gem wrapper scripts
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
82f61a1336
Коммит
bc388526ba
|
@ -443,9 +443,7 @@ else
|
||||||
PROLOG_SCRIPT = nil
|
PROLOG_SCRIPT = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
install?(:local, :comm, :bin, :'bin-comm') do
|
$script_installer = Struct.new(:ruby_shebang, :ruby_bin, :stub, :trans, :prebatch, :postbatch) do
|
||||||
prepare "command scripts", bindir
|
|
||||||
|
|
||||||
ruby_shebang = File.join(bindir, ruby_install_name)
|
ruby_shebang = File.join(bindir, ruby_install_name)
|
||||||
if File::ALT_SEPARATOR
|
if File::ALT_SEPARATOR
|
||||||
ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
ruby_bin = ruby_shebang.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
||||||
|
@ -481,19 +479,25 @@ install?(:local, :comm, :bin, :'bin-comm') do
|
||||||
postbatch = PROLOG_SCRIPT ? "};{\n#{PROLOG_SCRIPT.sub(/\A(?:#.*\n)*/, '')}" : ''
|
postbatch = PROLOG_SCRIPT ? "};{\n#{PROLOG_SCRIPT.sub(/\A(?:#.*\n)*/, '')}" : ''
|
||||||
postbatch << ">,\n}\n"
|
postbatch << ">,\n}\n"
|
||||||
postbatch.gsub!(/(?=\n)/, ' #')
|
postbatch.gsub!(/(?=\n)/, ' #')
|
||||||
install_recursive(File.join(srcdir, "bin"), bindir, :maxdepth => 1) do |src, cmd|
|
|
||||||
cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])}
|
|
||||||
|
|
||||||
shebang, body = open(src, "rb") do |f|
|
def prolog(shebang)
|
||||||
next f.gets, f.read
|
|
||||||
end
|
|
||||||
shebang or raise "empty file - #{src}"
|
|
||||||
if PROLOG_SCRIPT and !$cmdtype
|
if PROLOG_SCRIPT and !$cmdtype
|
||||||
shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")}
|
shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")}
|
||||||
else
|
else
|
||||||
shebang.sub!(/\A(\#!.*?ruby\b)?/) {"#!" + ruby_shebang + ($1 ? "" : "\n")}
|
shebang.sub!(/\A(\#!.*?ruby\b)?/) {"#!" + ruby_shebang + ($1 ? "" : "\n")}
|
||||||
end
|
end
|
||||||
shebang.sub!(/\r$/, '')
|
shebang.sub!(/\r$/, '')
|
||||||
|
shebang
|
||||||
|
end
|
||||||
|
|
||||||
|
def install(src, cmd)
|
||||||
|
cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])}
|
||||||
|
|
||||||
|
shebang, body = open(src, "rb") do |f|
|
||||||
|
next f.gets, f.read
|
||||||
|
end
|
||||||
|
shebang or raise "empty file - #{src}"
|
||||||
|
shebang = prolog(shebang)
|
||||||
body.gsub!(/\r$/, '')
|
body.gsub!(/\r$/, '')
|
||||||
|
|
||||||
cmd << ".#{$cmdtype}" if $cmdtype
|
cmd << ".#{$cmdtype}" if $cmdtype
|
||||||
|
@ -511,6 +515,16 @@ install?(:local, :comm, :bin, :'bin-comm') do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
break new(ruby_shebang, ruby_bin, stub, trans, prebatch, postbatch)
|
||||||
|
end
|
||||||
|
|
||||||
|
install?(:local, :comm, :bin, :'bin-comm') do
|
||||||
|
prepare "command scripts", bindir
|
||||||
|
|
||||||
|
install_recursive(File.join(srcdir, "bin"), bindir, :maxdepth => 1) do |src, cmd|
|
||||||
|
$script_installer.install(src, cmd)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
install?(:local, :comm, :lib) do
|
install?(:local, :comm, :lib) do
|
||||||
|
@ -674,6 +688,12 @@ module RbInstall
|
||||||
|
|
||||||
def build_extensions
|
def build_extensions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def shebang(bin_file_name)
|
||||||
|
path = File.join(gem_dir, spec.bindir, bin_file_name)
|
||||||
|
first_line = File.open(path, "rb") {|file| file.gets}
|
||||||
|
$script_installer.prolog(first_line)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -723,8 +743,10 @@ install?(:ext, :comm, :gem) do
|
||||||
bin_dir = File.join(gem_dir, 'gems', full_name, gemspec.bindir)
|
bin_dir = File.join(gem_dir, 'gems', full_name, gemspec.bindir)
|
||||||
makedirs(bin_dir)
|
makedirs(bin_dir)
|
||||||
|
|
||||||
execs = gemspec.executables.map {|exec| File.join(srcdir, 'bin', exec)}
|
gemspec.executables.map {|exec|
|
||||||
install(execs, bin_dir, :mode => $script_mode)
|
$script_installer.install(File.join(srcdir, 'bin', exec),
|
||||||
|
File.join(bin_dir, exec))
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче