From 5e982a68a852554d5fb3d2e8e7a99dfd826a3704 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Wed, 29 Feb 2012 20:36:21 -0800 Subject: [PATCH] Use new Requirements in formulae --- Formula/asymptote.rb | 28 ++++++++++++++++---------- Formula/auctex.rb | 26 +++++++++++++++--------- Formula/dbslayer.rb | 45 +++++++++++++++++++++++------------------- Formula/git-hg.rb | 24 ++++++++++++++++------ Formula/jstalk.rb | 26 +++++++++++++----------- Formula/lilypond.rb | 26 +++++++++++++++--------- Formula/mydumper.rb | 33 ++++++++++++++++++++++--------- Formula/mysql-proxy.rb | 33 ++++++++++++++++++++++--------- Formula/pg_top.rb | 34 ++++++++++++++++++++----------- Formula/pgtap.rb | 33 +++++++++++++++++++------------ Formula/skytools.rb | 33 ++++++++++++++++++++----------- 11 files changed, 221 insertions(+), 120 deletions(-) diff --git a/Formula/asymptote.rb b/Formula/asymptote.rb index 19b536be785..a873b416cb9 100644 --- a/Formula/asymptote.rb +++ b/Formula/asymptote.rb @@ -1,24 +1,32 @@ require 'formula' +class TexInstalled < Requirement + def message; <<-EOS.undent + A TeX/LaTeX installation is required to install. + You can obtain the TeX distribution for Mac OS X from: + http://www.tug.org/mactex/ + EOS + end + def satisfied? + which 'latex' + end + def fatal? + true + end +end + class Asymptote < Formula homepage 'http://asymptote.sourceforge.net/' url 'http://downloads.sourceforge.net/asymptote/asymptote-2.15.src.tgz' md5 '1adb969a4d7b17a3ae98728d1956bd77' + depends_on TexInstalled.new + depends_on 'readline' depends_on 'bdw-gc' def install - unless which 'latex' - onoe <<-EOS.undent - Asymptote requires a TeX/LaTeX installation; aborting now. - You can obtain the TeX distribution for Mac OS X from - http://www.tug.org/mactex/ - EOS - exit 1 - end - - texmfhome = share + 'texmf' + texmfhome = share+'texmf' # see: https://sourceforge.net/tracker/?func=detail&aid=3486838&group_id=120000&atid=685683 inreplace 'configure', '--no-var-tracking', '' if ENV.compiler == :clang diff --git a/Formula/auctex.rb b/Formula/auctex.rb index d36b3df3c35..2a199c2646d 100644 --- a/Formula/auctex.rb +++ b/Formula/auctex.rb @@ -1,11 +1,28 @@ require 'formula' +class TexInstalled < Requirement + def message; <<-EOS.undent + A TeX/LaTeX installation is required to install. + You can obtain the TeX distribution for Mac OS X from: + http://www.tug.org/mactex/ + EOS + end + def satisfied? + which 'latex' + end + def fatal? + true + end +end + class Auctex < Formula homepage 'http://ftp.gnu.org/pub/gnu/auctex' url 'http://ftpmirror.gnu.org/auctex/auctex-11.86.tar.gz' mirror 'http://ftp.gnu.org/gnu/auctex/auctex-11.86.tar.gz' md5 '6bc33a67b6ac59db1aa238f3693b36d2' + depends_on TexInstalled.new + def options [['--with-emacs=', "Force a different emacs"]] end @@ -21,15 +38,6 @@ class Auctex < Formula end def install - unless which 'latex' - onoe <<-EOS.undent - AUCTeX requires a TeX/LaTeX installation; aborting now. - You can obtain the TeX distribution for Mac OS X from - http://www.tug.org/mactex/ - EOS - exit 1 - end - # configure fails if the texmf dir is not there yet brew_texmf = share + 'texmf' brew_texmf.mkpath diff --git a/Formula/dbslayer.rb b/Formula/dbslayer.rb index 2b2e32cb426..dec1e3e93bf 100644 --- a/Formula/dbslayer.rb +++ b/Formula/dbslayer.rb @@ -1,34 +1,39 @@ require 'formula' +class MySqlInstalled < Requirement + def message; <<-EOS.undent + MySQL is required to install. + + You can install this with Homebrew using: + brew install mysql-connector-c + For MySQL client libraries only. + + brew install mysql + For MySQL server. + + Or you can use an official installer from: + http://dev.mysql.com/downloads/mysql/ + EOS + end + def satisfied? + which 'mysql_config' + end + def fatal? + true + end +end + class Dbslayer < Formula homepage 'http://code.nytimes.com/projects/dbslayer/wiki' url 'http://code.nytimes.com/downloads/dbslayer-beta-12.tgz' version '0.12.b' md5 'a529ea503c244d723166f78c75df3bb3' - def install - unless which 'mysql_config' - opoo "No MySQL client library detected" - puts "This formula may fail to build, see caveats for more information." - end + depends_on MySqlInstalled.new + def install system "./configure", "--prefix=#{prefix}" system "make" system "make install" end - - def caveats; <<-EOS.undent - DBSlayer depends on a MySQL client library. - - You can install this with Homebrew using: - brew install mysql - For MySQL server. - - brew install mysql-connector-c - For MySQL client libraries only. - - We don't install these for you when you install this formula, as - we don't know which datasource you intend to use. - EOS - end end diff --git a/Formula/git-hg.rb b/Formula/git-hg.rb index 153062fee81..fac0be430c4 100644 --- a/Formula/git-hg.rb +++ b/Formula/git-hg.rb @@ -1,16 +1,28 @@ require 'formula' +class HgInstalled < Requirement + def message; <<-EOS.undent + Mercurial is required to use this software. + + You can install this with Homebrew using: + brew install mercurial + + Or you can use an official installer from: + http://mercurial.selenic.com/ + EOS + end + def satisfied? + which 'hg' + end +end + class GitHg < Formula head 'https://github.com/offbytwo/git-hg.git' homepage 'http://offbytwo.com/git-hg/' - def install - unless which 'hg' - puts "You may need to install Mercurial before using this software:" - puts " brew install mercurial" - end + depends_on HgInstalled.new + def install prefix.install Dir['*'] end end - diff --git a/Formula/jstalk.rb b/Formula/jstalk.rb index d13cd391951..65af1eeeae7 100644 --- a/Formula/jstalk.rb +++ b/Formula/jstalk.rb @@ -1,21 +1,25 @@ require 'formula' +class NeedsSnowLeopard < Requirement + def satisfied? + MacOS.snow_leopard? + end + + def message + "jstalk requires Mac OS X 10.6 or newer" + end +end + class Jstalk < Formula - url 'https://github.com/ccgus/jstalk.git', :tag => "v1.0.1" homepage 'http://jstalk.org/' + url 'https://github.com/ccgus/jstalk.git', :tag => "v1.0.1" version '1.0.1' + depends_on NeedsSnowLeopard.new + def install - if MacOS.leopard? - onoe "jstalk requires Mac OS X 10.6+" - exit 1 - end - - args = ["-configuration", "Release", "ONLY_ACTIVE_ARCH=YES"] - targets = ["JSTalk Framework", "jstalk command line", "JSTalk Editor"] - - targets.each do |target| - system "xcodebuild", "-target", target, *args + ["JSTalk Framework", "jstalk command line", "JSTalk Editor"].each do |t| + system "xcodebuild", "-target", t, "-configuration", "Release", "ONLY_ACTIVE_ARCH=YES" end cd 'build/Release' do diff --git a/Formula/lilypond.rb b/Formula/lilypond.rb index bbc78b119f4..22f466c8187 100644 --- a/Formula/lilypond.rb +++ b/Formula/lilypond.rb @@ -1,10 +1,26 @@ require 'formula' +class TexInstalled < Requirement + def message; <<-EOS.undent + A TeX/LaTeX installation is required to install. + You can obtain the TeX distribution for Mac OS X from: + http://www.tug.org/mactex/ + EOS + end + def satisfied? + which 'mpost' + end + def fatal? + true + end +end + class Lilypond < Formula - url 'http://download.linuxaudio.org/lilypond/sources/v2.14/lilypond-2.14.2.tar.gz' homepage 'http://lilypond.org/' + url 'http://download.linuxaudio.org/lilypond/sources/v2.14/lilypond-2.14.2.tar.gz' md5 '4053a19e03181021893981280feb9aaa' + depends_on TexInstalled.new depends_on 'pkg-config' => :build depends_on 'gettext' depends_on 'pango' @@ -17,8 +33,6 @@ class Lilypond < Formula skip_clean :all def install - abort caveats unless which "mpost" - gs = Formula.factory('ghostscript') system "./configure", "--prefix=#{prefix}", "--with-ncsb-dir=#{gs.share}/ghostscript/fonts/" @@ -27,10 +41,4 @@ class Lilypond < Formula system "make" system "make install" end - - def caveats; <<-EOS.undent - Lilypond requires a version of TeX, such as TeX Live or MacTeX, prior to installing. - Available at: http://www.tug.org/mactex/ - EOS - end end diff --git a/Formula/mydumper.rb b/Formula/mydumper.rb index 5e897c05144..0e3d9f7af61 100644 --- a/Formula/mydumper.rb +++ b/Formula/mydumper.rb @@ -1,25 +1,40 @@ require 'formula' +class MySqlInstalled < Requirement + def message; <<-EOS.undent + MySQL is required to install. + + You can install this with Homebrew using: + brew install mysql-connector-c + For MySQL client libraries only. + + brew install mysql + For MySQL server. + + Or you can use an official installer from: + http://dev.mysql.com/downloads/mysql/ + EOS + end + def satisfied? + which 'mysql_config' + end + def fatal? + true + end +end + class Mydumper < Formula homepage 'http://www.mydumper.org/' url 'http://launchpadlibrarian.net/77098505/mydumper-0.5.1.tar.gz' md5 'b4df42dfe23f308ab13eb6ecb73a0d21' + depends_on MySqlInstalled.new depends_on 'pkg-config' => :build depends_on 'cmake' => :build depends_on 'glib' depends_on 'pcre' def install - unless which 'mysql_config' - opoo "`mysql_config` was not found" - puts "This software requires the MySQL client libraries." - puts "You can install them via Homebrew with one of these:" - puts " brew install mysql-connector-c" - puts " brew install mysql [--client-only]" - puts "Without the client libraries, this formula will fail to compile." - end - system "cmake #{std_cmake_parameters} ." system "make install" end diff --git a/Formula/mysql-proxy.rb b/Formula/mysql-proxy.rb index eadffe616a5..29b6720a482 100644 --- a/Formula/mysql-proxy.rb +++ b/Formula/mysql-proxy.rb @@ -1,25 +1,40 @@ require 'formula' +class MySqlInstalled < Requirement + def message; <<-EOS.undent + MySQL is required to install. + + You can install this with Homebrew using: + brew install mysql-connector-c + For MySQL client libraries only. + + brew install mysql + For MySQL server. + + Or you can use an official installer from: + http://dev.mysql.com/downloads/mysql/ + EOS + end + def satisfied? + which 'mysql_config' + end + def fatal? + true + end +end + class MysqlProxy < Formula url 'http://launchpad.net/mysql-proxy/0.8/0.8.0/+download/mysql-proxy-0.8.0.tar.gz' homepage 'https://launchpad.net/mysql-proxy' md5 'b6a9748d72e8db7fe3789fbdd60ff451' + depends_on MySqlInstalled.new depends_on 'pkg-config' => :build depends_on 'glib' depends_on 'libevent' depends_on 'lua' def install - unless which 'mysql_config' - opoo "`mysql_config` was not found" - puts "This software requires the MySQL client libraries." - puts "You can install them via Homebrew with one of these:" - puts " brew install mysql-connector-c" - puts " brew install mysql [--client-only]" - puts "Without the client libraries, this formula will fail to compile." - end - system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}", # Ugh, don't dump these directly into /usr/local/include. diff --git a/Formula/pg_top.rb b/Formula/pg_top.rb index 4d88b1ed453..f5cdbd5aab1 100644 --- a/Formula/pg_top.rb +++ b/Formula/pg_top.rb @@ -1,23 +1,33 @@ require 'formula' +class PostgresqlInstalled < Requirement + def message; <<-EOS.undent + PostgresQL is required to install. + + You can install this with: + brew install postgresql + + Or you can use an official installer from: + http://www.postgresql.org/ + EOS + end + def satisfied? + which 'pg_config' + end + def fatal? + true + end +end + + class PgTop < Formula homepage 'http://ptop.projects.postgresql.org/' url 'http://pgfoundry.org/frs/download.php/1781/pg_top-3.6.2.tar.gz' md5 '12ddb50cf83e3027d182a1381d388f1d' + depends_on PostgresqlInstalled.new + def install - unless which 'pg_config' - opoo "No pg_config was detected." - puts <<-EOS.undent - pg_top requires postgresql in order to compile, but pg_config was not - found. This install will likely fail. - - You can install this with: - brew install postgresql - or by using a package installer from the PostgreSQL project itself. - EOS - end - system "./configure", "--disable-debug", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make install" diff --git a/Formula/pgtap.rb b/Formula/pgtap.rb index 16415304a16..fc51492538e 100644 --- a/Formula/pgtap.rb +++ b/Formula/pgtap.rb @@ -1,25 +1,32 @@ require 'formula' +class PostgresqlInstalled < Requirement + def message; <<-EOS.undent + PostgresQL is required to install. + + You can install this with: + brew install postgresql + + Or you can use an official installer from: + http://www.postgresql.org/ + EOS + end + def satisfied? + which 'pg_config' + end + def fatal? + true + end +end + class Pgtap < Formula url 'http://pgfoundry.org/frs/download.php/2701/pgtap-0.24.tar.bz2' homepage 'http://pgtap.org' md5 '9d0360c87fca0ddf3ca9da49b9b71947' - skip_clean :all + depends_on PostgresqlInstalled.new def install - unless which 'pg_config' - opoo "No pg_config was detected." - puts <<-EOS.undent - pg_top requires postgresql in order to compile, but pg_config was not - found. This install will likely fail. - - You can install this with: - brew install postgresql - or by using a package installer from the PostgreSQL project itself. - EOS - end - system "make install" bin.install %w(bbin/pg_prove bbin/pg_tapgen) end diff --git a/Formula/skytools.rb b/Formula/skytools.rb index 34572dec5ce..e8ab6f41f11 100644 --- a/Formula/skytools.rb +++ b/Formula/skytools.rb @@ -1,23 +1,32 @@ require 'formula' +class PostgresqlInstalled < Requirement + def message; <<-EOS.undent + PostgresQL is required to install. + + You can install this with: + brew install postgresql + + Or you can use an official installer from: + http://www.postgresql.org/ + EOS + end + def satisfied? + which 'pg_config' + end + def fatal? + true + end +end + class Skytools < Formula homepage 'http://pgfoundry.org/projects/skytools/' url 'http://pgfoundry.org/frs/download.php/2872/skytools-2.1.12.tar.gz' md5 '94f3391d5b3c3ac6c2edcbfbda705573' + depends_on PostgresqlInstalled.new + def install - unless which 'pg_config' - opoo "No pg_config was detected." - puts <<-EOS.undent - pg_top requires postgresql in order to compile, but pg_config was not - found. This install will likely fail. - - You can install this with: - brew install postgresql - or by using a package installer from the PostgreSQL project itself. - EOS - end - system "./configure", "--prefix=#{prefix}" system "make" system "make install"