rbinstall.rb: reject empty files
* tool/rbinstall.rb (install_recursive): add maxdepth option. * tool/rbinstall.rb (bin-comm): limit depth of bindir and reject empty files. [ruby-core:55101] [Bug #8432] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75b9218f25
commit
14f6c8ca8a
@ -1,3 +1,10 @@
|
|||||||
|
Mon May 27 17:33:28 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* tool/rbinstall.rb (install_recursive): add maxdepth option.
|
||||||
|
|
||||||
|
* tool/rbinstall.rb (bin-comm): limit depth of bindir and reject empty
|
||||||
|
files. [ruby-core:55101] [Bug #8432]
|
||||||
|
|
||||||
Mon May 27 16:16:18 2013 Koichi Sasada <ko1@atdot.net>
|
Mon May 27 16:16:18 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* vm_trace.c (rb_postponed_job_flush, rb_postponed_job_register): use
|
* vm_trace.c (rb_postponed_job_flush, rb_postponed_job_register): use
|
||||||
|
@ -198,6 +198,7 @@ def install_recursive(srcdir, dest, options = {})
|
|||||||
opts = options.clone
|
opts = options.clone
|
||||||
noinst = opts.delete(:no_install)
|
noinst = opts.delete(:no_install)
|
||||||
glob = opts.delete(:glob) || "*"
|
glob = opts.delete(:glob) || "*"
|
||||||
|
maxdepth = opts.delete(:maxdepth)
|
||||||
subpath = (srcdir.size+1)..-1
|
subpath = (srcdir.size+1)..-1
|
||||||
prune = []
|
prune = []
|
||||||
skip = []
|
skip = []
|
||||||
@ -217,19 +218,21 @@ def install_recursive(srcdir, dest, options = {})
|
|||||||
prune = path_matcher(prune)
|
prune = path_matcher(prune)
|
||||||
skip = path_matcher(skip)
|
skip = path_matcher(skip)
|
||||||
File.directory?(srcdir) or return rescue return
|
File.directory?(srcdir) or return rescue return
|
||||||
paths = [[srcdir, dest, true]]
|
paths = [[srcdir, dest, 0]]
|
||||||
found = []
|
found = []
|
||||||
while file = paths.shift
|
while file = paths.shift
|
||||||
found << file
|
found << file
|
||||||
file, d, dir = *file
|
file, d, dir = *file
|
||||||
if dir
|
if dir
|
||||||
|
depth = dir + 1
|
||||||
|
next if maxdepth and maxdepth < depth
|
||||||
files = []
|
files = []
|
||||||
Dir.foreach(file) do |f|
|
Dir.foreach(file) do |f|
|
||||||
src = File.join(file, f)
|
src = File.join(file, f)
|
||||||
d = File.join(dest, dir = src[subpath])
|
d = File.join(dest, dir = src[subpath])
|
||||||
stat = File.lstat(src) rescue next
|
stat = File.lstat(src) rescue next
|
||||||
if stat.directory?
|
if stat.directory?
|
||||||
files << [src, d, true] if /\A\./ !~ f and !prune[dir]
|
files << [src, d, depth] if maxdepth != depth and /\A\./ !~ f and !prune[dir]
|
||||||
elsif stat.symlink?
|
elsif stat.symlink?
|
||||||
# skip
|
# skip
|
||||||
else
|
else
|
||||||
@ -453,7 +456,7 @@ install?(:local, :comm, :bin, :'bin-comm') do
|
|||||||
else
|
else
|
||||||
trans = proc {|base| base}
|
trans = proc {|base| base}
|
||||||
end
|
end
|
||||||
install_recursive(File.join(srcdir, "bin"), bindir) do |src, cmd|
|
install_recursive(File.join(srcdir, "bin"), bindir, :maxdepth => 1) do |src, cmd|
|
||||||
cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])}
|
cmd = cmd.sub(/[^\/]*\z/m) {|n| RbConfig.expand(trans[n])}
|
||||||
|
|
||||||
shebang = ''
|
shebang = ''
|
||||||
@ -462,6 +465,7 @@ install?(:local, :comm, :bin, :'bin-comm') do
|
|||||||
shebang = f.gets
|
shebang = f.gets
|
||||||
body = f.read
|
body = f.read
|
||||||
end
|
end
|
||||||
|
shebang or raise "empty file - #{src}"
|
||||||
if PROLOG_SCRIPT
|
if PROLOG_SCRIPT
|
||||||
shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")}
|
shebang.sub!(/\A(\#!.*?ruby\b)?/) {PROLOG_SCRIPT + ($1 || "#!ruby\n")}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user