Skip to content
Snippets Groups Projects
Commit e909b54c authored by Jack Nagel's avatar Jack Nagel
Browse files

Tighten post-install checks


 - Avoid ENOTDIR by ensuring that the directories we are checking are
   actually directories.
 - DRY up the check_PATH method; paths are already available via the
   global ORIGINAL_PATHS.

Signed-off-by: default avatarJack Nagel <jacknagel@gmail.com>
parent 5229bbf3
No related branches found
No related tags found
No related merge requests found
......@@ -321,16 +321,12 @@ class FormulaInstaller
## checks
def paths
@paths ||= ENV['PATH'].split(':').map{ |p| File.expand_path p }
end
def check_PATH
# warn the user if stuff was installed outside of their PATH
[f.bin, f.sbin].each do |bin|
if bin.directory? and bin.children.length > 0
bin = (HOMEBREW_PREFIX/bin.basename).realpath.to_s
unless paths.include? bin
bin = (HOMEBREW_PREFIX/bin.basename).realpath
unless ORIGINAL_PATHS.include? bin
opoo "#{bin} is not in your PATH"
puts "You can amend this by altering your ~/.bashrc file"
@show_summary_heading = true
......@@ -341,7 +337,7 @@ class FormulaInstaller
def check_manpages
# Check for man pages that aren't in share/man
if (f.prefix+'man').exist?
if (f.prefix+'man').directory?
opoo 'A top-level "man" directory was found.'
puts "Homebrew requires that man pages live under share."
puts 'This can often be fixed by passing "--mandir=#{man}" to configure.'
......@@ -351,7 +347,7 @@ class FormulaInstaller
def check_infopages
# Check for info pages that aren't in share/info
if (f.prefix+'info').exist?
if (f.prefix+'info').directory?
opoo 'A top-level "info" directory was found.'
puts "Homebrew suggests that info pages live under share."
puts 'This can often be fixed by passing "--infodir=#{info}" to configure.'
......@@ -360,7 +356,7 @@ class FormulaInstaller
end
def check_jars
return unless File.exist? f.lib
return unless f.lib.directory?
jars = f.lib.children.select{|g| g.to_s =~ /\.jar$/}
unless jars.empty?
......@@ -376,7 +372,7 @@ class FormulaInstaller
end
def check_non_libraries
return unless File.exist? f.lib
return unless f.lib.directory?
valid_extensions = %w(.a .dylib .framework .jnilib .la .o .so
.jar .prl .pm)
......@@ -395,9 +391,9 @@ class FormulaInstaller
end
def audit_bin
return unless File.exist? f.bin
return unless f.bin.directory?
non_exes = f.bin.children.select {|g| File.directory? g or not File.executable? g}
non_exes = f.bin.children.select { |g| g.directory? or not g.executable? }
unless non_exes.empty?
opoo 'Non-executables were installed to "bin".'
......@@ -409,9 +405,9 @@ class FormulaInstaller
end
def audit_sbin
return unless File.exist? f.sbin
return unless f.sbin.directory?
non_exes = f.sbin.children.select {|g| File.directory? g or not File.executable? g}
non_exes = f.sbin.children.select { |g| g.directory? or not g.executable? }
unless non_exes.empty?
opoo 'Non-executables were installed to "sbin".'
......@@ -429,7 +425,7 @@ class FormulaInstaller
def check_m4
# Newer versions of Xcode don't come with autotools
return if MacOS::Xcode.version.to_f >= 4.3
return unless MacOS::Xcode.provides_autotools?
# If the user has added our path to dirlist, don't complain
return if File.open("/usr/share/aclocal/dirlist") do |dirlist|
......
......@@ -91,4 +91,4 @@ unless ARGV.include? "--no-compat" or ENV['HOMEBREW_NO_COMPAT']
require 'compatibility'
end
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(File.expand_path(p)) rescue nil }.compact.freeze
ORIGINAL_PATHS = ENV['PATH'].split(':').map{ |p| Pathname.new(p).expand_path rescue nil }.compact.freeze
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment