Skip to content

Commit

Permalink
cask/audit: filter bad artifacts in rosetta audit
Browse files Browse the repository at this point in the history
  • Loading branch information
krehel committed Jun 27, 2024
1 parent fc3ba1b commit 475fc1d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,19 @@ def audit_rosetta
odebug "Auditing Rosetta 2 requirement"

extract_artifacts do |artifacts, tmpdir|
is_container = artifacts.any? { |a| a.is_a?(Artifact::App) || a.is_a?(Artifact::Pkg) }

Check warning on line 573 in Library/Homebrew/cask/audit.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cask/audit.rb#L573

Added line #L573 was not covered by tests

artifacts.filter { |a| a.is_a?(Artifact::App) || a.is_a?(Artifact::Binary) }
.each do |artifact|
next if artifact.is_a?(Artifact::Binary) && is_container

path = tmpdir/artifact.source.relative_path_from(cask.staged_path)

result = case artifact
when Artifact::App
files = Dir[path/"Contents/MacOS/*"]
files = Dir[path/"Contents/MacOS/*"].reject do |f|
!File.executable?(f) || File.directory?(f) || f.end_with?(".dylib")

Check warning on line 584 in Library/Homebrew/cask/audit.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cask/audit.rb#L584

Added line #L584 was not covered by tests
end
add_error "No binaries in App: #{artifact.source}", location: cask.url.location if files.empty?
system_command("lipo", args: ["-archs", files.first], print_stderr: false)
when Artifact::Binary
Expand Down

0 comments on commit 475fc1d

Please sign in to comment.