aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/os
diff options
context:
space:
mode:
authorMike McQuaid2016-07-09 13:51:53 +0100
committerGitHub2016-07-09 13:51:53 +0100
commitdf7e36b86cf4fab3cf24a6d0888121d94ca73b8a (patch)
treef904b0bacf72930f9bf7c3d06c70c46669a76100 /Library/Homebrew/extend/os
parenta5ec0aa2598d702b68300e7400fad48e8a392527 (diff)
downloadbrew-df7e36b86cf4fab3cf24a6d0888121d94ca73b8a.tar.bz2
formula_cellar_checks: port to generic OS. (#452)
Diffstat (limited to 'Library/Homebrew/extend/os')
-rw-r--r--Library/Homebrew/extend/os/formula_cellar_checks.rb5
-rw-r--r--Library/Homebrew/extend/os/mac/formula_cellar_checks.rb65
2 files changed, 70 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/os/formula_cellar_checks.rb b/Library/Homebrew/extend/os/formula_cellar_checks.rb
new file mode 100644
index 000000000..4e30cd791
--- /dev/null
+++ b/Library/Homebrew/extend/os/formula_cellar_checks.rb
@@ -0,0 +1,5 @@
+require "formula_cellar_checks"
+
+if OS.mac?
+ require "extend/os/mac/formula_cellar_checks"
+end
diff --git a/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb
new file mode 100644
index 000000000..b460aca86
--- /dev/null
+++ b/Library/Homebrew/extend/os/mac/formula_cellar_checks.rb
@@ -0,0 +1,65 @@
+module FormulaCellarChecks
+ def check_shadowed_headers
+ return if ["libtool", "subversion", "berkeley-db"].any? do |formula_name|
+ formula.name.start_with?(formula_name)
+ end
+
+ return if MacOS.version < :mavericks && formula.name.start_with?("postgresql")
+ return if MacOS.version < :yosemite && formula.name.start_with?("memcached")
+
+ return if formula.keg_only? || !formula.include.directory?
+
+ files = relative_glob(formula.include, "**/*.h")
+ files &= relative_glob("#{MacOS.sdk_path}/usr/include", "**/*.h")
+ files.map! { |p| File.join(formula.include, p) }
+
+ return if files.empty?
+
+ <<-EOS.undent
+ Header files that shadow system header files were installed to "#{formula.include}"
+ The offending files are:
+ #{files * "\n "}
+ EOS
+ end
+
+ def check_openssl_links
+ return unless formula.prefix.directory?
+ keg = Keg.new(formula.prefix)
+ system_openssl = keg.mach_o_files.select do |obj|
+ dlls = obj.dynamically_linked_libraries
+ dlls.any? { |dll| %r{/usr/lib/lib(crypto|ssl).(\d\.)*dylib}.match dll }
+ end
+ return if system_openssl.empty?
+
+ <<-EOS.undent
+ object files were linked against system openssl
+ These object files were linked against the deprecated system OpenSSL.
+ Adding `depends_on "openssl"` to the formula may help.
+ #{system_openssl * "\n "}
+ EOS
+ end
+
+ def check_python_framework_links(lib)
+ python_modules = Pathname.glob lib/"python*/site-packages/**/*.so"
+ framework_links = python_modules.select do |obj|
+ dlls = obj.dynamically_linked_libraries
+ dlls.any? { |dll| /Python\.framework/.match dll }
+ end
+ return if framework_links.empty?
+
+ <<-EOS.undent
+ python modules have explicit framework links
+ These python extension modules were linked directly to a Python
+ framework binary. They should be linked with -undefined dynamic_lookup
+ instead of -lpython or -framework Python.
+ #{framework_links * "\n "}
+ EOS
+ end
+
+ def audit_installed
+ generic_audit_installed
+ audit_check_output(check_shadowed_headers)
+ audit_check_output(check_openssl_links)
+ audit_check_output(check_python_framework_links(formula.lib))
+ end
+end