Merge pull request #12225 from carlocab/two-level
mac/formula_cellar_checks: check for flat namespace libraries
This commit is contained in:
commit
556b8f16c6
@ -88,12 +88,38 @@ module FormulaCellarChecks
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_flat_namespace(formula)
|
||||||
|
return unless formula.prefix.directory?
|
||||||
|
return if formula.tap.present? && tap_audit_exception(:flat_namespace_allowlist, formula.name)
|
||||||
|
|
||||||
|
keg = Keg.new(formula.prefix)
|
||||||
|
flat_namespace_files = keg.mach_o_files.reject do |file|
|
||||||
|
next true unless file.dylib?
|
||||||
|
|
||||||
|
macho = MachO.open(file)
|
||||||
|
if MachO::Utils.fat_magic?(macho.magic)
|
||||||
|
macho.machos.map(&:header).all? { |h| h.flag? :MH_TWOLEVEL }
|
||||||
|
else
|
||||||
|
macho.header.flag? :MH_TWOLEVEL
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return if flat_namespace_files.empty?
|
||||||
|
|
||||||
|
<<~EOS
|
||||||
|
Libraries were compiled with a flat namespace.
|
||||||
|
This can cause linker errors due to name collisions, and
|
||||||
|
is often due to a bug in detecting the macOS version.
|
||||||
|
#{flat_namespace_files * "\n "}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
def audit_installed
|
def audit_installed
|
||||||
generic_audit_installed
|
generic_audit_installed
|
||||||
problem_if_output(check_shadowed_headers)
|
problem_if_output(check_shadowed_headers)
|
||||||
problem_if_output(check_openssl_links)
|
problem_if_output(check_openssl_links)
|
||||||
problem_if_output(check_python_framework_links(formula.lib))
|
problem_if_output(check_python_framework_links(formula.lib))
|
||||||
check_linkage
|
check_linkage
|
||||||
|
problem_if_output(check_flat_namespace(formula))
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_library_extension?(filename)
|
def valid_library_extension?(filename)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user