doctor: extract helper from stray file checks

This commit is contained in:
Jack Nagel 2013-05-23 22:50:41 -05:00
parent 8559725645
commit 6a020239d1

View File

@ -97,9 +97,13 @@ def check_for_macgpg2
end unless File.exist? '/usr/local/MacGPG2/share/gnupg/VERSION' end unless File.exist? '/usr/local/MacGPG2/share/gnupg/VERSION'
end end
def check_for_stray_dylibs def __check_stray_files(pattern, white_list, message)
unbrewed_dylibs = Dir['/usr/local/lib/*.dylib'].select { |f| File.file? f and not File.symlink? f } files = Dir[pattern].select { |f| File.file? f and not File.symlink? f }
bad = files.reject {|d| white_list.key? File.basename(d) }
inject_file_list(bad, message) unless bad.empty?
end
def check_for_stray_dylibs
# Dylibs which are generally OK should be added to this list, # Dylibs which are generally OK should be added to this list,
# with a short description of the software they come with. # with a short description of the software they come with.
white_list = { white_list = {
@ -107,22 +111,16 @@ def check_for_stray_dylibs
"libfuse_ino64.2.dylib" => "MacFuse" "libfuse_ino64.2.dylib" => "MacFuse"
} }
bad_dylibs = unbrewed_dylibs.reject {|d| white_list.key? File.basename(d) } __check_stray_files '/usr/local/lib/*.dylib', white_list, <<-EOS.undent
return if bad_dylibs.empty?
s = <<-EOS.undent
Unbrewed dylibs were found in /usr/local/lib. Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted. building Homebrew formulae, and may need to be deleted.
Unexpected dylibs: Unexpected dylibs:
EOS EOS
inject_file_list(bad_dylibs, s)
end end
def check_for_stray_static_libs def check_for_stray_static_libs
unbrewed_alibs = Dir['/usr/local/lib/*.a'].select { |f| File.file? f and not File.symlink? f }
# Static libs which are generally OK should be added to this list, # Static libs which are generally OK should be added to this list,
# with a short description of the software they come with. # with a short description of the software they come with.
white_list = { white_list = {
@ -130,58 +128,42 @@ def check_for_stray_static_libs
"libsecurity_agent_server.a" => "OS X 10.8.2 Supplemental Update" "libsecurity_agent_server.a" => "OS X 10.8.2 Supplemental Update"
} }
bad_alibs = unbrewed_alibs.reject {|d| white_list.key? File.basename(d) } __check_stray_files '/usr/local/lib/*.a', white_list, <<-EOS.undent
return if bad_alibs.empty?
s = <<-EOS.undent
Unbrewed static libraries were found in /usr/local/lib. Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted. building Homebrew formulae, and may need to be deleted.
Unexpected static libraries: Unexpected static libraries:
EOS EOS
inject_file_list(bad_alibs, s)
end end
def check_for_stray_pcs def check_for_stray_pcs
unbrewed_pcs = Dir['/usr/local/lib/pkgconfig/*.pc'].select { |f| File.file? f and not File.symlink? f }
# Package-config files which are generally OK should be added to this list, # Package-config files which are generally OK should be added to this list,
# with a short description of the software they come with. # with a short description of the software they come with.
white_list = { } white_list = {}
bad_pcs = unbrewed_pcs.reject {|d| white_list.key? File.basename(d) } __check_stray_files '/usr/local/lib/pkgconfig/*.pc', white_list, <<-EOS.undent
return if bad_pcs.empty?
s = <<-EOS.undent
Unbrewed .pc files were found in /usr/local/lib/pkgconfig. Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted. building Homebrew formulae, and may need to be deleted.
Unexpected .pc files: Unexpected .pc files:
EOS EOS
inject_file_list(bad_pcs, s)
end end
def check_for_stray_las def check_for_stray_las
unbrewed_las = Dir['/usr/local/lib/*.la'].select { |f| File.file? f and not File.symlink? f }
white_list = { white_list = {
"libfuse.la" => "MacFuse", "libfuse.la" => "MacFuse",
"libfuse_ino64.la" => "MacFuse", "libfuse_ino64.la" => "MacFuse",
} }
bad_las = unbrewed_las.reject {|d| white_list.key? File.basename(d) } __check_stray_files '/usr/local/lib/*.la', white_list, <<-EOS.undent
return if bad_las.empty?
s = <<-EOS.undent
Unbrewed .la files were found in /usr/local/lib. Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted. building Homebrew formulae, and may need to be deleted.
Unexpected .la files: Unexpected .la files:
EOS EOS
inject_file_list(bad_las, s)
end end
def check_for_other_package_managers def check_for_other_package_managers