audit: Add check_repository_references
Ensure that any references to HOMEBREW_REPOSITORY are within HOMEBREW_LIBRARY.
This commit is contained in:
parent
65b9e1231d
commit
7b408dffc9
@ -7,6 +7,8 @@ require "utils/shell"
|
||||
#
|
||||
# @api private
|
||||
module FormulaCellarChecks
|
||||
REPOSITORY_AND_NOT_LIBRARY_REGEX = %r{#{HOMEBREW_REPOSITORY}(?!/Library/)}.freeze
|
||||
|
||||
def check_env_path(bin)
|
||||
# warn the user if stuff was installed outside of their PATH
|
||||
return unless bin.directory?
|
||||
@ -207,6 +209,25 @@ module FormulaCellarChecks
|
||||
EOS
|
||||
end
|
||||
|
||||
def check_repository_references(prefix)
|
||||
return unless prefix.directory?
|
||||
|
||||
keg = Keg.new(prefix)
|
||||
|
||||
matches = []
|
||||
keg.each_unique_file_matching(HOMEBREW_REPOSITORY) do |f|
|
||||
matches << f.relative_path_from(keg.to_path) if f.read.match? REPOSITORY_AND_NOT_LIBRARY_REGEX
|
||||
end
|
||||
|
||||
return if matches.empty?
|
||||
|
||||
<<~EOS
|
||||
Files were found with references to the Homebrew repository directory
|
||||
that are outside of the Library directory. The offending files are:
|
||||
#{matches * "\n "}
|
||||
EOS
|
||||
end
|
||||
|
||||
def check_shim_references(prefix)
|
||||
return unless prefix.directory?
|
||||
|
||||
@ -292,6 +313,7 @@ module FormulaCellarChecks
|
||||
problem_if_output(check_elisp_dirname(formula.share, formula.name))
|
||||
problem_if_output(check_elisp_root(formula.share, formula.name))
|
||||
problem_if_output(check_python_packages(formula.lib, formula.deps))
|
||||
problem_if_output(check_repository_references(formula.prefix))
|
||||
problem_if_output(check_shim_references(formula.prefix))
|
||||
problem_if_output(check_plist(formula.prefix, formula.plist))
|
||||
problem_if_output(check_python_symlinks(formula.name, formula.keg_only?))
|
||||
|
Loading…
x
Reference in New Issue
Block a user