Merge pull request #11077 from MikeMcQuaid/any_bottles
Support `all: SHA256` bottles.
This commit is contained in:
commit
1d34f7f2fa
@ -339,7 +339,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_, _, bottle_cellar = Formula[f.name].bottle_specification.checksum_for(bottle_tag, exact: true)
|
_, _, bottle_cellar = Formula[f.name].bottle_specification.checksum_for(bottle_tag, no_older_versions: true)
|
||||||
relocatable = [:any, :any_skip_relocation].include?(bottle_cellar)
|
relocatable = [:any, :any_skip_relocation].include?(bottle_cellar)
|
||||||
skip_relocation = bottle_cellar == :any_skip_relocation
|
skip_relocation = bottle_cellar == :any_skip_relocation
|
||||||
|
|
||||||
@ -579,6 +579,12 @@ module Homebrew
|
|||||||
def merge(args:)
|
def merge(args:)
|
||||||
bottles_hash = merge_json_files(parse_json_files(args.named))
|
bottles_hash = merge_json_files(parse_json_files(args.named))
|
||||||
|
|
||||||
|
# TODO: deduplicate --no-json bottles by:
|
||||||
|
# 1. throwing away bottles for newer versions of macOS if their SHA256 is
|
||||||
|
# identical
|
||||||
|
# 2. generating `all: $SHA256` bottles that can be used on macOS and Linux
|
||||||
|
# i.e. need to be `any_skip_relocation` and contain no ELF/MachO files.
|
||||||
|
|
||||||
any_cellars = ["any", "any_skip_relocation"]
|
any_cellars = ["any", "any_skip_relocation"]
|
||||||
bottles_hash.each do |formula_name, bottle_hash|
|
bottles_hash.each do |formula_name, bottle_hash|
|
||||||
ohai formula_name
|
ohai formula_name
|
||||||
|
@ -158,7 +158,7 @@ module Homebrew
|
|||||||
|
|
||||||
formulae.each do |f|
|
formulae.each do |f|
|
||||||
name = f.name.downcase
|
name = f.name.downcase
|
||||||
if f.bottle_specification.tag?(@bottle_tag, exact: true)
|
if f.bottle_specification.tag?(@bottle_tag, no_older_versions: true)
|
||||||
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: already bottled" if any_named_args
|
puts "#{Tty.bold}#{Tty.green}#{name}#{Tty.reset}: already bottled" if any_named_args
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -16,10 +16,10 @@ module Utils
|
|||||||
|
|
||||||
alias generic_find_matching_tag find_matching_tag
|
alias generic_find_matching_tag find_matching_tag
|
||||||
|
|
||||||
def find_matching_tag(tag, exact: false)
|
def find_matching_tag(tag, no_older_versions: false)
|
||||||
# Used primarily by developers testing beta macOS releases.
|
# Used primarily by developers testing beta macOS releases.
|
||||||
if exact || (OS::Mac.prerelease? && Homebrew::EnvConfig.developer? &&
|
if no_older_versions ||
|
||||||
Homebrew::EnvConfig.skip_or_later_bottles?)
|
(OS::Mac.prerelease? && Homebrew::EnvConfig.developer? && Homebrew::EnvConfig.skip_or_later_bottles?)
|
||||||
generic_find_matching_tag(tag)
|
generic_find_matching_tag(tag)
|
||||||
else
|
else
|
||||||
generic_find_matching_tag(tag) ||
|
generic_find_matching_tag(tag) ||
|
||||||
|
@ -485,9 +485,9 @@ class BottleSpecification
|
|||||||
cellar == :any_skip_relocation
|
cellar == :any_skip_relocation
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(tag: T.any(Symbol, Utils::Bottles::Tag), exact: T::Boolean).returns(T::Boolean) }
|
sig { params(tag: T.any(Symbol, Utils::Bottles::Tag), no_older_versions: T::Boolean).returns(T::Boolean) }
|
||||||
def tag?(tag, exact: false)
|
def tag?(tag, no_older_versions: false)
|
||||||
checksum_for(tag, exact: exact) ? true : false
|
checksum_for(tag, no_older_versions: no_older_versions) ? true : false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checksum methods in the DSL's bottle block take
|
# Checksum methods in the DSL's bottle block take
|
||||||
@ -532,14 +532,14 @@ class BottleSpecification
|
|||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
tag: T.any(Symbol, Utils::Bottles::Tag),
|
tag: T.any(Symbol, Utils::Bottles::Tag),
|
||||||
exact: T::Boolean,
|
no_older_versions: T::Boolean,
|
||||||
).returns(
|
).returns(
|
||||||
T.nilable([Checksum, Symbol, T.any(Symbol, String)]),
|
T.nilable([Checksum, Symbol, T.any(Symbol, String)]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
def checksum_for(tag, exact: false)
|
def checksum_for(tag, no_older_versions: false)
|
||||||
collector.fetch_checksum_for(tag, exact: exact)
|
collector.fetch_checksum_for(tag, no_older_versions: no_older_versions)
|
||||||
end
|
end
|
||||||
|
|
||||||
def checksums
|
def checksums
|
||||||
|
@ -493,37 +493,43 @@ describe "brew bottle" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "::merge_json_files" do
|
describe "::merge_json_files" do
|
||||||
bottles_hash = homebrew.merge_json_files(
|
it "merges JSON files" do
|
||||||
[hello_hash_big_sur, hello_hash_catalina, unzip_hash_big_sur, unzip_hash_catalina],
|
bottles_hash = homebrew.merge_json_files(
|
||||||
)
|
[hello_hash_big_sur, hello_hash_catalina, unzip_hash_big_sur, unzip_hash_catalina],
|
||||||
|
)
|
||||||
|
|
||||||
hello_hash = bottles_hash["hello"]
|
hello_hash = bottles_hash["hello"]
|
||||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
expect(hello_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
||||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("hello-1.0.big_sur.bottle.tar.gz")
|
expect(hello_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("hello-1.0.big_sur.bottle.tar.gz")
|
||||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("hello--1.0.big_sur.bottle.tar.gz")
|
expect(hello_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("hello--1.0.big_sur.bottle.tar.gz")
|
||||||
expect(hello_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
expect(hello_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
||||||
"a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
"a0af7dcbb5c83f6f3f7ecd507c2d352c1a018f894d51ad241ce8492fa598010f",
|
||||||
)
|
)
|
||||||
expect(hello_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any_skip_relocation")
|
expect(hello_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any_skip_relocation")
|
||||||
expect(hello_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("hello-1.0.catalina.bottle.tar.gz")
|
expect(hello_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("hello-1.0.catalina.bottle.tar.gz")
|
||||||
expect(hello_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("hello--1.0.catalina.bottle.tar.gz")
|
expect(hello_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("hello--1.0.catalina.bottle.tar.gz")
|
||||||
expect(hello_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
expect(hello_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
||||||
"5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
"5334dd344986e46b2aa4f0471cac7b0914bd7de7cb890a34415771788d03f2ac",
|
||||||
)
|
)
|
||||||
unzip_hash = bottles_hash["unzip"]
|
unzip_hash = bottles_hash["unzip"]
|
||||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
expect(unzip_hash["bottle"]["tags"]["big_sur"]["cellar"]).to eq("any_skip_relocation")
|
||||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("unzip-2.0.big_sur.bottle.tar.gz")
|
expect(unzip_hash["bottle"]["tags"]["big_sur"]["filename"]).to eq("unzip-2.0.big_sur.bottle.tar.gz")
|
||||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("unzip--2.0.big_sur.bottle.tar.gz")
|
expect(unzip_hash["bottle"]["tags"]["big_sur"]["local_filename"]).to eq("unzip--2.0.big_sur.bottle.tar.gz")
|
||||||
expect(unzip_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
expect(unzip_hash["bottle"]["tags"]["big_sur"]["sha256"]).to eq(
|
||||||
"16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
"16cf230afdfcb6306c208d169549cf8773c831c8653d2c852315a048960d7e72",
|
||||||
)
|
)
|
||||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any")
|
expect(unzip_hash["bottle"]["tags"]["catalina"]["cellar"]).to eq("any")
|
||||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("unzip-2.0.catalina.bottle.tar.gz")
|
expect(unzip_hash["bottle"]["tags"]["catalina"]["filename"]).to eq("unzip-2.0.catalina.bottle.tar.gz")
|
||||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("unzip--2.0.catalina.bottle.tar.gz")
|
expect(unzip_hash["bottle"]["tags"]["catalina"]["local_filename"]).to eq("unzip--2.0.catalina.bottle.tar.gz")
|
||||||
expect(unzip_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
expect(unzip_hash["bottle"]["tags"]["catalina"]["sha256"]).to eq(
|
||||||
"d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
"d9cc50eec8ac243148a121049c236cba06af4a0b1156ab397d0a2850aa79c137",
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: add deduplication tests e.g.
|
||||||
|
# it "deduplicates JSON files with matching macOS checksums"
|
||||||
|
# it "deduplicates JSON files with matching OS checksums" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#merge_bottle_spec" do
|
describe "#merge_bottle_spec" do
|
||||||
|
@ -87,6 +87,8 @@ module Utils
|
|||||||
|
|
||||||
sig { params(value: Symbol).returns(T.attached_class) }
|
sig { params(value: Symbol).returns(T.attached_class) }
|
||||||
def self.from_symbol(value)
|
def self.from_symbol(value)
|
||||||
|
return new(system: :all, arch: :all) if value == :all
|
||||||
|
|
||||||
@all_archs_regex ||= begin
|
@all_archs_regex ||= begin
|
||||||
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
|
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
|
||||||
/
|
/
|
||||||
@ -118,7 +120,9 @@ module Utils
|
|||||||
|
|
||||||
sig { returns(Symbol) }
|
sig { returns(Symbol) }
|
||||||
def to_sym
|
def to_sym
|
||||||
if macos? && arch == :x86_64
|
if system == :all && arch == :all
|
||||||
|
:all
|
||||||
|
elsif macos? && arch == :x86_64
|
||||||
system
|
system
|
||||||
else
|
else
|
||||||
"#{arch}_#{system}".to_sym
|
"#{arch}_#{system}".to_sym
|
||||||
@ -204,22 +208,26 @@ module Utils
|
|||||||
|
|
||||||
sig {
|
sig {
|
||||||
params(
|
params(
|
||||||
tag: T.any(Symbol, Utils::Bottles::Tag),
|
tag: T.any(Symbol, Utils::Bottles::Tag),
|
||||||
exact: T::Boolean,
|
no_older_versions: T::Boolean,
|
||||||
).returns(
|
).returns(
|
||||||
T.nilable([Checksum, Symbol, T.any(Symbol, String)]),
|
T.nilable([Checksum, Symbol, T.any(Symbol, String)]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
def fetch_checksum_for(tag, exact: false)
|
def fetch_checksum_for(tag, no_older_versions: false)
|
||||||
tag = Utils::Bottles::Tag.from_symbol(tag) if tag.is_a?(Symbol)
|
tag = Utils::Bottles::Tag.from_symbol(tag) if tag.is_a?(Symbol)
|
||||||
tag = find_matching_tag(tag, exact: exact)&.to_sym
|
tag = find_matching_tag(tag, no_older_versions: no_older_versions)&.to_sym
|
||||||
return self[tag][:checksum], tag, self[tag][:cellar] if tag
|
return self[tag][:checksum], tag, self[tag][:cellar] if tag
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def find_matching_tag(tag, exact: false)
|
def find_matching_tag(tag, no_older_versions: false)
|
||||||
tag if key?(tag.to_sym)
|
if key?(tag.to_sym)
|
||||||
|
tag
|
||||||
|
elsif key?(:all)
|
||||||
|
Tag.from_symbol(:all)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user