Merge pull request #4483 from MikeMcQuaid/runtime-dependencies-missing-formulae
Handle missing formulae in runtime_dependencies
This commit is contained in:
commit
87c3ce2bc3
@ -1521,6 +1521,7 @@ class Formula
|
|||||||
# @private
|
# @private
|
||||||
def runtime_dependencies(read_from_tab: true, undeclared: true)
|
def runtime_dependencies(read_from_tab: true, undeclared: true)
|
||||||
if read_from_tab &&
|
if read_from_tab &&
|
||||||
|
undeclared &&
|
||||||
(keg = opt_or_installed_prefix_keg) &&
|
(keg = opt_or_installed_prefix_keg) &&
|
||||||
(tab_deps = keg.runtime_dependencies)
|
(tab_deps = keg.runtime_dependencies)
|
||||||
return tab_deps.map do |d|
|
return tab_deps.map do |d|
|
||||||
@ -1534,44 +1535,28 @@ class Formula
|
|||||||
declared_runtime_dependencies | undeclared_runtime_dependencies
|
declared_runtime_dependencies | undeclared_runtime_dependencies
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a list of Dependency objects that are declared in the formula.
|
# Returns a list of Formula objects that are required at runtime.
|
||||||
# @private
|
# @private
|
||||||
def declared_runtime_dependencies
|
def runtime_formula_dependencies(read_from_tab: true, undeclared: true)
|
||||||
recursive_dependencies do |_, dependency|
|
runtime_dependencies(
|
||||||
Dependency.prune if dependency.build?
|
read_from_tab: read_from_tab,
|
||||||
next if dependency.required?
|
undeclared: undeclared,
|
||||||
if build.any_args_or_options?
|
).map do |d|
|
||||||
Dependency.prune if build.without?(dependency)
|
begin
|
||||||
elsif !dependency.recommended?
|
d.to_formula
|
||||||
Dependency.prune
|
rescue FormulaUnavailableError
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end.compact
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a list of Dependency objects that are not declared in the formula
|
|
||||||
# but the formula links to.
|
|
||||||
# @private
|
|
||||||
def undeclared_runtime_dependencies
|
|
||||||
keg = opt_or_installed_prefix_keg
|
|
||||||
return [] unless keg
|
|
||||||
|
|
||||||
undeclared_deps = CacheStoreDatabase.use(:linkage) do |db|
|
|
||||||
linkage_checker = LinkageChecker.new(keg, self, cache_db: db)
|
|
||||||
linkage_checker.undeclared_deps.map { |n| Dependency.new(n) }
|
|
||||||
end
|
|
||||||
|
|
||||||
undeclared_deps
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a list of formulae depended on by this formula that aren't
|
# Returns a list of formulae depended on by this formula that aren't
|
||||||
# installed
|
# installed
|
||||||
def missing_dependencies(hide: nil)
|
def missing_dependencies(hide: nil)
|
||||||
hide ||= []
|
hide ||= []
|
||||||
runtime_dependencies.map(&:to_formula).select do |d|
|
runtime_formula_dependencies.select do |f|
|
||||||
hide.include?(d.name) || d.installed_prefixes.empty?
|
hide.include?(f.name) || f.installed_prefixes.empty?
|
||||||
end
|
end
|
||||||
rescue FormulaUnavailableError
|
|
||||||
[]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
# @private
|
||||||
@ -1745,6 +1730,35 @@ class Formula
|
|||||||
PYTHON
|
PYTHON
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns a list of Dependency objects that are declared in the formula.
|
||||||
|
# @private
|
||||||
|
def declared_runtime_dependencies
|
||||||
|
recursive_dependencies do |_, dependency|
|
||||||
|
Dependency.prune if dependency.build?
|
||||||
|
next if dependency.required?
|
||||||
|
if build.any_args_or_options?
|
||||||
|
Dependency.prune if build.without?(dependency)
|
||||||
|
elsif !dependency.recommended?
|
||||||
|
Dependency.prune
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns a list of Dependency objects that are not declared in the formula
|
||||||
|
# but the formula links to.
|
||||||
|
# @private
|
||||||
|
def undeclared_runtime_dependencies
|
||||||
|
keg = opt_or_installed_prefix_keg
|
||||||
|
return [] unless keg
|
||||||
|
|
||||||
|
undeclared_deps = CacheStoreDatabase.use(:linkage) do |db|
|
||||||
|
linkage_checker = LinkageChecker.new(keg, self, cache_db: db)
|
||||||
|
linkage_checker.undeclared_deps.map { |n| Dependency.new(n) }
|
||||||
|
end
|
||||||
|
|
||||||
|
undeclared_deps
|
||||||
|
end
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
# To call out to the system, we use the `system` method and we prefer
|
# To call out to the system, we use the `system` method and we prefer
|
||||||
|
@ -155,8 +155,8 @@ class FormulaInstaller
|
|||||||
|
|
||||||
recursive_deps = formula.recursive_dependencies
|
recursive_deps = formula.recursive_dependencies
|
||||||
recursive_formulae = recursive_deps.map(&:to_formula)
|
recursive_formulae = recursive_deps.map(&:to_formula)
|
||||||
recursive_runtime_deps = formula.runtime_dependencies
|
recursive_runtime_formulae =
|
||||||
recursive_runtime_formulae = recursive_runtime_deps.map(&:to_formula)
|
formula.runtime_formula_dependencies(undeclared: false)
|
||||||
|
|
||||||
recursive_dependencies = []
|
recursive_dependencies = []
|
||||||
recursive_formulae.each do |dep|
|
recursive_formulae.each do |dep|
|
||||||
@ -174,7 +174,9 @@ class FormulaInstaller
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
if recursive_formulae.flat_map(&:recursive_dependencies).map(&:to_s).include?(formula.name)
|
if recursive_formulae.flat_map(&:recursive_dependencies)
|
||||||
|
.map(&:to_s)
|
||||||
|
.include?(formula.name)
|
||||||
raise CannotInstallFormulaError, <<~EOS
|
raise CannotInstallFormulaError, <<~EOS
|
||||||
#{formula.full_name} contains a recursive dependency on itself!
|
#{formula.full_name} contains a recursive dependency on itself!
|
||||||
EOS
|
EOS
|
||||||
@ -431,7 +433,7 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def runtime_requirements(formula)
|
def runtime_requirements(formula)
|
||||||
runtime_deps = formula.runtime_dependencies.map(&:to_formula)
|
runtime_deps = formula.runtime_formula_dependencies(undeclared: false)
|
||||||
recursive_requirements = formula.recursive_requirements do |dependent, _|
|
recursive_requirements = formula.recursive_requirements do |dependent, _|
|
||||||
Requirement.prune unless runtime_deps.include?(dependent)
|
Requirement.prune unless runtime_deps.include?(dependent)
|
||||||
end
|
end
|
||||||
|
@ -149,14 +149,8 @@ class LinkageChecker
|
|||||||
declared_deps_names = declared_deps_full_names.map do |dep|
|
declared_deps_names = declared_deps_full_names.map do |dep|
|
||||||
dep.split("/").last
|
dep.split("/").last
|
||||||
end
|
end
|
||||||
recursive_deps = formula.runtime_dependencies(undeclared: false)
|
recursive_deps = formula.runtime_formula_dependencies(undeclared: false)
|
||||||
.map do |dep|
|
.map(&:name)
|
||||||
begin
|
|
||||||
dep.to_formula.name
|
|
||||||
rescue FormulaUnavailableError
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end.compact
|
|
||||||
|
|
||||||
indirect_deps = []
|
indirect_deps = []
|
||||||
undeclared_deps = []
|
undeclared_deps = []
|
||||||
|
@ -17,7 +17,7 @@ class Tab < OpenStruct
|
|||||||
# Instantiates a Tab for a new installation of a formula.
|
# Instantiates a Tab for a new installation of a formula.
|
||||||
def self.create(formula, compiler, stdlib)
|
def self.create(formula, compiler, stdlib)
|
||||||
build = formula.build
|
build = formula.build
|
||||||
runtime_deps = formula.declared_runtime_dependencies
|
runtime_deps = formula.runtime_dependencies(undeclared: false)
|
||||||
attributes = {
|
attributes = {
|
||||||
"homebrew_version" => HOMEBREW_VERSION,
|
"homebrew_version" => HOMEBREW_VERSION,
|
||||||
"used_options" => build.used_options.as_flags,
|
"used_options" => build.used_options.as_flags,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user