bottles: support :all tag.

This allows the creation of bottles which will be used by any macOS
version, architecture or OS (i.e. macOS or Linux).

Add `TODO` stubs for where the bottle generation logic should be
implemented.
This commit is contained in:
Mike McQuaid 2021-04-08 17:39:57 +01:00
parent 6b5213286c
commit 0cb1645d25
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
3 changed files with 52 additions and 32 deletions

View File

@ -585,6 +585,12 @@ module Homebrew
def merge(args:)
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"]
bottles_hash.each do |formula_name, bottle_hash|
ohai formula_name

View File

@ -493,7 +493,8 @@ describe "brew bottle" do
end
end
specify "::merge_json_files" do
describe "::merge_json_files" do
it "merges JSON files" do
bottles_hash = homebrew.merge_json_files(
[hello_hash_big_sur, hello_hash_catalina, unzip_hash_big_sur, unzip_hash_catalina],
)
@ -526,6 +527,11 @@ describe "brew bottle" do
)
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
describe "#merge_bottle_spec" do
it "allows new bottle hash to be empty" do
valid_keys = [:root_url, :prefix, :cellar, :rebuild, :sha256]

View File

@ -87,6 +87,8 @@ module Utils
sig { params(value: Symbol).returns(T.attached_class) }
def self.from_symbol(value)
return new(system: :all, arch: :all) if value == :all
@all_archs_regex ||= begin
all_archs = Hardware::CPU::ALL_ARCHS.map(&:to_s)
/
@ -118,7 +120,9 @@ module Utils
sig { returns(Symbol) }
def to_sym
if macos? && arch == :x86_64
if system == :all && arch == :all
:all
elsif macos? && arch == :x86_64
system
else
"#{arch}_#{system}".to_sym
@ -219,7 +223,11 @@ module Utils
private
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