Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formula_cellar_checks: check plist. #7485

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions Library/Homebrew/formula_cellar_checks.rb
Expand Up @@ -224,6 +224,41 @@ def check_shim_references(prefix)
EOS
end

def check_plist(prefix, plist)
return unless prefix.directory?

plist = begin
Plist.parse_xml(plist)
rescue
nil
end
return if plist.blank?

program_location = plist["ProgramArguments"]&.first
key = "first ProgramArguments value"
if program_location.blank?
program_location = plist["Program"]
key = "Program"
end
return if program_location.blank?

Dir.chdir("/") do
unless File.exist?(program_location)
return <<~EOS
The plist #{key} does not exist:
#{program_location}
EOS
end

return if File.executable?(program_location)
end

<<~EOS
The plist #{key} is not executable:
#{program_location}
EOS
end

def audit_installed
@new_formula ||= false

Expand All @@ -240,6 +275,7 @@ def audit_installed
problem_if_output(check_elisp_root(formula.share, formula.name))
problem_if_output(check_python_packages(formula.lib, formula.deps))
problem_if_output(check_shim_references(formula.prefix))
problem_if_output(check_plist(formula.prefix, formula.plist))
end
alias generic_audit_installed audit_installed

Expand Down