formula_cellar_checks: add more types
Signed-off-by: Michael Cho <michael@michaelcho.dev>
This commit is contained in:
parent
92a4311868
commit
e31a2b8ed7
@ -5,6 +5,7 @@ require "cache_store"
|
|||||||
require "linkage_checker"
|
require "linkage_checker"
|
||||||
|
|
||||||
module FormulaCellarChecks
|
module FormulaCellarChecks
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_shadowed_headers
|
def check_shadowed_headers
|
||||||
return if ["libtool", "subversion", "berkeley-db"].any? do |formula_name|
|
return if ["libtool", "subversion", "berkeley-db"].any? do |formula_name|
|
||||||
formula.name.start_with?(formula_name)
|
formula.name.start_with?(formula_name)
|
||||||
@ -26,6 +27,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_openssl_links
|
def check_openssl_links
|
||||||
return unless formula.prefix.directory?
|
return unless formula.prefix.directory?
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(lib: Pathname).returns(T.nilable(String)) }
|
||||||
def check_python_framework_links(lib)
|
def check_python_framework_links(lib)
|
||||||
python_modules = Pathname.glob lib/"python*/site-packages/**/*.so"
|
python_modules = Pathname.glob lib/"python*/site-packages/**/*.so"
|
||||||
framework_links = python_modules.select do |obj|
|
framework_links = python_modules.select do |obj|
|
||||||
@ -62,6 +65,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_linkage
|
def check_linkage
|
||||||
return unless formula.prefix.directory?
|
return unless formula.prefix.directory?
|
||||||
|
|
||||||
@ -88,9 +92,10 @@ module FormulaCellarChecks
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(formula: Formula).returns(T.nilable(String)) }
|
||||||
def check_flat_namespace(formula)
|
def check_flat_namespace(formula)
|
||||||
return unless formula.prefix.directory?
|
return unless formula.prefix.directory?
|
||||||
return if formula.tap.present? && formula.tap.audit_exception(:flat_namespace_allowlist, formula.name)
|
return if formula.tap&.audit_exception(:flat_namespace_allowlist, formula.name)
|
||||||
|
|
||||||
keg = Keg.new(formula.prefix)
|
keg = Keg.new(formula.prefix)
|
||||||
flat_namespace_files = keg.mach_o_files.reject do |file|
|
flat_namespace_files = keg.mach_o_files.reject do |file|
|
||||||
@ -113,6 +118,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def audit_installed
|
def audit_installed
|
||||||
generic_audit_installed
|
generic_audit_installed
|
||||||
problem_if_output(check_shadowed_headers)
|
problem_if_output(check_shadowed_headers)
|
||||||
@ -122,6 +128,7 @@ module FormulaCellarChecks
|
|||||||
problem_if_output(check_flat_namespace(formula))
|
problem_if_output(check_flat_namespace(formula))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(filename: Pathname).returns(T::Boolean) }
|
||||||
def valid_library_extension?(filename)
|
def valid_library_extension?(filename)
|
||||||
macos_lib_extensions = %w[.dylib .framework]
|
macos_lib_extensions = %w[.dylib .framework]
|
||||||
generic_valid_library_extension?(filename) || macos_lib_extensions.include?(filename.extname)
|
generic_valid_library_extension?(filename) || macos_lib_extensions.include?(filename.extname)
|
||||||
|
@ -17,6 +17,7 @@ module FormulaCellarChecks
|
|||||||
sig { abstract.params(output: T.nilable(String)).void }
|
sig { abstract.params(output: T.nilable(String)).void }
|
||||||
def problem_if_output(output); end
|
def problem_if_output(output); end
|
||||||
|
|
||||||
|
sig { params(bin: Pathname).returns(T.nilable(String)) }
|
||||||
def check_env_path(bin)
|
def check_env_path(bin)
|
||||||
return if Homebrew::EnvConfig.no_env_hints?
|
return if Homebrew::EnvConfig.no_env_hints?
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_manpages
|
def check_manpages
|
||||||
# Check for man pages that aren't in share/man
|
# Check for man pages that aren't in share/man
|
||||||
return unless (formula.prefix/"man").directory?
|
return unless (formula.prefix/"man").directory?
|
||||||
@ -47,6 +49,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_infopages
|
def check_infopages
|
||||||
# Check for info pages that aren't in share/info
|
# Check for info pages that aren't in share/info
|
||||||
return unless (formula.prefix/"info").directory?
|
return unless (formula.prefix/"info").directory?
|
||||||
@ -58,6 +61,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_jars
|
def check_jars
|
||||||
return unless formula.lib.directory?
|
return unless formula.lib.directory?
|
||||||
|
|
||||||
@ -77,11 +81,13 @@ module FormulaCellarChecks
|
|||||||
|
|
||||||
VALID_LIBRARY_EXTENSIONS = %w[.a .jnilib .la .o .so .jar .prl .pm .sh].freeze
|
VALID_LIBRARY_EXTENSIONS = %w[.a .jnilib .la .o .so .jar .prl .pm .sh].freeze
|
||||||
|
|
||||||
|
sig { params(filename: Pathname).returns(T::Boolean) }
|
||||||
def valid_library_extension?(filename)
|
def valid_library_extension?(filename)
|
||||||
VALID_LIBRARY_EXTENSIONS.include? filename.extname
|
VALID_LIBRARY_EXTENSIONS.include? filename.extname
|
||||||
end
|
end
|
||||||
alias generic_valid_library_extension? valid_library_extension?
|
alias generic_valid_library_extension? valid_library_extension?
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
def check_non_libraries
|
def check_non_libraries
|
||||||
return unless formula.lib.directory?
|
return unless formula.lib.directory?
|
||||||
|
|
||||||
@ -100,6 +106,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(bin: Pathname).returns(T.nilable(String)) }
|
||||||
def check_non_executables(bin)
|
def check_non_executables(bin)
|
||||||
return unless bin.directory?
|
return unless bin.directory?
|
||||||
|
|
||||||
@ -113,6 +120,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(bin: Pathname).returns(T.nilable(String)) }
|
||||||
def check_generic_executables(bin)
|
def check_generic_executables(bin)
|
||||||
return unless bin.directory?
|
return unless bin.directory?
|
||||||
|
|
||||||
@ -130,6 +138,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(lib: Pathname).returns(T.nilable(String)) }
|
||||||
def check_easy_install_pth(lib)
|
def check_easy_install_pth(lib)
|
||||||
pth_found = Dir["#{lib}/python3*/site-packages/easy-install.pth"].map { |f| File.dirname(f) }
|
pth_found = Dir["#{lib}/python3*/site-packages/easy-install.pth"].map { |f| File.dirname(f) }
|
||||||
return if pth_found.empty?
|
return if pth_found.empty?
|
||||||
@ -143,6 +152,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(share: Pathname, name: String).returns(T.nilable(String)) }
|
||||||
def check_elisp_dirname(share, name)
|
def check_elisp_dirname(share, name)
|
||||||
return unless (share/"emacs/site-lisp").directory?
|
return unless (share/"emacs/site-lisp").directory?
|
||||||
# Emacs itself can do what it wants
|
# Emacs itself can do what it wants
|
||||||
@ -161,6 +171,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(share: Pathname, name: String).returns(T.nilable(String)) }
|
||||||
def check_elisp_root(share, name)
|
def check_elisp_root(share, name)
|
||||||
return unless (share/"emacs/site-lisp").directory?
|
return unless (share/"emacs/site-lisp").directory?
|
||||||
# Emacs itself can do what it wants
|
# Emacs itself can do what it wants
|
||||||
@ -216,6 +227,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(prefix: Pathname).returns(T.nilable(String)) }
|
||||||
def check_shim_references(prefix)
|
def check_shim_references(prefix)
|
||||||
return unless prefix.directory?
|
return unless prefix.directory?
|
||||||
|
|
||||||
@ -274,6 +286,7 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(name: String, keg_only: T::Boolean).returns(T.nilable(String)) }
|
||||||
def check_python_symlinks(name, keg_only)
|
def check_python_symlinks(name, keg_only)
|
||||||
return unless keg_only
|
return unless keg_only
|
||||||
return unless name.start_with? "python"
|
return unless name.start_with? "python"
|
||||||
@ -286,6 +299,7 @@ module FormulaCellarChecks
|
|||||||
"Python formulae that are keg-only should not create `pip3` and `wheel3` symlinks."
|
"Python formulae that are keg-only should not create `pip3` and `wheel3` symlinks."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(formula: Formula).returns(T.nilable(String)) }
|
||||||
def check_service_command(formula)
|
def check_service_command(formula)
|
||||||
return unless formula.prefix.directory?
|
return unless formula.prefix.directory?
|
||||||
return unless formula.service?
|
return unless formula.service?
|
||||||
@ -294,6 +308,7 @@ module FormulaCellarChecks
|
|||||||
"Service command does not exist" unless File.exist?(formula.service.command.first)
|
"Service command does not exist" unless File.exist?(formula.service.command.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(formula: Formula).returns(T.nilable(String)) }
|
||||||
def check_cpuid_instruction(formula)
|
def check_cpuid_instruction(formula)
|
||||||
# Checking for `cpuid` only makes sense on Intel:
|
# Checking for `cpuid` only makes sense on Intel:
|
||||||
# https://en.wikipedia.org/wiki/CPUID
|
# https://en.wikipedia.org/wiki/CPUID
|
||||||
@ -396,6 +411,7 @@ module FormulaCellarChecks
|
|||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def audit_installed
|
def audit_installed
|
||||||
@new_formula ||= false
|
@new_formula ||= false
|
||||||
|
|
||||||
@ -422,6 +438,7 @@ module FormulaCellarChecks
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
sig { params(dir: T.any(Pathname, String), pattern: String).returns(T::Array[String]) }
|
||||||
def relative_glob(dir, pattern)
|
def relative_glob(dir, pattern)
|
||||||
File.directory?(dir) ? Dir.chdir(dir) { Dir[pattern] } : []
|
File.directory?(dir) ? Dir.chdir(dir) { Dir[pattern] } : []
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user