From 60003eecc3d991437abc1d5aff2e867abf888f01 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 19 Jan 2013 20:45:59 -0600 Subject: [PATCH] Use new requirement syntax --- Formula/appledoc.rb | 5 ++--- Formula/avian.rb | 6 ++---- Formula/boost.rb | 5 ++--- Formula/boost149.rb | 5 ++--- Formula/cmake.rb | 7 ++++--- Formula/cmu-sphinxbase.rb | 5 ++--- Formula/coq.rb | 12 ++++++------ Formula/cvs2svn.rb | 6 ++---- Formula/diffpdf.rb | 5 ++--- Formula/drizzle.rb | 4 +--- Formula/dsniff.rb | 6 ++---- Formula/elixir.rb | 6 ++---- Formula/ghc.rb | 4 +--- Formula/git-hg.rb | 5 ++--- Formula/google-js-test.rb | 6 ++---- Formula/hyperestraier.rb | 4 +--- Formula/jstalk.rb | 4 +--- Formula/mlton.rb | 5 ++--- Formula/mongodb.rb | 4 +--- Formula/mu.rb | 2 +- Formula/mupdf.rb | 4 +--- Formula/mysql-connector-odbc.rb | 5 ++--- Formula/node.rb | 15 +++++++-------- Formula/nu.rb | 5 ++--- Formula/pdf2svg.rb | 5 ++--- Formula/phantomjs.rb | 4 +--- Formula/postgres-xc.rb | 5 ++--- Formula/rhash.rb | 5 ++--- Formula/shocco.rb | 6 ++---- Formula/signing-party.rb | 7 +++---- Formula/squid.rb | 7 ++----- Formula/uwsgi.rb | 10 +++++----- Formula/wxmac.rb | 11 ++++++----- 33 files changed, 77 insertions(+), 118 deletions(-) diff --git a/Formula/appledoc.rb b/Formula/appledoc.rb index eecde22e06768..e253e71fddf79 100644 --- a/Formula/appledoc.rb +++ b/Formula/appledoc.rb @@ -3,9 +3,8 @@ class LionOrNewer < Requirement fatal true - def satisfied? - MacOS.version >= :lion - end + satisfy MacOS.version >= :lion + def message "Appledoc requires Mac OS X 10.7 (Lion) or newer." end diff --git a/Formula/avian.rb b/Formula/avian.rb index 7d37eacd125f1..ce59cf84dd005 100644 --- a/Formula/avian.rb +++ b/Formula/avian.rb @@ -3,6 +3,8 @@ class JdkInstalled < Requirement fatal true + satisfy { which 'javac' } + def message; <<-EOS.undent A JDK is required. @@ -10,10 +12,6 @@ def message; <<-EOS.undent http://www.oracle.com/technetwork/java/javase/downloads/index.html EOS end - - def satisfied? - which 'javac' - end end class Avian < Formula diff --git a/Formula/boost.rb b/Formula/boost.rb index ab62ec38833ca..577d0be8aea47 100644 --- a/Formula/boost.rb +++ b/Formula/boost.rb @@ -9,6 +9,8 @@ def boost_layout end class UniversalPython < Requirement + satisfy { archs_for_command("python").universal? } + def message; <<-EOS.undent A universal build was requested, but Python is not a universal build @@ -16,9 +18,6 @@ def message; <<-EOS.undent is not a universal build then linking will likely fail. EOS end - def satisfied? - archs_for_command("python").universal? - end end class Boost < Formula diff --git a/Formula/boost149.rb b/Formula/boost149.rb index cd181b1f86a74..0901211bc77a4 100644 --- a/Formula/boost149.rb +++ b/Formula/boost149.rb @@ -1,6 +1,8 @@ require 'formula' class UniversalPython < Requirement + satisfy { archs_for_command("python").universal? } + def message; <<-EOS.undent A universal build was requested, but Python is not a universal build @@ -8,9 +10,6 @@ def message; <<-EOS.undent is not a universal build then linking will likely fail. EOS end - def satisfied? - archs_for_command("python").universal? - end end class Boost149 < Formula diff --git a/Formula/cmake.rb b/Formula/cmake.rb index db19d0b72cb8f..3688f8e234ee6 100644 --- a/Formula/cmake.rb +++ b/Formula/cmake.rb @@ -1,6 +1,10 @@ require 'formula' class NoExpatFramework < Requirement + satisfy :build_env => false do + not File.exist? "/Library/Frameworks/expat.framework" + end + def message; <<-EOS.undent Detected /Library/Frameworks/expat.framework @@ -10,9 +14,6 @@ def message; <<-EOS.undent You may need to move this file out of the way to compile CMake. EOS end - def satisfied? - not File.exist? "/Library/Frameworks/expat.framework" - end end diff --git a/Formula/cmu-sphinxbase.rb b/Formula/cmu-sphinxbase.rb index 2258fb64664df..1615864039f91 100644 --- a/Formula/cmu-sphinxbase.rb +++ b/Formula/cmu-sphinxbase.rb @@ -3,6 +3,8 @@ class HomebrewedPython < Requirement fatal true + satisfy(:build_env => false) { Formula.factory('python').installed? } + def message; <<-EOS.undent Compiling against the system-provided Python will likely fail. The system-provided Python includes PPC support, which will cause a compiler @@ -11,9 +13,6 @@ def message; <<-EOS.undent Patches to correct this issue are welcome. EOS end - def satisfied? - Formula.factory('python').installed? - end end class CmuSphinxbase < Formula diff --git a/Formula/coq.rb b/Formula/coq.rb index 1a163844b81af..ce67e6c4363a2 100644 --- a/Formula/coq.rb +++ b/Formula/coq.rb @@ -3,17 +3,17 @@ class TransitionalMode < Requirement fatal true + satisfy do + # If not installed, it will install in the correct mode. + # If installed, make sure it is transitional instead of strict. + !which('camlp5') || `camlp5 -pmode 2>&1`.chomp == 'transitional' + end + def message; <<-EOS.undent camlp5 must be compiled in transitional mode (instead of --strict mode): brew install camlp5 EOS end - def satisfied? - # If not installed, it will install in the correct mode. - return true if not which('camlp5') - # If installed, make sure it is transitional instead of strict. - `camlp5 -pmode 2>&1`.chomp == 'transitional' - end end class Coq < Formula diff --git a/Formula/cvs2svn.rb b/Formula/cvs2svn.rb index e6bf2394369e7..7a53b5d81a0e1 100644 --- a/Formula/cvs2svn.rb +++ b/Formula/cvs2svn.rb @@ -3,6 +3,8 @@ class PythonWithGdbm < Requirement fatal true + satisfy { quiet_system "python", "-c", "import gdbm" } + def message; <<-EOS.undent The Python being used does not include gdbm support, but it is required to build this formula: @@ -12,10 +14,6 @@ def message; <<-EOS.undent Homebrew's Python includes gdbm support. EOS end - - def satisfied? - quiet_system "python", "-c", "import gdbm" - end end class Cvs2svn < Formula diff --git a/Formula/diffpdf.rb b/Formula/diffpdf.rb index 15775363fcb5b..1d0c4fddcc3a0 100644 --- a/Formula/diffpdf.rb +++ b/Formula/diffpdf.rb @@ -3,9 +3,8 @@ class PopplerQt4 < Requirement fatal true - def satisfied? - poppler = Tab.for_formula 'poppler' - poppler.installed_with? '--with-qt4' + satisfy :build_env => false do + Tab.for_formula("poppler").installed_with? "--with-qt4" end def message; <<-EOS.undent diff --git a/Formula/drizzle.rb b/Formula/drizzle.rb index 828f9ac35d272..b156a76b7009f 100644 --- a/Formula/drizzle.rb +++ b/Formula/drizzle.rb @@ -1,9 +1,7 @@ require 'formula' class LionOrNewer < Requirement - def satisfied? - MacOS.version >= :lion - end + satisfy MacOS.version >= :lion def message "Drizzle requires Mac OS X 10.7 (Lion) or newer." diff --git a/Formula/dsniff.rb b/Formula/dsniff.rb index 8eda8cc455b08..add05311cdb28 100644 --- a/Formula/dsniff.rb +++ b/Formula/dsniff.rb @@ -1,6 +1,8 @@ require 'formula' class NoBdb5 < Requirement + satisfy(:build_env => false) { !Formula.factory("berkeley-db").installed? } + def message; <<-EOS.undent This software can fail to compile when Berkeley-DB 5.x is installed. You may need to try: @@ -9,10 +11,6 @@ def message; <<-EOS.undent brew link berkeley-db EOS end - def satisfied? - f = Formula.factory("berkeley-db") - not f.installed? - end end class Dsniff < Formula diff --git a/Formula/elixir.rb b/Formula/elixir.rb index 96c196cbd6ffa..8132c56f522dc 100644 --- a/Formula/elixir.rb +++ b/Formula/elixir.rb @@ -3,6 +3,8 @@ class ErlangInstalled < Requirement fatal true + satisfy { which 'erl' } + def message; <<-EOS.undent Erlang is required to install. @@ -13,10 +15,6 @@ def message; <<-EOS.undent http://www.erlang.org/ EOS end - - def satisfied? - which 'erl' - end end class Elixir < Formula diff --git a/Formula/ghc.rb b/Formula/ghc.rb index 6b49abf2a403d..57edee02d8923 100644 --- a/Formula/ghc.rb +++ b/Formula/ghc.rb @@ -1,9 +1,7 @@ require 'formula' class NeedsSnowLeopard < Requirement - def satisfied? - MacOS.version >= :snow_leopard - end + satisfy MacOS.version >= :snow_leopard def message; <<-EOS.undent GHC requires OS X 10.6 or newer. The binary releases no longer work on diff --git a/Formula/git-hg.rb b/Formula/git-hg.rb index fac0be430c451..1c11e49e9335b 100644 --- a/Formula/git-hg.rb +++ b/Formula/git-hg.rb @@ -1,6 +1,8 @@ require 'formula' class HgInstalled < Requirement + satisfy { which 'hg' } + def message; <<-EOS.undent Mercurial is required to use this software. @@ -11,9 +13,6 @@ def message; <<-EOS.undent http://mercurial.selenic.com/ EOS end - def satisfied? - which 'hg' - end end class GitHg < Formula diff --git a/Formula/google-js-test.rb b/Formula/google-js-test.rb index b28bf43be35c5..3bce824dd2306 100644 --- a/Formula/google-js-test.rb +++ b/Formula/google-js-test.rb @@ -1,13 +1,11 @@ require 'formula' class NeedsSnowLeopard < Requirement + satisfy MacOS.version >= :snow_leopard + def message "Google JS Test requires Mac OS X 10.6 (Snow Leopard) or newer." end - - def satisfied? - MacOS.version >= :snow_leopard - end end class GoogleJsTest < Formula diff --git a/Formula/hyperestraier.rb b/Formula/hyperestraier.rb index 932ebc1003d1d..38d55f124a05f 100644 --- a/Formula/hyperestraier.rb +++ b/Formula/hyperestraier.rb @@ -7,9 +7,7 @@ def initialize @mecab_ipadic_installed = Formula.factory('mecab-ipadic').installed? end - def satisfied? - @mecab_ipadic_installed && mecab_dic_charset == 'euc' - end + satisfy { @mecab_ipadic_installed && mecab_dic_charset == 'euc' } def message if @mecab_ipadic_installed diff --git a/Formula/jstalk.rb b/Formula/jstalk.rb index ac31ad2406692..7b9fce72b5b1e 100644 --- a/Formula/jstalk.rb +++ b/Formula/jstalk.rb @@ -1,9 +1,7 @@ require 'formula' class NeedsSnowLeopard < Requirement - def satisfied? - MacOS.version >= :snow_leopard - end + satisfy MacOS.version >= :snow_leopard def message "jstalk requires Mac OS X 10.6 or newer" diff --git a/Formula/mlton.rb b/Formula/mlton.rb index 9fa2ef3e9b9f1..999cd35fd9285 100644 --- a/Formula/mlton.rb +++ b/Formula/mlton.rb @@ -5,6 +5,8 @@ # would require an existing ML compiler/interpreter for bootstrapping. class StandardHomebrewLocation < Requirement + satisfy HOMEBREW_PREFIX.to_s == "/usr/local" + def message; <<-EOS.undent mlton won't work outside of /usr/local @@ -13,9 +15,6 @@ def message; <<-EOS.undent will be unable to find GMP. EOS end - def satisfied? - HOMEBREW_PREFIX.to_s == "/usr/local" - end end class Mlton < Formula diff --git a/Formula/mongodb.rb b/Formula/mongodb.rb index 6f74fc18ab4c6..fed3430b9c658 100644 --- a/Formula/mongodb.rb +++ b/Formula/mongodb.rb @@ -3,9 +3,7 @@ class SixtyFourBitRequired < Requirement fatal true - def satisfied? - MacOS.prefer_64_bit? - end + satisfy MacOS.prefer_64_bit? def message; <<-EOS.undent 32-bit MongoDB binaries are no longer available. diff --git a/Formula/mu.rb b/Formula/mu.rb index 4c4dda530402c..9e2008e35b2c0 100644 --- a/Formula/mu.rb +++ b/Formula/mu.rb @@ -4,7 +4,7 @@ class Emacs23Installed < Requirement fatal true env :userpaths - def satisfied? + satisfy do `emacs --version 2>/dev/null` =~ /^GNU Emacs (\d{2})/ $1.to_i >= 23 end diff --git a/Formula/mupdf.rb b/Formula/mupdf.rb index 07c4fb64d44f1..9381f9e4f242f 100644 --- a/Formula/mupdf.rb +++ b/Formula/mupdf.rb @@ -3,9 +3,7 @@ class NeedsSnowLeopard < Requirement fatal true - def satisfied? - MacOS.version >= :snow_leopard - end + satisfy MacOS.version >= :snow_leopard def message; <<-EOS.undent The version of Freetype that comes with Leopard is too old to build MuPDF diff --git a/Formula/mysql-connector-odbc.rb b/Formula/mysql-connector-odbc.rb index 5bcf3bc88718a..385fa09dae45d 100644 --- a/Formula/mysql-connector-odbc.rb +++ b/Formula/mysql-connector-odbc.rb @@ -3,6 +3,8 @@ class MySqlInstalled < Requirement fatal true + satisfy { which 'mysql_config' } + def message; <<-EOS.undent MySQL is required to install. @@ -17,9 +19,6 @@ def message; <<-EOS.undent http://dev.mysql.com/downloads/mysql/ EOS end - def satisfied? - which 'mysql_config' - end end class MysqlConnectorOdbc < Formula diff --git a/Formula/node.rb b/Formula/node.rb index 55cfc9f9bff6d..0574281b2338a 100644 --- a/Formula/node.rb +++ b/Formula/node.rb @@ -1,16 +1,19 @@ require 'formula' class PythonVersion < Requirement + env :userpaths + + satisfy { `python -c 'import sys;print(sys.version[:3])'`.strip.to_f >= 2.6 } + def message; <<-EOS.undent Node's build system, gyp, requires Python 2.6 or newer. EOS end - def satisfied? - `python -c 'import sys;print(sys.version[:3])'`.strip.to_f >= 2.6 - end end class NpmNotInstalled < Requirement + fatal true + def modules_folder "#{HOMEBREW_PREFIX}/lib/node_modules" end @@ -28,7 +31,7 @@ def message; <<-EOS.undent EOS end - def satisfied? + satisfy :build_env => false do begin path = Pathname.new("#{modules_folder}/npm") not path.realpath.to_s.include?(HOMEBREW_CELLAR) @@ -36,10 +39,6 @@ def satisfied? true end end - - def fatal? - true - end end class Node < Formula diff --git a/Formula/nu.rb b/Formula/nu.rb index 0dcb9575b6ece..3ed0e2ac3d8c2 100644 --- a/Formula/nu.rb +++ b/Formula/nu.rb @@ -3,9 +3,8 @@ class NeedsLion < Requirement fatal true - def satisfied? - MacOS.version >= :lion - end + satisfy MacOS.version >= :lion + def message "Nu requires Mac OS X 10.7 or newer" end diff --git a/Formula/pdf2svg.rb b/Formula/pdf2svg.rb index a36575477581a..89c950c305104 100644 --- a/Formula/pdf2svg.rb +++ b/Formula/pdf2svg.rb @@ -3,9 +3,8 @@ class PopplerGlib < Requirement fatal true - def satisfied? - poppler = Tab.for_formula 'poppler' - poppler.installed_with? '--with-glib' + satisfy :build_env => false do + Tab.for_formula("poppler").installed_with? "--with-glib" end def message; <<-EOS.undent diff --git a/Formula/phantomjs.rb b/Formula/phantomjs.rb index af6de6eca15a0..e69d81c02e107 100644 --- a/Formula/phantomjs.rb +++ b/Formula/phantomjs.rb @@ -1,9 +1,7 @@ require 'formula' class SnowLeopardOrNewer < Requirement - def satisfied? - MacOS.version >= :snow_leopard - end + satisfy MacOS.version >= :snow_leopard def message "PhantomJS requires Mac OS X 10.6 (Snow Leopard) or newer." diff --git a/Formula/postgres-xc.rb b/Formula/postgres-xc.rb index c130ebea030e3..4179df26be868 100644 --- a/Formula/postgres-xc.rb +++ b/Formula/postgres-xc.rb @@ -3,14 +3,13 @@ class X86_64_Architecture < Requirement fatal true + satisfy MacOS.prefer_64_bit? + def message; <<-EOS.undent Your system appears to run on a 32-bit architecture. Postgres-XC only supports 64-bit architectures, sorry. EOS end - def satisfied? - MacOS.prefer_64_bit? - end end class PostgresXc < Formula diff --git a/Formula/rhash.rb b/Formula/rhash.rb index 2b497c13b10bf..9bea1082a6317 100644 --- a/Formula/rhash.rb +++ b/Formula/rhash.rb @@ -3,9 +3,8 @@ class LionOrNewer < Requirement fatal true - def satisfied? - MacOS.version >= :lion - end + satisfy(:build_env => false) { MacOS.version >= :lion } + def message "rhash requires `wcsdup` which isn't in the SDK before Lion." end diff --git a/Formula/shocco.rb b/Formula/shocco.rb index b13c443ffa579..81029c85aadfc 100644 --- a/Formula/shocco.rb +++ b/Formula/shocco.rb @@ -11,6 +11,8 @@ class Pygments < Formula class MarkdownProvider < Requirement fatal true + satisfy { which 'markdown' } + def message; <<-EOS.undent shocco requires a `markdown` command. @@ -21,10 +23,6 @@ def message; <<-EOS.undent Please install one and try again. EOS end - - def satisfied? - which 'markdown' - end end class Shocco < Formula diff --git a/Formula/signing-party.rb b/Formula/signing-party.rb index 4dfd321a58ae8..33c2010553eab 100644 --- a/Formula/signing-party.rb +++ b/Formula/signing-party.rb @@ -2,6 +2,9 @@ class GnupgInstalled < Requirement fatal true + env :userpaths + + satisfy { which('gpg') || which('gpg2') } def message; <<-EOS.undent Gnupg is required to use these tools. @@ -14,10 +17,6 @@ def message; <<-EOS.undent prepackaged installers that are available. EOS end - - def satisfied? - which 'gpg' or which 'gpg2' - end end class SigningParty < Formula diff --git a/Formula/squid.rb b/Formula/squid.rb index cf461aad1b433..0a1a1afe50610 100644 --- a/Formula/squid.rb +++ b/Formula/squid.rb @@ -4,6 +4,8 @@ class NoBdb5 < Requirement # Not fatal in case Squid starts working with a newer version of BDB. fatal false + satisfy(:build_env => false) { !Formula.factory("berkeley-db").installed? } + def message; <<-EOS.undent This software can fail to compile when Berkeley-DB 5.x is installed. You may need to try: @@ -12,11 +14,6 @@ def message; <<-EOS.undent brew link berkeley-db EOS end - - def satisfied? - f = Formula.factory("berkeley-db") - not f.installed? - end end class Squid < Formula diff --git a/Formula/uwsgi.rb b/Formula/uwsgi.rb index 255a2da2bd74c..652a8bca61b34 100644 --- a/Formula/uwsgi.rb +++ b/Formula/uwsgi.rb @@ -3,6 +3,11 @@ class UniversalPcre < Requirement fatal true + satisfy :build_env => false do + f = Formula.factory('pcre') + f.installed? && archs_for_command(f.lib/'libpcre.dylib').universal? + end + def message; <<-EOS.undent pcre must be build universal for uwsgi to work. You will need to: @@ -10,11 +15,6 @@ def message; <<-EOS.undent brew install --universal pcre EOS end - - def satisfied? - f = Formula.factory('pcre') - f.installed? && archs_for_command(f.lib/'libpcre.dylib').universal? - end end class Uwsgi < Formula diff --git a/Formula/wxmac.rb b/Formula/wxmac.rb index 09af04e832b55..78cb2c0750013 100644 --- a/Formula/wxmac.rb +++ b/Formula/wxmac.rb @@ -2,15 +2,16 @@ class FrameworkPython < Requirement fatal true + env :userpaths - def message; <<-EOS.undent - Python needs to be built as a framework. - EOS - end - def satisfied? + satisfy do q = `python -c "import distutils.sysconfig as c; print(c.get_config_var('PYTHONFRAMEWORK'))"` not q.chomp.empty? end + + def message + "Python needs to be built as a framework." + end end class Wxmac < Formula