Skip to content

Commit 08c63fe

Browse files
committed
fetch: add --all-platforms switch
- Iterate `[:macos, :linux] × [:intel, :arm]` (4 combos) for verifying multi-platform cask URLs and checksums in a single command, instead of `--os=all --arch=all` which iterates every macOS codename. - Tolerate `CaskInvalidError`/`CaskUnreadableError` during multi-combo fetches for casks that legitimately omit some platforms (mirrors the `bump-cask-pr.rb` rescue pattern).
1 parent 0b7a7c7 commit 08c63fe

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

Library/Homebrew/cli/args.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def only_formula_or_cask
126126

127127
sig { returns(T::Array[[Symbol, Symbol]]) }
128128
def os_arch_combinations
129+
return OnSystem::BASE_OS_OPTIONS.product(OnSystem::ARCH_OPTIONS) if @table[:all_platforms?]
130+
129131
skip_invalid_combinations = false
130132

131133
oses = case (os_sym = @table[:os]&.to_sym)

Library/Homebrew/cmd/fetch.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class FetchCmd < AbstractCommand
2525
flag "--arch=",
2626
description: "Download for the given CPU architecture. " \
2727
"(Pass `all` to download for all architectures.)"
28+
switch "--all-platforms",
29+
description: "Download for every supported OS and CPU architecture combination."
2830
flag "--bottle-tag=",
2931
description: "Download a bottle for given tag."
3032
switch "--HEAD",
@@ -65,6 +67,9 @@ class FetchCmd < AbstractCommand
6567
conflicts "--formula", "--cask"
6668
conflicts "--os", "--bottle-tag"
6769
conflicts "--arch", "--bottle-tag"
70+
conflicts "--all-platforms", "--os"
71+
conflicts "--all-platforms", "--arch"
72+
conflicts "--all-platforms", "--bottle-tag"
6873

6974
named_args [:formula, :cask], min: 1
7075
end
@@ -160,9 +165,13 @@ def run
160165

161166
os_arch_combinations.each do |os, arch|
162167
SimulateSystem.with(os:, arch:) do
163-
cask = Cask::CaskLoader.load(ref)
168+
loaded_cask = begin
169+
Cask::CaskLoader.load(ref)
170+
rescue Cask::CaskInvalidError, Cask::CaskUnreadableError
171+
raise unless cask.on_system_blocks_exist?
172+
end
164173

165-
if cask.url.nil? || cask.sha256.nil?
174+
if loaded_cask.nil? || loaded_cask.url.nil? || loaded_cask.sha256.nil?
166175
opoo "Cask #{cask} is not supported on os #{os} and arch #{arch}"
167176
next
168177
end
@@ -171,7 +180,7 @@ def run
171180
quarantine = true if quarantine.nil?
172181

173182
download = Cask::Download.new(
174-
cask,
183+
loaded_cask,
175184
quarantine:,
176185
require_sha: Homebrew::EnvConfig.cask_opts_require_sha?,
177186
)

Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/fetch_cmd.rbi

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)