From 168a2687f8ca00d59d8c4e1d1c50dc650f67cab8 Mon Sep 17 00:00:00 2001 From: Alex Dunn Date: Sat, 31 Oct 2015 21:42:43 -0700 Subject: [PATCH] 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). --- Library/Homebrew/caveats.rb | 7 +----- Library/Homebrew/formula_cellar_checks.rb | 26 ++++++++++++++++++----- Library/Homebrew/keg.rb | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index e4e880fa28..c1da2c4ea2 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -143,12 +143,7 @@ class Caveats if keg && keg.elisp_installed? <<-EOS.undent Emacs Lisp files have been installed to: - #{HOMEBREW_PREFIX}/share/emacs/site-lisp/ - - 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)) + #{HOMEBREW_PREFIX}/share/emacs/site-lisp/#{f.name} EOS end end diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index 071b3f4ddd..9622c98e6f 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -173,19 +173,34 @@ module FormulaCellarChecks EOS end - def check_emacs_lisp(share, name) + def check_elisp_dirname(share, name) 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 return if name == "emacs" elisps = (share/"emacs/site-lisp").children.select { |file| %w[.el .elc].include? file.extname } return if elisps.empty? - <<-EOS.undent Emacs Lisp files were linked directly to #{HOMEBREW_PREFIX}/share/emacs/site-lisp - - This may cause conflicts with other packages; install to a subdirectory instead, such as + This may cause conflicts with other packages. + They should instead be installed into: #{share}/emacs/site-lisp/#{name} The offending files are: @@ -206,7 +221,8 @@ module FormulaCellarChecks audit_check_output(check_easy_install_pth(formula.lib)) audit_check_output(check_openssl_links) 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 private diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 9b548b83af..4151895bc4 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -263,7 +263,7 @@ class Keg end 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 def version