From d366b28923ed31aafe914a3f27873b2b7605e903 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Mon, 7 Sep 2009 01:06:08 +0100 Subject: Dependency resolution Specify dependencies in your formula's deps function. You can return an Array, String or Hash, eg: def deps { :optional => 'libogg', :required => %w[flac sdl], :recommended => 'cmake' } end Note currently the Hash is flattened and qualifications are ignored. If you only return an Array or String, the qualification is assumed to be :required. Other packaging systems have problems when it comes to packages requiring a specific version of a package, or some patches that may not work well with other software. With Homebrew we have some options: 1. If the formula is vanilla but an older version we can cherry-pick the old version and install it in the Cellar in parallel, but just not symlink it into /usr/local while forcing the formula that depends on it to link to that one and not any other versions of it. 2. If the dependency requires patches then we shouldn't install this for use by any other tools, (I guess this needs to be decided on a per-situation basis). It can be installed into the parent formula's prefix, and not symlinked into /usr/local. In this case the dependency's Formula derivation should be saved in the parent formula's file (check git or flac for an example of this). Both the above can be done currently with hacks, so I'll flesh out a proper way sometime this week. --- Library/Formula/fish.rb | 2 +- Library/Formula/ghostscript.rb | 32 +++++++++++++++++++ Library/Formula/imagemagick.rb | 61 +----------------------------------- Library/Formula/liblastfm.rb | 4 +-- Library/Formula/libmusicbrainz.rb | 3 +- Library/Formula/libtiff.rb | 12 +++++++ Library/Formula/libvorbis.rb | 2 +- Library/Formula/libwmf.rb | 16 ++++++++++ Library/Formula/little-cms.rb | 12 +++++++ Library/Formula/memcached.rb | 2 +- Library/Formula/mysql-connector-c.rb | 2 +- Library/Formula/mysql.rb | 3 +- Library/Formula/nginx.rb | 2 +- Library/Formula/playdar.rb | 4 +-- Library/Formula/python.rb | 2 +- Library/Formula/scummvm.rb | 6 +--- Library/Formula/sshfs.rb | 4 +-- Library/Formula/taglib.rb | 4 +-- Library/Formula/unp.rb | 2 +- Library/Formula/vorbis-tools.rb | 4 +-- Library/Formula/yajl.rb | 4 +-- Library/Homebrew/brew.h.rb | 27 ++++++++++++++++ Library/Homebrew/formula.rb | 2 +- Library/Homebrew/unittest.rb | 23 +++++++++----- 24 files changed, 134 insertions(+), 101 deletions(-) create mode 100644 Library/Formula/ghostscript.rb create mode 100644 Library/Formula/libtiff.rb create mode 100644 Library/Formula/libwmf.rb create mode 100644 Library/Formula/little-cms.rb (limited to 'Library') diff --git a/Library/Formula/fish.rb b/Library/Formula/fish.rb index c84bb8111..09246747e 100644 --- a/Library/Formula/fish.rb +++ b/Library/Formula/fish.rb @@ -6,7 +6,7 @@ class Fish 'jpeg', :optional => %w[libwmf libtiff little-cms ghostscript] } end def install @@ -47,33 +17,6 @@ class Imagemagick 'neon', :optional => 'libdiscid' } end def install diff --git a/Library/Formula/libtiff.rb b/Library/Formula/libtiff.rb new file mode 100644 index 000000000..831491321 --- /dev/null +++ b/Library/Formula/libtiff.rb @@ -0,0 +1,12 @@ +require 'brewkit' + +class Libtiff 'sdl', :recommended => %w[flac libogg libvorbis] } end def install diff --git a/Library/Formula/sshfs.rb b/Library/Formula/sshfs.rb index 67d94fae4..0ae3f40d9 100644 --- a/Library/Formula/sshfs.rb +++ b/Library/Formula/sshfs.rb @@ -14,9 +14,7 @@ class Sshfs %w[ogg vorbis], :optional => %w[ao ogg123] } end def install diff --git a/Library/Formula/yajl.rb b/Library/Formula/yajl.rb index 288e2fd39..19f47f2ff 100644 --- a/Library/Formula/yajl.rb +++ b/Library/Formula/yajl.rb @@ -6,7 +6,7 @@ class Yajl 0 + ARGV.shift + end end end ARGV.extend ExtendArgvPlusYeast @@ -347,8 +352,9 @@ class BeerTasting :optional depends_on 'far' => :recommended depends_on Sew.new end Sew would be a formula you have defined in this Formula file. This is useful, eg. see Python's formula. Formula specified in this fashion cannot be linked into the HOMEBREW_PREFIX, they are considered private libraries. This allows you to create custom installations that are very specific to your formula. More features to come, like specifying versions --- Library/Formula/erlang.rb | 3 +++ Library/Formula/fish.rb | 4 +--- Library/Formula/glib.rb | 6 ++---- Library/Formula/imagemagick.rb | 19 ++++++++++--------- Library/Formula/liblastfm.rb | 6 +++--- Library/Formula/libmusicbrainz.rb | 5 ++--- Library/Formula/libvorbis.rb | 4 +--- Library/Formula/memcached.rb | 4 +--- Library/Formula/mysql-connector-c.rb | 4 +--- Library/Formula/mysql.rb | 4 +--- Library/Formula/nginx.rb | 4 +--- Library/Formula/playdar.rb | 6 +++--- Library/Formula/python.rb | 6 ++---- Library/Formula/scummvm.rb | 7 ++++--- Library/Formula/sshfs.rb | 6 +++--- Library/Formula/subversion.rb | 13 ++----------- Library/Formula/unp.rb | 4 +--- Library/Formula/vorbis-tools.rb | 7 ++++--- Library/Formula/yajl.rb | 4 +--- Library/Homebrew/brew.h.rb | 27 ++++----------------------- Library/Homebrew/formula.rb | 33 +++++++++++++++++++++++++++++---- 21 files changed, 79 insertions(+), 97 deletions(-) (limited to 'Library') diff --git a/Library/Formula/erlang.rb b/Library/Formula/erlang.rb index eaa002ba0..41feea372 100644 --- a/Library/Formula/erlang.rb +++ b/Library/Formula/erlang.rb @@ -13,6 +13,9 @@ class Erlang 'jpeg', :optional => %w[libwmf libtiff little-cms ghostscript] } - end + depends_on 'jpeg' + depends_on 'libwmf' => :optional + depends_on 'libtiff' => :optional + depends_on 'little-cms' => :optional + depends_on 'ghostscript' => :recommended def install ENV.libpng @@ -25,15 +27,14 @@ class Imagemagick 'neon', :optional => 'libdiscid' } - end + depends_on 'neon' + depends_on 'libdiscid' => :optional def install system "cmake . #{std_cmake_parameters}" diff --git a/Library/Formula/libvorbis.rb b/Library/Formula/libvorbis.rb index cdd795437..d4ca863e8 100644 --- a/Library/Formula/libvorbis.rb +++ b/Library/Formula/libvorbis.rb @@ -5,9 +5,7 @@ class Libvorbis 'sdl', :recommended => %w[flac libogg libvorbis] } - end + depends_on 'sdl' + depends_on 'flac' => :recommended + depends_on 'libvorbis' => :recommended + depends_on 'libogg' => :recommended def install system "./configure --prefix='#{prefix}' --disable-debug" diff --git a/Library/Formula/sshfs.rb b/Library/Formula/sshfs.rb index 0ae3f40d9..59c184663 100644 --- a/Library/Formula/sshfs.rb +++ b/Library/Formula/sshfs.rb @@ -13,9 +13,9 @@ class Sshfs %w[ogg vorbis], :optional => %w[ao ogg123] } - end + depends_on 'ogg' + depends_on 'vorbis' + depends_on 'ao' => :optional + depends_on 'ogg123' => :optional def install system "./configure --disable-debug --disable-nls --disable-dependency-tracking --prefix='#{prefix}'" diff --git a/Library/Formula/yajl.rb b/Library/Formula/yajl.rb index 19f47f2ff..f47a454e4 100644 --- a/Library/Formula/yajl.rb +++ b/Library/Formula/yajl.rb @@ -5,9 +5,7 @@ class Yajl ['http://moo.com/patch5', 'http://moo.com/patch6'] # } def patches; [] end - # reimplement and specify dependencies - def deps; end # sometimes the clean process breaks things, return true to skip anything def skip_clean? path; false end @@ -157,6 +155,7 @@ class Formula end def self.factory name + return name if name.kind_of? Formula require self.path(name) return eval(self.class(name)).new(name) rescue LoadError @@ -167,6 +166,10 @@ class Formula HOMEBREW_PREFIX+'Library'+'Formula'+"#{name.downcase}.rb" end + def deps + self.class.deps or [] + end + protected # Pretty titles the command and buffers stdout/stderr # Throws if there's an error @@ -280,9 +283,31 @@ private end class <