aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Howell2009-09-18 19:16:39 +0100
committerMax Howell2009-09-21 18:27:48 +0100
commit68108e109839a901313b9933cbb1e3202aed90cf (patch)
tree124d204c43534f4e8171c5d278d4cb09d46f06a2
parent0d1ec9641403ea2de9588ffdb22b68a23e6c2547 (diff)
downloadhomebrew-68108e109839a901313b9933cbb1e3202aed90cf.tar.bz2
Dependency resolution with fancy syntax
Is it a DSL? No. But people call it that apparently. To add a dependency: class Doe <Formula depends_on 'ray' depends_on 'mee' => :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
-rw-r--r--Library/Formula/erlang.rb3
-rw-r--r--Library/Formula/fish.rb4
-rw-r--r--Library/Formula/glib.rb6
-rw-r--r--Library/Formula/imagemagick.rb19
-rw-r--r--Library/Formula/liblastfm.rb6
-rw-r--r--Library/Formula/libmusicbrainz.rb5
-rw-r--r--Library/Formula/libvorbis.rb4
-rw-r--r--Library/Formula/memcached.rb4
-rw-r--r--Library/Formula/mysql-connector-c.rb4
-rw-r--r--Library/Formula/mysql.rb4
-rw-r--r--Library/Formula/nginx.rb4
-rw-r--r--Library/Formula/playdar.rb6
-rw-r--r--Library/Formula/python.rb6
-rw-r--r--Library/Formula/scummvm.rb7
-rw-r--r--Library/Formula/sshfs.rb6
-rw-r--r--Library/Formula/subversion.rb13
-rw-r--r--Library/Formula/unp.rb4
-rw-r--r--Library/Formula/vorbis-tools.rb7
-rw-r--r--Library/Formula/yajl.rb4
-rw-r--r--Library/Homebrew/brew.h.rb27
-rw-r--r--Library/Homebrew/formula.rb33
-rwxr-xr-xbin/brew23
22 files changed, 93 insertions, 106 deletions
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 <Formula
@url='http://erlang.org/download/otp_src_R13B01.tar.gz'
@md5='b3db581de6c13e1ec93d74e54a7b4231'
+ depends_on 'icu4c'
+ depends_on 'openssl'
+
def install
ENV.deparallelize
system "./configure", "--disable-debug",
diff --git a/Library/Formula/fish.rb b/Library/Formula/fish.rb
index 09246747e..0324f0259 100644
--- a/Library/Formula/fish.rb
+++ b/Library/Formula/fish.rb
@@ -5,9 +5,7 @@ class Fish <Formula
@homepage='http:://fishshell.org/'
@md5='4b2436843e63bebba467cc4add11428a'
- def deps
- 'readline'
- end
+ depends_on 'readline'
def install
system "./configure", "--prefix=#{prefix}", "--without-xsel"
diff --git a/Library/Formula/glib.rb b/Library/Formula/glib.rb
index 9befe40c1..24c55be41 100644
--- a/Library/Formula/glib.rb
+++ b/Library/Formula/glib.rb
@@ -5,10 +5,8 @@ class Glib <Formula
@md5='4c178b91d82ef80a2da3c26b772569c0'
@homepage='http://www.gtk.org'
- def deps
- BinaryDep.new 'pkg-config'
- LibraryDep.new 'gettext'
- end
+ depends_on 'pkg-config'
+ depends_on 'gettext'
def install
# indeed, amazingly, -w causes gcc to emit spurious errors for this package!
diff --git a/Library/Formula/imagemagick.rb b/Library/Formula/imagemagick.rb
index ee06a50ac..0a7469b8a 100644
--- a/Library/Formula/imagemagick.rb
+++ b/Library/Formula/imagemagick.rb
@@ -7,9 +7,11 @@ class Imagemagick <Formula
@md5='8cb7471a50428e4892ee46aa404e54c2'
@homepage='http://www.imagemagick.org'
- def deps
- { :required => '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 <Formula
"--without-maximum-compile-warnings",
"--prefix=#{prefix}",
"--disable-osx-universal-binary",
- "--with-gs-font-dir=#{prefix}/share/ghostscript/fonts",
+ "--with-gs-font-dir=#{HOMEBREW_PREFIX}/share/ghostscript/fonts",
"--without-perl" # I couldn't make this compile
system "make install"
- # We already copy these in
- d=prefix+'share'
- (d+'NEWS.txt').unlink
- (d+'LICENSE').unlink
- (d+'ChangeLog').unlink
+ # We already copy these into the keg root
+ (share+'NEWS.txt').unlink
+ (share+'LICENSE').unlink
+ (share+'ChangeLog').unlink
end
def caveats
diff --git a/Library/Formula/liblastfm.rb b/Library/Formula/liblastfm.rb
index ea6a61706..fabdf637b 100644
--- a/Library/Formula/liblastfm.rb
+++ b/Library/Formula/liblastfm.rb
@@ -5,9 +5,9 @@ class Liblastfm <Formula
@url='http://static.last.fm/src/liblastfm-0.3.0.tar.bz2'
@md5='3f73222ebc31635941832b01e7a494b6'
- def deps
- %w[qt fftw samplerate]
- end
+ depends_on 'qt'
+ depends_on 'fftw'
+ depends_on 'samplerate'
def install
system "./configure --release --prefix '#{prefix}'"
diff --git a/Library/Formula/libmusicbrainz.rb b/Library/Formula/libmusicbrainz.rb
index b9d5c1c45..b7869abca 100644
--- a/Library/Formula/libmusicbrainz.rb
+++ b/Library/Formula/libmusicbrainz.rb
@@ -5,9 +5,8 @@ class Libmusicbrainz <Formula
@homepage='http://musicbrainz.org'
@md5='648ecd43f7b80852419aaf73702bc23f'
- def deps
- { :required => '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 <Formula
@md5='6a7086ee666b8c62e122d29d107f7bec'
@homepage='http://vorbis.com'
- def deps
- 'libogg'
- end
+ depends_on 'libogg'
def install
system "./configure --enable-docs --disable-debug --disable-dependency-tracking --prefix='#{prefix}'"
diff --git a/Library/Formula/memcached.rb b/Library/Formula/memcached.rb
index 0ad5681c3..3b942615f 100644
--- a/Library/Formula/memcached.rb
+++ b/Library/Formula/memcached.rb
@@ -5,9 +5,7 @@ class Memcached <Formula
@homepage='http://www.danga.com/memcached/'
@md5='d7651ecb8bf345144cb17900d9a46c85'
- def deps
- 'libevent'
- end
+ depends_on 'libevent'
def install
system "./configure --prefix='#{prefix}'"
diff --git a/Library/Formula/mysql-connector-c.rb b/Library/Formula/mysql-connector-c.rb
index f135f7dc8..580b6f5a6 100644
--- a/Library/Formula/mysql-connector-c.rb
+++ b/Library/Formula/mysql-connector-c.rb
@@ -5,9 +5,7 @@ class MysqlConnectorC <Formula
@url='http://mysql.llarian.net/Downloads/Connector-C/mysql-connector-c-6.0.1.tar.gz'
@md5='348a869fa72957062ea4e7ad3865623c'
- def deps
- 'cmake'
- end
+ depends_on 'cmake'
def install
system "cmake . #{std_cmake_parameters}"
diff --git a/Library/Formula/mysql.rb b/Library/Formula/mysql.rb
index 5cfb8be41..76fd2a7c4 100644
--- a/Library/Formula/mysql.rb
+++ b/Library/Formula/mysql.rb
@@ -5,9 +5,7 @@ class Mysql <Formula
@homepage='http://dev.mysql.com/doc/refman/5.1/en/'
@md5='7564d7759a8077b3a0e6190955422287'
- def deps
- 'readline'
- end
+ depends_on 'readline'
def options
[
diff --git a/Library/Formula/nginx.rb b/Library/Formula/nginx.rb
index 4863381e6..d0f03666b 100644
--- a/Library/Formula/nginx.rb
+++ b/Library/Formula/nginx.rb
@@ -5,9 +5,7 @@ class Nginx <Formula
@homepage='http://nginx.net/'
@md5='6ebf89b9b00a3b82734e93c32da7df07'
- def deps
- 'pcre'
- end
+ depends_on 'pcre'
def install
system "./configure", "--prefix=#{prefix}", "--with-http_ssl_module"
diff --git a/Library/Formula/playdar.rb b/Library/Formula/playdar.rb
index 44b1f815d..5ec5c0639 100644
--- a/Library/Formula/playdar.rb
+++ b/Library/Formula/playdar.rb
@@ -4,9 +4,9 @@ class Playdar <Formula
@homepage='http://www.playdar.org'
@head='git://github.com/mxcl/playdar.git'
- def deps
- %w[taglib boost cmake]
- end
+ depends_on 'taglib'
+ depends_on 'boost'
+ depends_on 'cmake'
def skip_clean? path
# for some reason stripping breaks it
diff --git a/Library/Formula/python.rb b/Library/Formula/python.rb
index 6d92d147c..c1d15a887 100644
--- a/Library/Formula/python.rb
+++ b/Library/Formula/python.rb
@@ -26,10 +26,8 @@ class Python <Formula
@homepage='http://www.python.org/'
@md5='245db9f1e0f09ab7e0faaa0cf7301011'
- def deps
- # You can build Python without readline, but you really don't want to.
- Readline.new
- end
+ # You can build Python without readline, but you really don't want to.
+ depends_on Readline.new
def skip_clean? path
path == bin+'python' or path == bin+'python2.6' or # if you strip these, it can't load modules
diff --git a/Library/Formula/scummvm.rb b/Library/Formula/scummvm.rb
index adb1f1a48..912c4207e 100644
--- a/Library/Formula/scummvm.rb
+++ b/Library/Formula/scummvm.rb
@@ -13,9 +13,10 @@ prefer to use theirs. If so type `brew home scummvm' to visit their site.
EOS
end
- def deps
- { :required => '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 <Formula
}
end
- def deps
- %w[pkg-config glib macfuse]
- end
+ depends_on 'pkg-config'
+ depends_on 'glib'
+ depends_on 'macfuse'
def install
# Steal compile flags from macfuse_buildtool.sh
diff --git a/Library/Formula/subversion.rb b/Library/Formula/subversion.rb
index 63254e746..e4584062e 100644
--- a/Library/Formula/subversion.rb
+++ b/Library/Formula/subversion.rb
@@ -1,22 +1,13 @@
require 'brewkit'
-class SubversionDeps <Formula
- @url='http://subversion.tigris.org/downloads/subversion-deps-1.6.5.tar.bz2'
- @md5='8272316e1670d4d2bea451411e438bde'
-end
-
class Subversion <Formula
@url='http://subversion.tigris.org/downloads/subversion-1.6.5.tar.bz2'
@homepage='http://subversion.tigris.org/'
@md5='1a53a0e72bee0bf814f4da83a9b6a636'
- def install
- # Slot dependencies into place
- d=Pathname.getwd
- SubversionDeps.new.brew do
- d.install Dir['*']
- end
+ depends_on 'neon'
+ def install
# Use existing system zlib, dep-provided other libraries
# Don't mess with Apache modules (since we're not sudo)
system "./configure", "--disable-debug",
diff --git a/Library/Formula/unp.rb b/Library/Formula/unp.rb
index 83cd639c2..d01b7a36e 100644
--- a/Library/Formula/unp.rb
+++ b/Library/Formula/unp.rb
@@ -5,9 +5,7 @@ class Unp <Formula
@homepage='http://packages.debian.org/de/etch/unp'
@md5='ecea662bd7e7efe7f7e2213bf21d9646'
- def deps
- 'p7zip'
- end
+ depends_on 'p7zip'
def install
bin.install %w[unp ucat]
diff --git a/Library/Formula/vorbis-tools.rb b/Library/Formula/vorbis-tools.rb
index b057cbe18..deaa2d403 100644
--- a/Library/Formula/vorbis-tools.rb
+++ b/Library/Formula/vorbis-tools.rb
@@ -5,9 +5,10 @@ class VorbisTools <Formula
@md5='df976d24e51ef3d87cd462edf747bf9a'
@homepage='http://vorbis.com'
- def deps
- { :required => %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 <Formula
@url='http://github.com/lloyd/yajl/tarball/1.0.5'
@md5='f4a3cbc764c43231ed1aedc54438b69b'
- def deps
- 'cmake'
- end
+ depends_on 'cmake'
def install
ENV.deparallelize
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb
index 875f61be0..0d977ae95 100644
--- a/Library/Homebrew/brew.h.rb
+++ b/Library/Homebrew/brew.h.rb
@@ -144,31 +144,12 @@ def clean f
end
-# NOTE this is ugly code, and inefficient too, and can have infinite cycles
-# I have no time currently to improve it, feel free to submit a more elegant
-# solution. Thanks! --mxcl
-def expand_deps fae
+def expand_deps ff
deps = []
- fae.each do |f|
- case f.deps
- when String, Array
- f.deps.each do |name|
- f = Formula.factory name
- deps << expand_deps(f) if f.deps # hideous inefficient
- deps << f unless f.installed?
- end
- when Hash
- # TODO implement optional and recommended
- names = []
- f.deps.each_value {|v| names << v}
- ff=names.flatten.collect {|name| Formula.factory name}
- deps << expand_deps(ff)
- end
- deps << f
+ ff.deps.collect do |f|
+ deps += expand_deps(Formula.factory(f))
end
-
- # TODO much more efficient to use a set and not recurse stuff already done
- return deps.flatten.uniq
+ deps << ff
end
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 9c5123545..a4bebdd2b 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -114,8 +114,6 @@ class Formula
# :p2 => ['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 <<self
- attr_reader :url, :version, :homepage, :head
+ attr_reader :url, :version, :homepage, :head, :deps
attr_reader *CHECKSUM_TYPES
- end
+
+ def depends_on name, *args
+ @deps ||= []
+
+ case name
+ when String
+ # noop
+ when Hash
+ name = name.keys.first # indeed, we only support one mapping
+ when Symbol
+ name = name.to_s
+ when Formula
+ @deps << name
+ return # we trust formula dev to not dupe their own instantiations
+ else
+ raise "Unsupported type #{name.class}"
+ end
+
+ # we get duplicates because every new fork of this process repeats this
+ # step for some reason I am not sure about
+ @deps << name unless @deps.include? name
+ end
+ end
end
# see ack.rb for an example usage
diff --git a/bin/brew b/bin/brew
index bf3a449c2..722544615 100755
--- a/bin/brew
+++ b/bin/brew
@@ -38,6 +38,7 @@ unless system "which -s gcc-4.2" and $?.success?
abort "Sorry, Homebrew requires gcc 4.2, which is provided by Xcode 3.1"
end
+
begin
case ARGV.shift
when '--prefix' then puts HOMEBREW_PREFIX
@@ -104,7 +105,7 @@ begin
unless system "which #{ENV['CC'] or 'cc'} &> /dev/null" and $?.success?
raise "We cannot find a c compiler, have you installed the latest Xcode?"
end
- fae = ARGV.formulae.reject do |f|
+ formulae = ARGV.formulae.reject do |f|
if f.installed?
message = "Formula already installed: #{f.prefix}"
if ARGV.formulae.count > 1
@@ -115,20 +116,24 @@ begin
true
end
end
- exit 0 if fae.empty?
+ exit 0 if formulae.empty?
else
- fae=ARGV.formulae
+ formulae = ARGV.formulae
end
- # the resulting order will be optimal for super-deps and deps
- fae=expand_deps fae
+ deps = []
+ formulae.each { |f| deps += expand_deps f }
+ formulae = deps.reject { |f| f.installed? }
- require 'beer_events'
+ require 'set'
+ done = Set.new
+ require 'beer_events'
watch_out_for_spill do
- fae.each do |f|
- # we need to ensure a pristine ENV for each process or the formula
- # will start with the ENV from the previous build
+ formulae.each do |f|
+ next if done.include? f.class
+ done << f.class
+
pid=fork
if pid.nil?
exec __FILE__, "install-just-one", f.name, *ARGV.options