aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorJack Nagel2012-09-11 00:34:36 -0500
committerJack Nagel2012-09-11 00:45:45 -0500
commite909b54c9697e44d984cd642c866edbf240105da (patch)
tree03ded3348f3207cd01341aff24f5827c1acca075 /Library/Homebrew
parent5229bbf3040f8bf0a36abbfd49f0776ac61be3c7 (diff)
downloadbrew-e909b54c9697e44d984cd642c866edbf240105da.tar.bz2
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: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/formula_installer.rb26
-rw-r--r--Library/Homebrew/global.rb2
2 files changed, 12 insertions, 16 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 808f5c162..2a3724c19 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -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|
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index d8faef077..12157b0c0 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -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