diff options
| author | Adam Vandenberg | 2010-09-08 07:48:11 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-09-08 07:48:11 -0700 |
| commit | 412e829e42908486ca1e79d43335bc91aca9b891 (patch) | |
| tree | 8b37f2ccc8468ed51613dc38c8085ee84703f9ce /Library | |
| parent | da1d246a08ad4d27678b14e0979c68bac9926a5c (diff) | |
| download | homebrew-412e829e42908486ca1e79d43335bc91aca9b891.tar.bz2 | |
Fix brew-leaves
Diffstat (limited to 'Library')
| -rwxr-xr-x | Library/Contributions/examples/brew-leaves.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/Library/Contributions/examples/brew-leaves.rb b/Library/Contributions/examples/brew-leaves.rb index ba5644c55..d24709229 100755 --- a/Library/Contributions/examples/brew-leaves.rb +++ b/Library/Contributions/examples/brew-leaves.rb @@ -1,9 +1,27 @@ +# Outputs formulas that are installed but are not a dependency for +# any other installed formula. # See: http://github.com/mxcl/homebrew/issues/issue/1438 require 'formula' -deps_graph = Formula.get_used_by -formulas = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s } -formulas.each do |name| + +def get_used_by + used_by = {} + Formula.all.each do |f| + next if f.deps == nil + + f.deps.each do |dep| + _deps = used_by[dep] || [] + _deps << f.name unless _deps.include? f.name + used_by[dep] = _deps + end + end + + return used_by +end + +deps_graph = get_used_by() +installed = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s } +installed.each do |name| deps = deps_graph[name] || [] - puts name if !deps.any? { |dep| formulas.include?(dep) } + puts name unless deps.any? { |dep| installed.include? dep } end |
