Use plist main binary for Rosetta audit

Currently `brew audit` only audits the first binary in a cask.
For example the cask `wiso-steuer-2024` contains multiple binaries in
`Contents/MacOS`:
- `btssysteminfo`
- `whilfe`
- `wmain24`

The first binary (some telemetry tool) is not the main binary and not
a universal binary, but the other two are. Given that `wmain24` is
defined as the main binary in the `Contents/Info.plist`, brew probably
should audit that binary rather than just checking the first one.
This commit is contained in:
Lukas Eipert 2024-08-21 09:50:15 +02:00
parent f827410798
commit 8814a492aa

View File

@ -574,7 +574,11 @@ module Cask
File.executable?(f) && !File.directory?(f) && !f.end_with?(".dylib") File.executable?(f) && !File.directory?(f) && !f.end_with?(".dylib")
end end
add_error "No binaries in App: #{artifact.source}", location: cask.url.location if files.empty? 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 when Artifact::Binary
binary_path = path.to_s.gsub(cask.appdir, tmpdir) binary_path = path.to_s.gsub(cask.appdir, tmpdir)
system_command("lipo", args: ["-archs", binary_path], print_stderr: true) system_command("lipo", args: ["-archs", binary_path], print_stderr: true)
@ -739,6 +743,17 @@ module Cask
end end
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 } sig { void }
def audit_github_prerelease_version def audit_github_prerelease_version
odebug "Auditing GitHub prerelease" odebug "Auditing GitHub prerelease"