diff options
| author | Max Howell | 2009-05-22 16:20:27 +0100 |
|---|---|---|
| committer | Max Howell | 2009-05-22 16:23:13 +0100 |
| commit | 985030ad82fe94d51a1a4e96a51a62fa7c543c7f (patch) | |
| tree | cc8d16fa82737199a4710856c0598035ccfd6a47 | |
| parent | 02cef8a36e59e35b4d6169e4bd7fa30baea1bd7b (diff) | |
| download | brew-985030ad82fe94d51a1a4e96a51a62fa7c543c7f.tar.bz2 | |
Fix prune
Don't prune everything!
Also added count puts
| -rwxr-xr-x | Cellar/homebrew/brew | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Cellar/homebrew/brew b/Cellar/homebrew/brew index 184d9f9eb..aac825708 100755 --- a/Cellar/homebrew/brew +++ b/Cellar/homebrew/brew @@ -6,14 +6,27 @@ require 'pathname' $root = Pathname.new(__FILE__).realpath.dirname.parent.parent def prune + n=0 + dirs=Array.new $root.find do |path| if path.directory? - name=path.basename - Find.prune if name == 'Cellar' or name == 'Formula' + name=path.relative_path_from($root).to_s + if name == '.git' or name == 'Cellar' or name == 'Formula' + Find.prune + else + dirs<<path + end elsif path.symlink? - path.unlink unless path.readlink.exist? + resolved_path=path.dirname+path.readlink + unless resolved_path.exist? + path.unlink + n+=1 + end end end + # entries lists '.' and '..' so 2 is minimum basically + dirs.sort.reverse_each { |d| d.rmdir if d.children.length == 0 } + return n end case ARGV[0] @@ -48,12 +61,16 @@ case ARGV[0] to.mkpath unless to.exist? elsif from.file? tod=to.dirname - Dir.chdir(tod) { `ln -s "#{from.relative_path_from tod}"` } + Dir.chdir(tod) do + `ln -sf "#{from.relative_path_from tod}"` + n+=1 + end end end + puts "Created #{n} links" when 'prune', 'pasteurize' then - prune + puts "Pruned #{prune} files" else puts "usage: #{$0} [prune] [ln path] [install pkg]" |
