Merge pull request #4263 from MikeMcQuaid/handle-bad-tab-runtime-dependencies
Fix bad formula/tab runtime_dependencies handling
This commit is contained in:
commit
2863a88499
@ -10,6 +10,8 @@ class Dependency
|
|||||||
DEFAULT_ENV_PROC = proc {}
|
DEFAULT_ENV_PROC = proc {}
|
||||||
|
|
||||||
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name])
|
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name])
|
||||||
|
raise ArgumentError, "Dependency must have a name!" unless name
|
||||||
|
|
||||||
@name = name
|
@name = name
|
||||||
@tags = tags
|
@tags = tags
|
||||||
@env_proc = env_proc
|
@env_proc = env_proc
|
||||||
|
@ -1522,7 +1522,11 @@ class Formula
|
|||||||
if read_from_tab &&
|
if read_from_tab &&
|
||||||
(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 { |d| Dependency.new d["full_name"] }.compact
|
return tab_deps.map do |d|
|
||||||
|
full_name = d["full_name"]
|
||||||
|
next unless full_name
|
||||||
|
Dependency.new full_name
|
||||||
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
declared_runtime_dependencies | undeclared_runtime_dependencies
|
declared_runtime_dependencies | undeclared_runtime_dependencies
|
||||||
|
@ -613,7 +613,7 @@ class FormulaInstaller
|
|||||||
# Update tab with actual runtime dependencies
|
# Update tab with actual runtime dependencies
|
||||||
tab = Tab.for_keg(keg)
|
tab = Tab.for_keg(keg)
|
||||||
Tab.clear_cache
|
Tab.clear_cache
|
||||||
tab.runtime_dependencies =
|
tab.runtime_dependency_objects =
|
||||||
formula.runtime_dependencies(read_from_tab: false)
|
formula.runtime_dependencies(read_from_tab: false)
|
||||||
tab.write
|
tab.write
|
||||||
|
|
||||||
|
@ -277,6 +277,7 @@ module Formulary
|
|||||||
# * a formula URL
|
# * a formula URL
|
||||||
# * a local bottle reference
|
# * a local bottle reference
|
||||||
def self.factory(ref, spec = :stable, alias_path: nil, from: nil)
|
def self.factory(ref, spec = :stable, alias_path: nil, from: nil)
|
||||||
|
raise ArgumentError, "Formulae must have a ref!" unless ref
|
||||||
loader_for(ref, from: from).get_formula(spec, alias_path: alias_path)
|
loader_for(ref, from: from).get_formula(spec, alias_path: alias_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,10 +33,7 @@ class Tab < OpenStruct
|
|||||||
"compiler" => compiler,
|
"compiler" => compiler,
|
||||||
"stdlib" => stdlib,
|
"stdlib" => stdlib,
|
||||||
"aliases" => formula.aliases,
|
"aliases" => formula.aliases,
|
||||||
"runtime_dependencies" => runtime_deps.map do |dep|
|
"runtime_dependencies" => Tab.runtime_deps_hash(runtime_deps),
|
||||||
f = dep.to_formula
|
|
||||||
{ "full_name" => f.full_name, "version" => f.version.to_s }
|
|
||||||
end,
|
|
||||||
"source" => {
|
"source" => {
|
||||||
"path" => formula.specified_path.to_s,
|
"path" => formula.specified_path.to_s,
|
||||||
"tap" => formula.tap&.name,
|
"tap" => formula.tap&.name,
|
||||||
@ -203,6 +200,13 @@ class Tab < OpenStruct
|
|||||||
new(attributes)
|
new(attributes)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.runtime_deps_hash(deps)
|
||||||
|
deps.map do |dep|
|
||||||
|
f = dep.to_formula
|
||||||
|
{ "full_name" => f.full_name, "version" => f.version.to_s }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def with?(val)
|
def with?(val)
|
||||||
option_names = val.respond_to?(:option_names) ? val.option_names : [val]
|
option_names = val.respond_to?(:option_names) ? val.option_names : [val]
|
||||||
|
|
||||||
@ -262,6 +266,10 @@ class Tab < OpenStruct
|
|||||||
super unless parsed_homebrew_version < "1.1.6"
|
super unless parsed_homebrew_version < "1.1.6"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def runtime_dependency_objects=(deps)
|
||||||
|
source["runtime_dependencies"] = Tab.runtime_deps_hash(deps)
|
||||||
|
end
|
||||||
|
|
||||||
def cxxstdlib
|
def cxxstdlib
|
||||||
# Older tabs won't have these values, so provide sensible defaults
|
# Older tabs won't have these values, so provide sensible defaults
|
||||||
lib = stdlib.to_sym if stdlib
|
lib = stdlib.to_sym if stdlib
|
||||||
|
Loading…
x
Reference in New Issue
Block a user