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
|
# @api private
|
||||||
module FormulaCellarChecks
|
module FormulaCellarChecks
|
||||||
|
REPOSITORY_AND_NOT_LIBRARY_REGEX = %r{#{HOMEBREW_REPOSITORY}(?!/Library/)}.freeze
|
||||||
|
|
||||||
def check_env_path(bin)
|
def check_env_path(bin)
|
||||||
# warn the user if stuff was installed outside of their PATH
|
# warn the user if stuff was installed outside of their PATH
|
||||||
return unless bin.directory?
|
return unless bin.directory?
|
||||||
@ -207,6 +209,25 @@ module FormulaCellarChecks
|
|||||||
EOS
|
EOS
|
||||||
end
|
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)
|
def check_shim_references(prefix)
|
||||||
return unless prefix.directory?
|
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_dirname(formula.share, formula.name))
|
||||||
problem_if_output(check_elisp_root(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_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_shim_references(formula.prefix))
|
||||||
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?))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user