mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
remove all references to JSON v3
The logic has now been removed in previous commits. This just removes some references to the `HOMEBREW_INTERNAL_JSON_V3` environment variable along with reverting the changes to the `Cachable` class that were originally added in bd72ec812c3ed656dfcf8e24f77df142a1fe9cc1.
This commit is contained in:
parent
eead014ceb
commit
f916f27d82
@ -184,11 +184,6 @@ module Homebrew
|
|||||||
|
|
||||||
Tap.fetch(org, repo)
|
Tap.fetch(org, repo)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
|
||||||
def self.internal_json_v3?
|
|
||||||
ENV["HOMEBREW_INTERNAL_JSON_V3"].present?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) }
|
sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) }
|
||||||
|
@ -11,7 +11,6 @@ module Homebrew
|
|||||||
extend Cachable
|
extend Cachable
|
||||||
|
|
||||||
DEFAULT_API_FILENAME = "formula.jws.json"
|
DEFAULT_API_FILENAME = "formula.jws.json"
|
||||||
INTERNAL_V3_API_FILENAME = "internal/v3/homebrew-core.jws.json"
|
|
||||||
|
|
||||||
private_class_method :cache
|
private_class_method :cache
|
||||||
|
|
||||||
@ -43,33 +42,24 @@ module Homebrew
|
|||||||
|
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def self.cached_json_file_path
|
def self.cached_json_file_path
|
||||||
if Homebrew::API.internal_json_v3?
|
HOMEBREW_CACHE_API/DEFAULT_API_FILENAME
|
||||||
HOMEBREW_CACHE_API/INTERNAL_V3_API_FILENAME
|
|
||||||
else
|
|
||||||
HOMEBREW_CACHE_API/DEFAULT_API_FILENAME
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def self.download_and_cache_data!
|
def self.download_and_cache_data!
|
||||||
if Homebrew::API.internal_json_v3?
|
json_formulae, updated = Homebrew::API.fetch_json_api_file DEFAULT_API_FILENAME
|
||||||
json_formulae, updated = Homebrew::API.fetch_json_api_file INTERNAL_V3_API_FILENAME
|
|
||||||
overwrite_cache! T.cast(json_formulae, T::Hash[String, T.untyped])
|
|
||||||
else
|
|
||||||
json_formulae, updated = Homebrew::API.fetch_json_api_file DEFAULT_API_FILENAME
|
|
||||||
|
|
||||||
cache["aliases"] = {}
|
cache["aliases"] = {}
|
||||||
cache["renames"] = {}
|
cache["renames"] = {}
|
||||||
cache["formulae"] = json_formulae.to_h do |json_formula|
|
cache["formulae"] = json_formulae.to_h do |json_formula|
|
||||||
json_formula["aliases"].each do |alias_name|
|
json_formula["aliases"].each do |alias_name|
|
||||||
cache["aliases"][alias_name] = json_formula["name"]
|
cache["aliases"][alias_name] = json_formula["name"]
|
||||||
end
|
|
||||||
(json_formula["oldnames"] || [json_formula["oldname"]].compact).each do |oldname|
|
|
||||||
cache["renames"][oldname] = json_formula["name"]
|
|
||||||
end
|
|
||||||
|
|
||||||
[json_formula["name"], json_formula.except("name")]
|
|
||||||
end
|
end
|
||||||
|
(json_formula["oldnames"] || [json_formula["oldname"]].compact).each do |oldname|
|
||||||
|
cache["renames"][oldname] = json_formula["name"]
|
||||||
|
end
|
||||||
|
|
||||||
|
[json_formula["name"], json_formula.except("name")]
|
||||||
end
|
end
|
||||||
|
|
||||||
updated
|
updated
|
||||||
|
@ -219,7 +219,6 @@ module Homebrew
|
|||||||
|
|
||||||
# TODO: remove this and fix tests when possible.
|
# TODO: remove this and fix tests when possible.
|
||||||
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
||||||
ENV.delete("HOMEBREW_INTERNAL_JSON_V3")
|
|
||||||
|
|
||||||
ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp
|
ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp
|
||||||
|
|
||||||
|
@ -7,16 +7,8 @@ module Cachable
|
|||||||
@cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped]))
|
@cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped]))
|
||||||
end
|
end
|
||||||
|
|
||||||
# NOTE: We overwrite here instead of using `Hash#clear` to handle frozen hashes.
|
|
||||||
sig { void }
|
sig { void }
|
||||||
def clear_cache
|
def clear_cache
|
||||||
overwrite_cache!({})
|
cache.clear
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
sig { params(hash: T::Hash[T.untyped, T.untyped]).void }
|
|
||||||
def overwrite_cache!(hash)
|
|
||||||
@cache = hash
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -213,71 +213,38 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_deps = if Homebrew::API.internal_json_v3?
|
add_deps = lambda do |spec|
|
||||||
lambda do |deps|
|
T.bind(self, SoftwareSpec)
|
||||||
T.bind(self, SoftwareSpec)
|
|
||||||
|
|
||||||
deps&.each do |name, info|
|
dep_json = json_formula.fetch("#{spec}_dependencies", json_formula)
|
||||||
tags = case info&.dig("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")
|
dep_json["dependencies"]&.each do |dep|
|
||||||
bounds = info["uses_from_macos"].dup || {}
|
# Backwards compatibility check - uses_from_macos used to be a part of dependencies on Linux
|
||||||
bounds.deep_transform_keys!(&:to_sym)
|
next if !json_formula.key?("uses_from_macos_bounds") && uses_from_macos_names.include?(dep) &&
|
||||||
bounds.deep_transform_values!(&:to_sym)
|
!Homebrew::SimulateSystem.simulating_or_running_on_macos?
|
||||||
|
|
||||||
if tags
|
depends_on dep
|
||||||
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
|
end
|
||||||
else
|
|
||||||
lambda do |spec|
|
|
||||||
T.bind(self, SoftwareSpec)
|
|
||||||
|
|
||||||
dep_json = json_formula.fetch("#{spec}_dependencies", json_formula)
|
[:build, :test, :recommended, :optional].each do |type|
|
||||||
|
dep_json["#{type}_dependencies"]&.each do |dep|
|
||||||
dep_json["dependencies"]&.each do |dep|
|
|
||||||
# Backwards compatibility check - uses_from_macos used to be a part of dependencies on Linux
|
# Backwards compatibility check - uses_from_macos used to be a part of dependencies on Linux
|
||||||
next if !json_formula.key?("uses_from_macos_bounds") && uses_from_macos_names.include?(dep) &&
|
next if !json_formula.key?("uses_from_macos_bounds") && uses_from_macos_names.include?(dep) &&
|
||||||
!Homebrew::SimulateSystem.simulating_or_running_on_macos?
|
!Homebrew::SimulateSystem.simulating_or_running_on_macos?
|
||||||
|
|
||||||
depends_on dep
|
depends_on dep => type
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
[:build, :test, :recommended, :optional].each do |type|
|
dep_json["uses_from_macos"]&.each_with_index do |dep, index|
|
||||||
dep_json["#{type}_dependencies"]&.each do |dep|
|
bounds = dep_json.fetch("uses_from_macos_bounds", [])[index].dup || {}
|
||||||
# Backwards compatibility check - uses_from_macos used to be a part of dependencies on Linux
|
bounds.deep_transform_keys!(&:to_sym)
|
||||||
next if !json_formula.key?("uses_from_macos_bounds") && uses_from_macos_names.include?(dep) &&
|
bounds.deep_transform_values!(&:to_sym)
|
||||||
!Homebrew::SimulateSystem.simulating_or_running_on_macos?
|
|
||||||
|
|
||||||
depends_on dep => type
|
if dep.is_a?(Hash)
|
||||||
end
|
uses_from_macos dep.deep_transform_values(&:to_sym).merge(bounds)
|
||||||
end
|
else
|
||||||
|
uses_from_macos dep, bounds
|
||||||
dep_json["uses_from_macos"]&.each_with_index do |dep, index|
|
|
||||||
bounds = dep_json.fetch("uses_from_macos_bounds", [])[index].dup || {}
|
|
||||||
bounds.deep_transform_keys!(&:to_sym)
|
|
||||||
bounds.deep_transform_values!(&:to_sym)
|
|
||||||
|
|
||||||
if dep.is_a?(Hash)
|
|
||||||
uses_from_macos dep.deep_transform_values(&:to_sym).merge(bounds)
|
|
||||||
else
|
|
||||||
uses_from_macos dep, bounds
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -299,15 +266,10 @@ module Formulary
|
|||||||
using: urls_stable["using"]&.to_sym,
|
using: urls_stable["using"]&.to_sym,
|
||||||
}.compact
|
}.compact
|
||||||
url urls_stable["url"], **url_spec
|
url urls_stable["url"], **url_spec
|
||||||
version Homebrew::API.internal_json_v3? ? json_formula["version"] : json_formula["versions"]["stable"]
|
version json_formula["versions"]["stable"]
|
||||||
sha256 urls_stable["checksum"] if urls_stable["checksum"].present?
|
sha256 urls_stable["checksum"] if urls_stable["checksum"].present?
|
||||||
|
|
||||||
if Homebrew::API.internal_json_v3?
|
instance_exec(:stable, &add_deps)
|
||||||
instance_exec(json_formula["dependencies"], &add_deps)
|
|
||||||
else
|
|
||||||
instance_exec(:stable, &add_deps)
|
|
||||||
end
|
|
||||||
|
|
||||||
requirements[:stable]&.each do |req|
|
requirements[:stable]&.each do |req|
|
||||||
depends_on req
|
depends_on req
|
||||||
end
|
end
|
||||||
@ -322,23 +284,14 @@ module Formulary
|
|||||||
}.compact
|
}.compact
|
||||||
url urls_head["url"], **url_spec
|
url urls_head["url"], **url_spec
|
||||||
|
|
||||||
if Homebrew::API.internal_json_v3?
|
instance_exec(:head, &add_deps)
|
||||||
instance_exec(json_formula["head_dependencies"], &add_deps)
|
|
||||||
else
|
|
||||||
instance_exec(:head, &add_deps)
|
|
||||||
end
|
|
||||||
|
|
||||||
requirements[:head]&.each do |req|
|
requirements[:head]&.each do |req|
|
||||||
depends_on req
|
depends_on req
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bottles_stable = if Homebrew::API.internal_json_v3?
|
bottles_stable = json_formula["bottle"]["stable"].presence
|
||||||
json_formula["bottle"]
|
|
||||||
else
|
|
||||||
json_formula["bottle"]["stable"]
|
|
||||||
end.presence
|
|
||||||
|
|
||||||
if bottles_stable
|
if bottles_stable
|
||||||
bottle do
|
bottle do
|
||||||
@ -426,26 +379,20 @@ module Formulary
|
|||||||
.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home)
|
.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home)
|
||||||
end
|
end
|
||||||
|
|
||||||
@tap_git_head_string = if Homebrew::API.internal_json_v3?
|
@tap_git_head_string = json_formula["tap_git_head"]
|
||||||
Homebrew::API::Formula.tap_git_head
|
|
||||||
else
|
|
||||||
json_formula["tap_git_head"]
|
|
||||||
end
|
|
||||||
|
|
||||||
def tap_git_head
|
def tap_git_head
|
||||||
self.class.instance_variable_get(:@tap_git_head_string)
|
self.class.instance_variable_get(:@tap_git_head_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Homebrew::API.internal_json_v3?
|
@oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact
|
||||||
@oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact
|
def oldnames
|
||||||
def oldnames
|
self.class.instance_variable_get(:@oldnames_array)
|
||||||
self.class.instance_variable_get(:@oldnames_array)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
@aliases_array = json_formula.fetch("aliases", [])
|
@aliases_array = json_formula.fetch("aliases", [])
|
||||||
def aliases
|
def aliases
|
||||||
self.class.instance_variable_get(:@aliases_array)
|
self.class.instance_variable_get(:@aliases_array)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@versioned_formulae_array = json_formula.fetch("versioned_formulae", [])
|
@versioned_formulae_array = json_formula.fetch("versioned_formulae", [])
|
||||||
|
@ -1307,8 +1307,6 @@ class CoreTap < AbstractCoreTap
|
|||||||
@tap_migrations ||= if Homebrew::EnvConfig.no_install_from_api?
|
@tap_migrations ||= if Homebrew::EnvConfig.no_install_from_api?
|
||||||
ensure_installed!
|
ensure_installed!
|
||||||
super
|
super
|
||||||
elsif Homebrew::API.internal_json_v3?
|
|
||||||
Homebrew::API::Formula.tap_migrations
|
|
||||||
else
|
else
|
||||||
migrations, = Homebrew::API.fetch_json_api_file "formula_tap_migrations.jws.json",
|
migrations, = Homebrew::API.fetch_json_api_file "formula_tap_migrations.jws.json",
|
||||||
stale_seconds: TAP_MIGRATIONS_STALE_SECONDS
|
stale_seconds: TAP_MIGRATIONS_STALE_SECONDS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user