Allow multiple unsatisfied fatal requirements
Closes Homebrew/homebrew#13335.
This commit is contained in:
parent
bcde6432f3
commit
8c8701f268
@ -56,7 +56,7 @@ at_exit do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install f
|
def install f
|
||||||
f.external_deps.each { |dep| dep.modify_build_environment }
|
f.requirements.each { |dep| dep.modify_build_environment }
|
||||||
|
|
||||||
f.recursive_deps.uniq.each do |dep|
|
f.recursive_deps.uniq.each do |dep|
|
||||||
dep = Formula.factory dep
|
dep = Formula.factory dep
|
||||||
|
@ -19,11 +19,11 @@ class DependencyCollector
|
|||||||
:chicken, :jruby, :lua, :node, :perl, :python, :rbx, :ruby
|
:chicken, :jruby, :lua, :node, :perl, :python, :rbx, :ruby
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
attr_reader :deps, :external_deps
|
attr_reader :deps, :requirements
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@deps = Dependencies.new
|
@deps = Dependencies.new
|
||||||
@external_deps = Set.new
|
@requirements = Set.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def add spec
|
def add spec
|
||||||
@ -35,7 +35,7 @@ class DependencyCollector
|
|||||||
# dependency needed for the current platform.
|
# dependency needed for the current platform.
|
||||||
return if dep.nil?
|
return if dep.nil?
|
||||||
# Add dep to the correct bucket
|
# Add dep to the correct bucket
|
||||||
(dep.is_a?(Requirement) ? @external_deps : @deps) << dep
|
(dep.is_a?(Requirement) ? @requirements : @deps) << dep
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -65,12 +65,15 @@ class FormulaInstallationAlreadyAttemptedError < Homebrew::InstallationError
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class UnsatisfiedRequirement < Homebrew::InstallationError
|
class UnsatisfiedRequirements < Homebrew::InstallationError
|
||||||
attr :dep
|
attr :reqs
|
||||||
|
|
||||||
def initialize formula, dep
|
def initialize formula, reqs
|
||||||
@dep = dep
|
@reqs = reqs
|
||||||
super formula, "An unsatisfied requirement failed this build."
|
message = (reqs.length == 1) \
|
||||||
|
? "An unsatisfied requirement failed this build." \
|
||||||
|
: "Unsatisifed requirements failed this build."
|
||||||
|
super formula, message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -422,8 +422,8 @@ class Formula
|
|||||||
HOMEBREW_REPOSITORY+"Library/Formula/#{name.downcase}.rb"
|
HOMEBREW_REPOSITORY+"Library/Formula/#{name.downcase}.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
def deps; self.class.dependencies.deps; end
|
def deps; self.class.dependencies.deps; end
|
||||||
def external_deps; self.class.dependencies.external_deps; end
|
def requirements; self.class.dependencies.requirements; end
|
||||||
|
|
||||||
# deps are in an installable order
|
# deps are in an installable order
|
||||||
# which means if a depends on b then b will be ordered before a in this list
|
# which means if a depends on b then b will be ordered before a in this list
|
||||||
|
@ -43,7 +43,8 @@ class FormulaInstaller
|
|||||||
|
|
||||||
f.recursive_deps.each do |dep|
|
f.recursive_deps.each do |dep|
|
||||||
if dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?
|
if dep.installed? and not dep.keg_only? and not dep.linked_keg.directory?
|
||||||
raise CannotInstallFormulaError, "You must `brew link #{dep}' before #{f} can be installed"
|
raise CannotInstallFormulaError,
|
||||||
|
"You must `brew link #{dep}' before #{f} can be installed"
|
||||||
end
|
end
|
||||||
end unless ignore_deps
|
end unless ignore_deps
|
||||||
|
|
||||||
@ -66,15 +67,25 @@ class FormulaInstaller
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
f.external_deps.each do |dep|
|
# Build up a list of unsatisifed fatal requirements
|
||||||
unless dep.satisfied?
|
first_message = true
|
||||||
puts dep.message
|
unsatisfied_fatals = []
|
||||||
if dep.fatal? and not ignore_deps
|
f.requirements.each do |req|
|
||||||
raise UnsatisfiedRequirement.new(f, dep)
|
unless req.satisfied?
|
||||||
|
# Newline between multiple messages
|
||||||
|
puts unless first_message
|
||||||
|
puts req.message
|
||||||
|
first_message = false
|
||||||
|
if req.fatal? and not ignore_deps
|
||||||
|
unsatisfied_fatals << req
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless unsatisfied_fatals.empty?
|
||||||
|
raise UnsatisfiedRequirements.new(f, unsatisfied_fatals)
|
||||||
|
end
|
||||||
|
|
||||||
unless ignore_deps
|
unless ignore_deps
|
||||||
needed_deps = f.recursive_deps.reject{ |d| d.installed? }
|
needed_deps = f.recursive_deps.reject{ |d| d.installed? }
|
||||||
unless needed_deps.empty?
|
unless needed_deps.empty?
|
||||||
|
@ -12,9 +12,9 @@ class ExternalDepsTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Should have found a dep
|
# Should have found a dep
|
||||||
assert d.external_deps.size == 1
|
assert d.requirements.size == 1
|
||||||
|
|
||||||
d.external_deps do |dep|
|
d.requirements do |req|
|
||||||
assert !d.satisfied?
|
assert !d.satisfied?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -26,9 +26,9 @@ class ExternalDepsTests < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Should have found a dep
|
# Should have found a dep
|
||||||
assert d.external_deps.size == 1
|
assert d.requirements.size == 1
|
||||||
|
|
||||||
d.external_deps do |dep|
|
d.requirements do |req|
|
||||||
assert d.satisfied?
|
assert d.satisfied?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user