Extract unsatisfied dependency logic from installer
This commit is contained in:
parent
41dec56d29
commit
5e83629119
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user