stricter audit for Emacs Lisp installs

Require that the subdirectory in site-lisp match the formula name
exactly.  This lets us provide better information in the caveats and
will make it easier for helper methods to write to the correct
location (as in in Homebrew/homebrew-emacs#13).
This commit is contained in:
Alex Dunn 2015-10-31 21:42:43 -07:00
parent 91dd4d56d4
commit 168a2687f8
3 changed files with 23 additions and 12 deletions

View File

@ -143,12 +143,7 @@ class Caveats
if keg && keg.elisp_installed? if keg && keg.elisp_installed?
<<-EOS.undent <<-EOS.undent
Emacs Lisp files have been installed to: Emacs Lisp files have been installed to:
#{HOMEBREW_PREFIX}/share/emacs/site-lisp/ #{HOMEBREW_PREFIX}/share/emacs/site-lisp/#{f.name}
Add the following to your init file to have packages installed by
Homebrew added to your load-path:
(let ((default-directory "#{HOMEBREW_PREFIX}/share/emacs/site-lisp/"))
(normal-top-level-add-subdirs-to-load-path))
EOS EOS
end end
end end

View File

@ -173,19 +173,34 @@ module FormulaCellarChecks
EOS EOS
end end
def check_emacs_lisp(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
return if name == "emacs"
bad_dir_name = (share/"emacs/site-lisp").children.any? do |child|
child.directory? && child.basename.to_s != name
end
return unless bad_dir_name
<<-EOS
Emacs Lisp files were installed into the wrong site-lisp subdirectory.
They should be installed into:
#{share}/emacs/site-lisp/#{name}
EOS
end
def check_elisp_root(share, name)
return unless (share/"emacs/site-lisp").directory?
# Emacs itself can do what it wants # Emacs itself can do what it wants
return if name == "emacs" return if name == "emacs"
elisps = (share/"emacs/site-lisp").children.select { |file| %w[.el .elc].include? file.extname } elisps = (share/"emacs/site-lisp").children.select { |file| %w[.el .elc].include? file.extname }
return if elisps.empty? return if elisps.empty?
<<-EOS.undent <<-EOS.undent
Emacs Lisp files were linked directly to #{HOMEBREW_PREFIX}/share/emacs/site-lisp Emacs Lisp files were linked directly to #{HOMEBREW_PREFIX}/share/emacs/site-lisp
This may cause conflicts with other packages.
This may cause conflicts with other packages; install to a subdirectory instead, such as They should instead be installed into:
#{share}/emacs/site-lisp/#{name} #{share}/emacs/site-lisp/#{name}
The offending files are: The offending files are:
@ -206,7 +221,8 @@ module FormulaCellarChecks
audit_check_output(check_easy_install_pth(formula.lib)) audit_check_output(check_easy_install_pth(formula.lib))
audit_check_output(check_openssl_links) audit_check_output(check_openssl_links)
audit_check_output(check_python_framework_links(formula.lib)) audit_check_output(check_python_framework_links(formula.lib))
audit_check_output(check_emacs_lisp(formula.share, formula.name)) audit_check_output(check_elisp_dirname(formula.share, formula.name))
audit_check_output(check_elisp_root(formula.share, formula.name))
end end
private private

View File

@ -263,7 +263,7 @@ class Keg
end end
def elisp_installed? def elisp_installed?
Dir["#{path}/share/emacs/site-lisp/**/*.el"].any? (path/"share/emacs/site-lisp"/name).children.any? { |f| %w[.el .elc].include? f.extname }
end end
def version def version