Unpack new internal json v3 dep format
This commit is contained in:
parent
039eb1adff
commit
ff0c24786b
@ -211,7 +211,39 @@ module Formulary
|
||||
end
|
||||
end
|
||||
|
||||
add_deps = lambda do |spec|
|
||||
add_deps = if Homebrew::API.internal_json_v3?
|
||||
lambda do |deps|
|
||||
T.bind(self, SoftwareSpec)
|
||||
|
||||
deps&.each do |name, info|
|
||||
tags = case info["tags"]
|
||||
in Array => tag_list
|
||||
tag_list.map(&:to_sym)
|
||||
in String => tag
|
||||
tag.to_sym
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
if info.key?("uses_from_macos")
|
||||
bounds = info["uses_from_macos"] || {}
|
||||
bounds.deep_transform_keys!(&:to_sym)
|
||||
bounds.deep_transform_values!(&:to_sym)
|
||||
|
||||
if tags
|
||||
uses_from_macos name => tags, **bounds
|
||||
else
|
||||
uses_from_macos name, **bounds
|
||||
end
|
||||
elsif tags
|
||||
depends_on name => tags
|
||||
else
|
||||
depends_on name
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
lambda do |spec|
|
||||
T.bind(self, SoftwareSpec)
|
||||
|
||||
dep_json = json_formula.fetch("#{spec}_dependencies", json_formula)
|
||||
@ -246,6 +278,7 @@ module Formulary
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
klass = Class.new(::Formula) do
|
||||
@loaded_from_api = true
|
||||
@ -267,7 +300,11 @@ module Formulary
|
||||
version Homebrew::API.internal_json_v3? ? json_formula["version"] : json_formula["versions"]["stable"]
|
||||
sha256 urls_stable["checksum"] if urls_stable["checksum"].present?
|
||||
|
||||
if Homebrew::API.internal_json_v3?
|
||||
instance_exec(json_formula["dependencies"], &add_deps)
|
||||
else
|
||||
instance_exec(:stable, &add_deps)
|
||||
end
|
||||
|
||||
requirements[:stable]&.each do |req|
|
||||
depends_on req
|
||||
@ -283,7 +320,11 @@ module Formulary
|
||||
}.compact
|
||||
url urls_head["url"], **url_spec
|
||||
|
||||
if Homebrew::API.internal_json_v3?
|
||||
instance_exec(json_formula["head_dependencies"], &add_deps)
|
||||
else
|
||||
instance_exec(:head, &add_deps)
|
||||
end
|
||||
|
||||
requirements[:head]&.each do |req|
|
||||
depends_on req
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user