formula_cellar_checks: check keg for mismatched arches
There have been a few instances I've noticed that we've been silently installing binaries built for x86_64 on ARM. There's probably more that I haven't found yet, so it seems useful to check this with an audit.
This commit is contained in:
parent
12d272abe8
commit
488ccfdf70
@ -314,6 +314,22 @@ module FormulaCellarChecks
|
|||||||
"No `cpuid` instruction detected. #{formula} should not use `ENV.runtime_cpu_detection`."
|
"No `cpuid` instruction detected. #{formula} should not use `ENV.runtime_cpu_detection`."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_binary_arches(formula)
|
||||||
|
return unless formula.prefix.directory?
|
||||||
|
|
||||||
|
keg = Keg.new(formula.prefix)
|
||||||
|
mismatches = keg.binary_executable_or_library_files.reject do |file|
|
||||||
|
file.arch == Hardware::CPU.arch
|
||||||
|
end
|
||||||
|
return if mismatches.empty?
|
||||||
|
|
||||||
|
<<~EOS
|
||||||
|
Binaries built for a non-native architecture were installed into #{formula}'s prefix.
|
||||||
|
The offending files are:
|
||||||
|
#{mismatches * "\n "}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
def audit_installed
|
def audit_installed
|
||||||
@new_formula ||= false
|
@new_formula ||= false
|
||||||
|
|
||||||
@ -334,6 +350,7 @@ module FormulaCellarChecks
|
|||||||
problem_if_output(check_plist(formula.prefix, formula.plist))
|
problem_if_output(check_plist(formula.prefix, formula.plist))
|
||||||
problem_if_output(check_python_symlinks(formula.name, formula.keg_only?))
|
problem_if_output(check_python_symlinks(formula.name, formula.keg_only?))
|
||||||
problem_if_output(check_cpuid_instruction(formula))
|
problem_if_output(check_cpuid_instruction(formula))
|
||||||
|
problem_if_output(check_binary_arches(formula))
|
||||||
end
|
end
|
||||||
alias generic_audit_installed audit_installed
|
alias generic_audit_installed audit_installed
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ module MachOShim
|
|||||||
|
|
||||||
machos.each do |m|
|
machos.each do |m|
|
||||||
arch = case m.cputype
|
arch = case m.cputype
|
||||||
when :x86_64, :i386, :ppc64 then m.cputype
|
when :x86_64, :i386, :ppc64, :arm64, :arm then m.cputype
|
||||||
when :ppc then :ppc7400
|
when :ppc then :ppc7400
|
||||||
else :dunno
|
else :dunno
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user