diff options
| author | Jack Nagel | 2013-01-27 19:40:10 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-01-27 21:20:09 -0600 |
| commit | 5e83629119c47436e5f8fefa90711062e4f3ea64 (patch) | |
| tree | 033e76936d655b483cc77b24f323cfff5fbbe28c /Library | |
| parent | 41dec56d2985a723aa9682eef344bf33f3a02829 (diff) | |
| download | brew-5e83629119c47436e5f8fefa90711062e4f3ea64.tar.bz2 | |
Extract unsatisfied dependency logic from installer
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/dependency.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/exceptions.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/formula_installer.rb | 14 |
3 files changed, 21 insertions, 10 deletions
diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 91b939c4f..331082219 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -42,6 +42,14 @@ class Dependency ARGV.formulae.include?(to_formula) rescue false end + def satisfied? + installed? && missing_options.empty? + end + + def missing_options + options - Tab.for_formula(to_formula).used_options + end + def universal! tags << 'universal' if to_formula.build.has_option? 'universal' end diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index edd5cf1d1..a1dcb101d 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -77,6 +77,15 @@ class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError end end +class UnsatisfiedDependencyError < Homebrew::InstallationError + def initialize(f, dep) + super f, <<-EOS.undent + #{f} dependency #{dep} not installed with: + #{dep.missing_options * ', '} + EOS + end +end + class UnsatisfiedRequirements < Homebrew::InstallationError attr :reqs diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index b934e2a86..67c90cd79 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -143,16 +143,10 @@ class FormulaInstaller dep.universal! unless dep.build? end - dep_f = dep.to_formula - dep_tab = Tab.for_formula(dep) - missing = dep.options - dep_tab.used_options - - if dep.installed? - if missing.empty? - Dependency.prune - else - raise "#{f} dependency #{dep} not installed with:\n #{missing*', '}" - end + if dep.satisfied? + Dependency.prune + elsif dep.installed? + raise UnsatisfiedDependencyError.new(f, dep) end end end |
