From 475fc1d2812c5a831a18bbcc4846dfeff398aa23 Mon Sep 17 00:00:00 2001 From: Justin Krehel <39449589+krehel@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:13:31 -0400 Subject: [PATCH 1/2] cask/audit: filter bad artifacts in rosetta audit --- Library/Homebrew/cask/audit.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index f0ed98b2da9d9..5a67bbda83b37 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -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) } + 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") + 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 From a7b2da0fc410c8f6e140d7ee92e878d59896ef77 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 28 Jun 2024 08:33:20 +0100 Subject: [PATCH 2/2] cask/audit: use select instead of reject. Co-authored-by: Rylan Polster --- Library/Homebrew/cask/audit.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index 5a67bbda83b37..5e9be9be3760b 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -580,8 +580,8 @@ def audit_rosetta result = case artifact when Artifact::App - files = Dir[path/"Contents/MacOS/*"].reject do |f| - !File.executable?(f) || File.directory?(f) || f.end_with?(".dylib") + files = Dir[path/"Contents/MacOS/*"].select do |f| + File.executable?(f) && !File.directory?(f) && !f.end_with?(".dylib") 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)