diff --git a/Library/Homebrew/dev-cmd/generate-cask-api.rb b/Library/Homebrew/dev-cmd/generate-cask-api.rb index 48bcfdbd40..9f639aec52 100644 --- a/Library/Homebrew/dev-cmd/generate-cask-api.rb +++ b/Library/Homebrew/dev-cmd/generate-cask-api.rb @@ -75,9 +75,7 @@ module Homebrew Homebrew::API.merge_variations(cask, bottle_tag:) end - unless args.dry_run? - File.write("api/internal/cask.#{bottle_tag}.json", JSON.pretty_generate(variation_casks)) - end + File.write("api/internal/cask.#{bottle_tag}.json", JSON.generate(variation_casks)) unless args.dry_run? end end end diff --git a/Library/Homebrew/dev-cmd/generate-formula-api.rb b/Library/Homebrew/dev-cmd/generate-formula-api.rb index 04a2077f9d..5741ce6872 100644 --- a/Library/Homebrew/dev-cmd/generate-formula-api.rb +++ b/Library/Homebrew/dev-cmd/generate-formula-api.rb @@ -69,12 +69,26 @@ module Homebrew File.write("_data/formula_canonical.json", "#{canonical_json}\n") unless args.dry_run? OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag| - variation_formulae = all_formulae.map do |_, formula| - Homebrew::API.merge_variations(formula, bottle_tag:) + variation_formulae = all_formulae.to_h do |name, formula| + formula = Homebrew::API.merge_variations(formula, bottle_tag:) + + version = Version.new(formula.dig("versions", "stable")) + pkg_version = PkgVersion.new(version, formula["revision"]) + rebuild = formula.dig("bottle", "stable", "rebuild") || 0 + + bottle_collector = Utils::Bottles::Collector.new + formula.dig("bottle", "stable", "files")&.each do |tag, data| + tag = Utils::Bottles::Tag.from_symbol(tag) + bottle_collector.add tag, checksum: Checksum.new(data["sha256"]), cellar: :any + end + + sha256 = bottle_collector.specification_for(bottle_tag)&.checksum&.to_s + + [name, [pkg_version.to_s, rebuild, sha256]] end unless args.dry_run? - File.write("api/internal/formula.#{bottle_tag}.json", JSON.pretty_generate(variation_formulae)) + File.write("api/internal/formula.#{bottle_tag}.json", JSON.generate(variation_formulae)) end end end diff --git a/Library/Homebrew/extend/os/mac/utils/bottles.rb b/Library/Homebrew/extend/os/mac/utils/bottles.rb index 754aeaec64..9b4c71a914 100644 --- a/Library/Homebrew/extend/os/mac/utils/bottles.rb +++ b/Library/Homebrew/extend/os/mac/utils/bottles.rb @@ -47,7 +47,7 @@ module Utils return if tag_version.blank? tags.find do |candidate| - next if candidate.arch != tag.arch + next if candidate.standardized_arch != tag.standardized_arch candidate.to_macos_version <= tag_version rescue MacOSVersion::Error