aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-09-24 14:00:39 -0500
committerJack Nagel2014-09-24 14:00:39 -0500
commit71b0c773ec47f3f95076a018e431b0233fdf4251 (patch)
tree1df5858b16ec2cb397e8ebf8a2ab7d052738aff3 /Library
parente5c42895a86bb32b68a46ef00ee486d1608e00f5 (diff)
downloadbrew-71b0c773ec47f3f95076a018e431b0233fdf4251.tar.bz2
Match whitelisted files using fnmatch
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/doctor.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index 252e755ff..e2235cdcd 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -103,9 +103,18 @@ def check_for_macgpg2
end
end
-def __check_stray_files(pattern, white_list, message)
- files = Dir[pattern].select { |f| File.file? f and not File.symlink? f }
- bad = files.reject {|d| white_list.key? File.basename(d) }
+def __check_stray_files(dir, pattern, white_list, message)
+ files = Dir.chdir(dir) {
+ Dir[pattern].select { |f| File.file?(f) && !File.symlink?(f) }
+ }
+
+ keys = white_list.keys
+ bad = files.reject { |file|
+ keys.any? { |pat| File.fnmatch?(pat, file) }
+ }
+
+ bad.map! { |file| File.join(dir, file) }
+
inject_file_list(bad, message) unless bad.empty?
end
@@ -119,7 +128,7 @@ def check_for_stray_dylibs
"libosxfuse_i64.2.dylib" => "OSXFuse",
}
- __check_stray_files '/usr/local/lib/*.dylib', white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/lib", "*.dylib", white_list, <<-EOS.undent
Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
@@ -136,7 +145,7 @@ def check_for_stray_static_libs
"libsecurity_agent_server.a" => "OS X 10.8.2 Supplemental Update"
}
- __check_stray_files '/usr/local/lib/*.a', white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/lib", "*.a", white_list, <<-EOS.undent
Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
@@ -152,7 +161,7 @@ def check_for_stray_pcs
"osxfuse.pc" => "OSXFuse",
}
- __check_stray_files '/usr/local/lib/pkgconfig/*.pc', white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/lib/pkgconfig", "*.pc", white_list, <<-EOS.undent
Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
@@ -169,7 +178,7 @@ def check_for_stray_las
"libosxfuse_i64.la" => "OSXFuse",
}
- __check_stray_files '/usr/local/lib/*.la', white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/lib", "*.la", white_list, <<-EOS.undent
Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
@@ -181,7 +190,7 @@ end
def check_for_stray_headers
white_list = {} # TODO whitelist MacFuse/OSXFuse headers
- __check_stray_files "/usr/local/include/**/*.h", white_list, <<-EOS.undent
+ __check_stray_files "/usr/local/include", "**/*.h", white_list, <<-EOS.undent
Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.