diff --git a/Library/Homebrew/cask/audit.rb b/Library/Homebrew/cask/audit.rb index e903d558de..23ee6c9748 100644 --- a/Library/Homebrew/cask/audit.rb +++ b/Library/Homebrew/cask/audit.rb @@ -574,7 +574,11 @@ module Cask 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) + + main_binary = get_plist_main_binary(path) + main_binary ||= files.first + + system_command("lipo", args: ["-archs", main_binary], print_stderr: false) when Artifact::Binary binary_path = path.to_s.gsub(cask.appdir, tmpdir) system_command("lipo", args: ["-archs", binary_path], print_stderr: true) @@ -739,6 +743,17 @@ module Cask end end + sig { params(path: Pathname).returns(T.nilable(String)) } + def get_plist_main_binary(path) + return unless online? + + plist_path = "#{path}/Contents/Info.plist" + return unless File.exist?(plist_path) + + plist = system_command!("plutil", args: ["-convert", "xml1", "-o", "-", plist_path]).plist + plist["CFBundleExecutable"].presence + end + sig { void } def audit_github_prerelease_version odebug "Auditing GitHub prerelease"