Skip to content

Commit 1f37a11

Browse files
authored
Merge pull request #20051 from Homebrew/internal-api-bare-minimum
Reduce the internal formula API to contain the bare minimum data
2 parents fda1645 + 73b6439 commit 1f37a11

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

Library/Homebrew/dev-cmd/generate-cask-api.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ def run
7575
Homebrew::API.merge_variations(cask, bottle_tag:)
7676
end
7777

78-
unless args.dry_run?
79-
File.write("api/internal/cask.#{bottle_tag}.json", JSON.pretty_generate(variation_casks))
80-
end
78+
File.write("api/internal/cask.#{bottle_tag}.json", JSON.generate(variation_casks)) unless args.dry_run?
8179
end
8280
end
8381
end

Library/Homebrew/dev-cmd/generate-formula-api.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,26 @@ def run
6969
File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run?
7070

7171
OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag|
72-
variation_formulae = all_formulae.map do |_, formula|
73-
Homebrew::API.merge_variations(formula, bottle_tag:)
72+
variation_formulae = all_formulae.to_h do |name, formula|
73+
formula = Homebrew::API.merge_variations(formula, bottle_tag:)
74+
75+
version = Version.new(formula.dig("versions", "stable"))
76+
pkg_version = PkgVersion.new(version, formula["revision"])
77+
rebuild = formula.dig("bottle", "stable", "rebuild") || 0
78+
79+
bottle_collector = Utils::Bottles::Collector.new
80+
formula.dig("bottle", "stable", "files")&.each do |tag, data|
81+
tag = Utils::Bottles::Tag.from_symbol(tag)
82+
bottle_collector.add tag, checksum: Checksum.new(data["sha256"]), cellar: :any
83+
end
84+
85+
sha256 = bottle_collector.specification_for(bottle_tag)&.checksum&.to_s
86+
87+
[name, [pkg_version.to_s, rebuild, sha256]]
7488
end
7589

7690
unless args.dry_run?
77-
File.write("api/internal/formula.#{bottle_tag}.json", JSON.pretty_generate(variation_formulae))
91+
File.write("api/internal/formula.#{bottle_tag}.json", JSON.generate(variation_formulae))
7892
end
7993
end
8094
end

Library/Homebrew/extend/os/mac/utils/bottles.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def find_older_compatible_tag(tag)
4747
return if tag_version.blank?
4848

4949
tags.find do |candidate|
50-
next if candidate.arch != tag.arch
50+
next if candidate.standardized_arch != tag.standardized_arch
5151

5252
candidate.to_macos_version <= tag_version
5353
rescue MacOSVersion::Error

0 commit comments

Comments
 (0)