diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-12 03:39:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-01-12 03:39:58 +0000 |
commit | 4f2b409a108b1ed38d20eb480146994b8a8a5935 (patch) | |
tree | 4ff41d1960aca8079fdfe01ca50b1d8742acee5d /instruby.rb | |
parent | 5c94a67eca00071edb4cc84a3f90dbb860d8c945 (diff) |
* instruby.rb (install_recursive): skips the directory if matched
to a no_install pattern ending with a file separator.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'instruby.rb')
-rwxr-xr-x | instruby.rb | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/instruby.rb b/instruby.rb index 38e7eb91d1..9af1fffb63 100755 --- a/instruby.rb +++ b/instruby.rb @@ -159,25 +159,59 @@ def makedirs(dirs) super(dirs, :mode => $dir_mode) unless dirs.empty? end +FalseProc = proc {false} +def path_matcher(pat) + if pat and !pat.empty? + proc {|f| pat.any? {|n| File.fnmatch?(n, f)}} + else + FalseProc + end +end + def install_recursive(srcdir, dest, options = {}) opts = options.clone noinst = opts.delete(:no_install) glob = opts.delete(:glob) || "*" - subpath = srcdir.size..-1 - Dir.glob("#{srcdir}/**/#{glob}") do |src| - case base = File.basename(src) - when /\A\#.*\#\z/, /~\z/ - next - end - if noinst - if Array === noinst - next if noinst.any? {|n| File.fnmatch?(n, base)} + subpath = (srcdir.size+1)..-1 + prune = skip = FalseProc + if noinst + if Array === noinst + prune = noinst.grep(/#{File::SEPARATOR}/o).map!{|f| f.chomp(File::SEPARATOR)} + skip = noinst.grep(/\A[^#{File::SEPARATOR}]*\z/o) + else + if noinst.index(File::SEPARATOR) + prune = [noinst] else - next if File.fnmatch?(noinst, base) + skip = [noinst] end end - d = dest + src[subpath] - if File.directory?(src) + skip |= %w"#*# *~ *.old *.bak *.orig *.rej *.diff *.patch *.core" + prune = path_matcher(prune) + skip = path_matcher(skip) + end + File.directory?(srcdir) or return rescue return + paths = [[srcdir, dest, true]] + found = [] + while file = paths.shift + found << file + file, d, dir = *file + if dir + files = [] + Dir.foreach(file) do |f| + src = File.join(file, f) + d = File.join(dest, dir = src[subpath]) + stat = File.lstat(src) rescue next + if stat.directory? + files << [src, d, true] if /\A\./ !~ f and !prune[dir] + else + files << [src, d, false] if File.fnmatch?(glob, f) and !skip[f] + end + end + paths.insert(0, *files) + end + end + for src, d, dir in found + if dir makedirs(d) else makedirs(File.dirname(d)) @@ -265,9 +299,7 @@ if $extout install?(:ext, :arch, :'ext-arch') do puts "installing extension objects" makedirs [archlibdir, sitearchlibdir, vendorarchlibdir, archhdrdir] - if noinst = CONFIG["no_install_files"] and noinst.empty? - noinst = nil - end + noinst = %w[-*] | (CONFIG["no_install_files"] || "").split install_recursive("#{extout}/#{CONFIG['arch']}", archlibdir, :no_install => noinst, :mode => $prog_mode) install_recursive("#{extout}/include/#{CONFIG['arch']}", archhdrdir, :glob => "*.h", :mode => $data_mode) end @@ -407,7 +439,7 @@ install?(:local, :comm, :man) do end end -install?(:local, :comm, :gem) do +install?(:ext, :comm, :gem) do puts "creating default gem directories" directories = [] |