Don't install dependencies that are already installed

This commit is contained in:
Max Howell 2009-09-10 14:11:04 +01:00
parent 0a31190fdc
commit fdaa267fb9
2 changed files with 21 additions and 15 deletions

View File

@ -155,7 +155,7 @@ def expand_deps fae
f.deps.each do |name| f.deps.each do |name|
f = Formula.factory name f = Formula.factory name
deps << expand_deps(f) if f.deps # hideous inefficient deps << expand_deps(f) if f.deps # hideous inefficient
deps << f deps << f unless f.installed?
end end
when Hash when Hash
# TODO implement optional and recommended # TODO implement optional and recommended
@ -166,6 +166,7 @@ def expand_deps fae
end end
deps << f deps << f
end end
# TODO much more efficient to use a set and not recurse stuff already done # TODO much more efficient to use a set and not recurse stuff already done
return deps.flatten.uniq return deps.flatten.uniq
end end

View File

@ -91,12 +91,12 @@ begin
end end
end end
unless ARGV.force?
unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success? unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success?
raise "We cannot find a c compiler, have you installed the latest Xcode?" raise "We cannot find a c compiler, have you installed the latest Xcode?"
end end
fae = ARGV.formulae.reject do |f| fae = ARGV.formulae.reject do |f|
if f.installed? and not ARGV.force? if f.installed?
message = "Formula already installed: #{f.prefix}" message = "Formula already installed: #{f.prefix}"
if ARGV.formulae.count > 1 if ARGV.formulae.count > 1
opoo message opoo message
@ -106,8 +106,13 @@ begin
true true
end end
end end
exit 0 if fae.empty?
else
fae=ARGV.formulae
end
fae=expand_deps ARGV.formulae # the resulting order will be optimal for super-deps and deps
fae=expand_deps fae
require 'beer_events' require 'beer_events'