aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Howell2009-09-07 01:06:08 +0100
committerMax Howell2009-09-10 19:23:03 +0100
commitd366b28923ed31aafe914a3f27873b2b7605e903 (patch)
treedf03cc6b62658324cd5c3f0250e394122ef5dae2
parent16ad958a11fb87a67e35659b8938eee99e211555 (diff)
downloadhomebrew-d366b28923ed31aafe914a3f27873b2b7605e903.tar.bz2
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.
-rw-r--r--Library/Formula/fish.rb2
-rw-r--r--Library/Formula/ghostscript.rb32
-rw-r--r--Library/Formula/imagemagick.rb61
-rw-r--r--Library/Formula/liblastfm.rb4
-rw-r--r--Library/Formula/libmusicbrainz.rb3
-rw-r--r--Library/Formula/libtiff.rb12
-rw-r--r--Library/Formula/libvorbis.rb2
-rw-r--r--Library/Formula/libwmf.rb16
-rw-r--r--Library/Formula/little-cms.rb12
-rw-r--r--Library/Formula/memcached.rb2
-rw-r--r--Library/Formula/mysql-connector-c.rb2
-rw-r--r--Library/Formula/mysql.rb3
-rw-r--r--Library/Formula/nginx.rb2
-rw-r--r--Library/Formula/playdar.rb4
-rw-r--r--Library/Formula/python.rb2
-rw-r--r--Library/Formula/scummvm.rb6
-rw-r--r--Library/Formula/sshfs.rb4
-rw-r--r--Library/Formula/taglib.rb4
-rw-r--r--Library/Formula/unp.rb2
-rw-r--r--Library/Formula/vorbis-tools.rb4
-rw-r--r--Library/Formula/yajl.rb4
-rw-r--r--Library/Homebrew/brew.h.rb27
-rw-r--r--Library/Homebrew/formula.rb2
-rwxr-xr-xLibrary/Homebrew/unittest.rb23
-rwxr-xr-xbin/brew31
25 files changed, 150 insertions, 116 deletions
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 <Formula
@md5='4b2436843e63bebba467cc4add11428a'
def deps
- LibraryDep.new 'readline'
+ 'readline'
end
def install
diff --git a/Library/Formula/ghostscript.rb b/Library/Formula/ghostscript.rb
new file mode 100644
index 000000000..9f7ef7785
--- /dev/null
+++ b/Library/Formula/ghostscript.rb
@@ -0,0 +1,32 @@
+require 'brewkit'
+
+class GhostscriptFonts <Formula
+ @url='http://downloads.sourceforge.net/project/gs-fonts/gs-fonts/8.11%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-8.11.tar.gz'
+ @homepage='http://sourceforge.net/projects/gs-fonts/'
+ @md5='6865682b095f8c4500c54b285ff05ef6'
+end
+
+class Ghostscript <Formula
+ @url='http://downloads.sourceforge.net/project/ghostscript/GPL%20Ghostscript/8.70/ghostscript-8.70.tar.bz2'
+ @homepage='http://www.ghostscript.com/'
+ @md5='526366f8cb4fda0d3d293597cc5b984b'
+
+ def install
+ # ghostscript configure ignores LDFLAGs apparently
+ ENV['LIBS']="-L/usr/X11/lib"
+ system "./configure", "--prefix=#{prefix}", "--disable-debug",
+ # the cups component adamantly installs to /usr so fuck it
+ "--disable-cups"
+ # versioned stuff in main tree is pointless for us
+ inreplace 'Makefile', '/$(GS_DOT_VERSION)', ''
+ system "make install"
+ (prefix+'share'+'ghostscript'+'doc').rmtree
+
+ GhostscriptFonts.new.brew do
+ Dir.chdir '..'
+ (prefix+'share'+'ghostscript').install 'fonts'
+ end
+
+ (man+'de').rmtree
+ end
+end
diff --git a/Library/Formula/imagemagick.rb b/Library/Formula/imagemagick.rb
index 5db518006..ee06a50ac 100644
--- a/Library/Formula/imagemagick.rb
+++ b/Library/Formula/imagemagick.rb
@@ -2,43 +2,13 @@ require 'brewkit'
# some credit to http://github.com/maddox/magick-installer
-class LibTIFF <Formula
- @url='ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz'
- @homepage='http://www.libtiff.org/'
- @md5='fbb6f446ea4ed18955e2714934e5b698'
-end
-
-class Libwmf <Formula
- @url='http://downloads.sourceforge.net/project/wvware/libwmf/0.2.8.4/libwmf-0.2.8.4.tar.gz'
- @homepage='http://wvware.sourceforge.net/libwmf.html'
- @md5='d1177739bf1ceb07f57421f0cee191e0'
-end
-
-class LittleCMS <Formula
- @url='http://www.littlecms.com/lcms-1.17.tar.gz'
- @homepage='http://www.littlecms.com/'
- @md5='07bdbb4cfb05d21caa58fe3d1c84ddc1'
-end
-
-class Ghostscript <Formula
- @url='http://downloads.sourceforge.net/project/ghostscript/GPL%20Ghostscript/8.70/ghostscript-8.70.tar.bz2'
- @homepage='http://www.ghostscript.com/'
- @md5='526366f8cb4fda0d3d293597cc5b984b'
-end
-
-class GhostscriptFonts <Formula
- @url='http://downloads.sourceforge.net/project/gs-fonts/gs-fonts/8.11%20%28base%2035%2C%20GPL%29/ghostscript-fonts-std-8.11.tar.gz'
- @homepage='http://sourceforge.net/projects/gs-fonts/'
- @md5='6865682b095f8c4500c54b285ff05ef6'
-end
-
class Imagemagick <Formula
@url='ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.5.5-4.tar.bz2'
@md5='8cb7471a50428e4892ee46aa404e54c2'
@homepage='http://www.imagemagick.org'
def deps
- LibraryDep.new 'jpeg'
+ { :required => 'jpeg', :optional => %w[libwmf libtiff little-cms ghostscript] }
end
def install
@@ -47,33 +17,6 @@ class Imagemagick <Formula
# TODO eventually these will be external optional dependencies
# but for now I am lazy
- LibTIFF.new.brew do
- system "./configure", "--prefix=#{prefix}", "--disable-debug"
- system "make install"
- end
- Libwmf.new.brew do
- system "./configure", "--prefix=#{prefix}", "--disable-debug"
- system "make install"
- end
- LittleCMS.new.brew do
- system "./configure", "--prefix=#{prefix}", "--disable-debug"
- system "make install"
- end
- Ghostscript.new.brew do
- # ghostscript configure ignores LDFLAGs apparently
- ENV['LIBS']="-L/usr/X11/lib"
- system "./configure", "--prefix=#{prefix}", "--disable-debug",
- # the cups component adamantly installs to /usr so fuck it
- "--disable-cups"
- # versioned stuff in main tree is pointless for us
- inreplace 'Makefile', '/$(GS_DOT_VERSION)', ''
- system "make install"
- (prefix+'share'+'ghostscript'+'doc').rmtree
- end
- GhostscriptFonts.new.brew do
- Dir.chdir '..'
- (prefix+'share'+'ghostscript').install 'fonts'
- end
# versioned stuff in main tree is pointless for us
inreplace 'configure', '${PACKAGE_NAME}-${PACKAGE_VERSION}', '${PACKAGE_NAME}'
@@ -91,8 +34,6 @@ class Imagemagick <Formula
(d+'NEWS.txt').unlink
(d+'LICENSE').unlink
(d+'ChangeLog').unlink
-
- (man+'de').rmtree
end
def caveats
diff --git a/Library/Formula/liblastfm.rb b/Library/Formula/liblastfm.rb
index 52444bdfa..ea6a61706 100644
--- a/Library/Formula/liblastfm.rb
+++ b/Library/Formula/liblastfm.rb
@@ -6,9 +6,7 @@ class Liblastfm <Formula
@md5='3f73222ebc31635941832b01e7a494b6'
def deps
- BinaryDep.new 'qmake', 'qt'
- LibraryDep.new 'fftw3f', 'fftw'
- LibraryDep.new 'samplerate'
+ %w[qt fftw samplerate]
end
def install
diff --git a/Library/Formula/libmusicbrainz.rb b/Library/Formula/libmusicbrainz.rb
index d562ab12a..b9d5c1c45 100644
--- a/Library/Formula/libmusicbrainz.rb
+++ b/Library/Formula/libmusicbrainz.rb
@@ -6,8 +6,7 @@ class Libmusicbrainz <Formula
@md5='648ecd43f7b80852419aaf73702bc23f'
def deps
- LibraryDep.new 'neon'
- OptionalLibraryDep.new 'libdiscid'
+ { :required => '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 <Formula
+ @url='ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz'
+ @homepage='http://www.libtiff.org/'
+ @md5='fbb6f446ea4ed18955e2714934e5b698'
+
+ def install
+ system "./configure", "--prefix=#{prefix}", "--disable-debug"
+ system "make install"
+ end
+end
diff --git a/Library/Formula/libvorbis.rb b/Library/Formula/libvorbis.rb
index d597b1feb..cdd795437 100644
--- a/Library/Formula/libvorbis.rb
+++ b/Library/Formula/libvorbis.rb
@@ -6,7 +6,7 @@ class Libvorbis <Formula
@homepage='http://vorbis.com'
def deps
- LibraryDep.new 'libogg'
+ 'libogg'
end
def install
diff --git a/Library/Formula/libwmf.rb b/Library/Formula/libwmf.rb
new file mode 100644
index 000000000..f1a3ba1a1
--- /dev/null
+++ b/Library/Formula/libwmf.rb
@@ -0,0 +1,16 @@
+require 'brewkit'
+
+class Libwmf <Formula
+ @url='http://downloads.sourceforge.net/project/wvware/libwmf/0.2.8.4/libwmf-0.2.8.4.tar.gz'
+ @homepage='http://wvware.sourceforge.net/libwmf.html'
+ @md5='d1177739bf1ceb07f57421f0cee191e0'
+
+ def install
+ ENV.libpng
+ system "./configure", "--prefix=#{prefix}", "--disable-debug"
+ system "make"
+
+ ENV.j1 # yet another rubbish Makefile
+ system "make install"
+ end
+end
diff --git a/Library/Formula/little-cms.rb b/Library/Formula/little-cms.rb
new file mode 100644
index 000000000..a3efd783b
--- /dev/null
+++ b/Library/Formula/little-cms.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class LittleCms <Formula
+ @url='http://www.littlecms.com/lcms-1.17.tar.gz'
+ @homepage='http://www.littlecms.com/'
+ @md5='07bdbb4cfb05d21caa58fe3d1c84ddc1'
+
+ def install
+ system "./configure", "--prefix=#{prefix}", "--disable-debug"
+ system "make install"
+ end
+end
diff --git a/Library/Formula/memcached.rb b/Library/Formula/memcached.rb
index fda521f1d..0ad5681c3 100644
--- a/Library/Formula/memcached.rb
+++ b/Library/Formula/memcached.rb
@@ -6,7 +6,7 @@ class Memcached <Formula
@md5='d7651ecb8bf345144cb17900d9a46c85'
def deps
- LibraryDep.new 'libevent'
+ 'libevent'
end
def install
diff --git a/Library/Formula/mysql-connector-c.rb b/Library/Formula/mysql-connector-c.rb
index f97945135..f135f7dc8 100644
--- a/Library/Formula/mysql-connector-c.rb
+++ b/Library/Formula/mysql-connector-c.rb
@@ -6,7 +6,7 @@ class MysqlConnectorC <Formula
@md5='348a869fa72957062ea4e7ad3865623c'
def deps
- BinaryDep.new 'cmake'
+ 'cmake'
end
def install
diff --git a/Library/Formula/mysql.rb b/Library/Formula/mysql.rb
index 662d8320d..5cfb8be41 100644
--- a/Library/Formula/mysql.rb
+++ b/Library/Formula/mysql.rb
@@ -6,8 +6,7 @@ class Mysql <Formula
@md5='7564d7759a8077b3a0e6190955422287'
def deps
- # --without-readline means use system's readline
- LibraryDep.new 'readline'
+ 'readline'
end
def options
diff --git a/Library/Formula/nginx.rb b/Library/Formula/nginx.rb
index b2fe3e2fa..4863381e6 100644
--- a/Library/Formula/nginx.rb
+++ b/Library/Formula/nginx.rb
@@ -6,7 +6,7 @@ class Nginx <Formula
@md5='6ebf89b9b00a3b82734e93c32da7df07'
def deps
- LibraryDep.new 'pcre'
+ 'pcre'
end
def install
diff --git a/Library/Formula/playdar.rb b/Library/Formula/playdar.rb
index 0d2669ea8..44b1f815d 100644
--- a/Library/Formula/playdar.rb
+++ b/Library/Formula/playdar.rb
@@ -5,9 +5,7 @@ class Playdar <Formula
@head='git://github.com/mxcl/playdar.git'
def deps
- LibraryDep.new 'taglib'
- LibraryDep.new 'boost'
- BinaryDep.new 'cmake'
+ %w[taglib boost cmake]
end
def skip_clean? path
diff --git a/Library/Formula/python.rb b/Library/Formula/python.rb
index d1d058644..0624146bc 100644
--- a/Library/Formula/python.rb
+++ b/Library/Formula/python.rb
@@ -7,7 +7,7 @@ class Python <Formula
def deps
# You can build Python without readline, but you really don't want to.
- LibraryDep.new 'readline'
+ 'readline'
end
def skip_clean? path
diff --git a/Library/Formula/scummvm.rb b/Library/Formula/scummvm.rb
index de0bd7bf1..adb1f1a48 100644
--- a/Library/Formula/scummvm.rb
+++ b/Library/Formula/scummvm.rb
@@ -14,11 +14,7 @@ prefer to use theirs. If so type `brew home scummvm' to visit their site.
end
def deps
- LibraryDep.new 'sdl'
- # Optional, but you want them anyway.
- OptionalLibraryDep.new 'flac'
- OptionalLibraryDep.new 'libogg'
- OptionalLibraryDep.new 'libvorbis'
+ { :required => '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 <Formula
end
def deps
- BinaryDep.new 'pkg-config'
- LibraryDep.new 'glib'
- LibraryDep.new 'macfuse'
+ %w[pkg-config glib macfuse]
end
def install
diff --git a/Library/Formula/taglib.rb b/Library/Formula/taglib.rb
index 59129a16a..ea92fa6df 100644
--- a/Library/Formula/taglib.rb
+++ b/Library/Formula/taglib.rb
@@ -11,13 +11,13 @@ class Taglib <Formula
@homepage='http://developer.kde.org/~wheeler/taglib.html'
def deps
- BinaryDep.new 'cmake'
+ 'cmake'
end
def install
system "./configure --disable-debug --prefix='#{prefix}'"
system "make install"
-
+
TaglibExtras.new.brew do
system "cmake . #{std_cmake_parameters}"
system "make install"
diff --git a/Library/Formula/unp.rb b/Library/Formula/unp.rb
index 50ab9ea8c..83cd639c2 100644
--- a/Library/Formula/unp.rb
+++ b/Library/Formula/unp.rb
@@ -6,7 +6,7 @@ class Unp <Formula
@md5='ecea662bd7e7efe7f7e2213bf21d9646'
def deps
- BinaryDep.new 'p7zip'
+ 'p7zip'
end
def install
diff --git a/Library/Formula/vorbis-tools.rb b/Library/Formula/vorbis-tools.rb
index 4cd6613ac..b057cbe18 100644
--- a/Library/Formula/vorbis-tools.rb
+++ b/Library/Formula/vorbis-tools.rb
@@ -6,9 +6,7 @@ class VorbisTools <Formula
@homepage='http://vorbis.com'
def deps
- LibraryDep.new 'ogg'
- LibraryDep.new 'vorbis'
- OptionalLibraryDep.new 'ao', 'ogg123'
+ { :required => %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 <Formula
@md5='f4a3cbc764c43231ed1aedc54438b69b'
def deps
- BinaryDep.new 'cmake'
+ 'cmake'
end
def install
@@ -18,4 +18,4 @@ class Yajl <Formula
system "./configure --prefix '#{prefix}'"
system "make install"
end
-end \ No newline at end of file
+end
diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb
index 8b3939968..496e7afc0 100644
--- a/Library/Homebrew/brew.h.rb
+++ b/Library/Homebrew/brew.h.rb
@@ -144,6 +144,33 @@ 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
+ 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
+ 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
+ end
+ # TODO much more efficient to use a set and not recurse stuff already done
+ return deps.flatten.uniq
+end
+
+
def install f
f.brew do
if ARGV.flag? '--interactive'
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 7faabbae6..9c5123545 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -123,7 +123,7 @@ class Formula
def brew
validate_variable :name
validate_variable :version
-
+
stage do
begin
patch
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb
index ae8b0c1bc..2738755e4 100755
--- a/Library/Homebrew/unittest.rb
+++ b/Library/Homebrew/unittest.rb
@@ -41,7 +41,8 @@ class MostlyAbstractFormula <Formula
end
class TestBall <Formula
- def initialize
+ # name parameter required for some Formula::factory
+ def initialize name=nil
@url="file:///#{Pathname.new(ABS__FILE__).parent.realpath}/testball-0.1.tbz"
super "testball"
end
@@ -98,9 +99,13 @@ def nostdout
end
module ExtendArgvPlusYeast
- def stick_an_arg_in_thar
+ def reset
@named=nil
- unshift 'foo'
+ @formulae=nil
+ @kegs=nil
+ while ARGV.count > 0
+ ARGV.shift
+ end
end
end
ARGV.extend ExtendArgvPlusYeast
@@ -347,8 +352,9 @@ class BeerTasting <Test::Unit::TestCase
end
def test_no_ARGV_dupes
- ARGV.unshift'foo'
- ARGV.unshift'foo'
+ ARGV.reset
+ ARGV.unshift 'foo'
+ ARGV.unshift 'foo'
n=0
ARGV.named.each{|arg| n+=1 if arg == 'foo'}
assert_equal 1, n
@@ -360,9 +366,10 @@ class BeerTasting <Test::Unit::TestCase
assert_raises(UsageError) { ARGV.kegs }
assert ARGV.named_empty?
- (HOMEBREW_CELLAR+'foo'+'0.1').mkpath
+ (HOMEBREW_CELLAR+'mxcl'+'10.0').mkpath
- ARGV.stick_an_arg_in_thar
+ ARGV.reset
+ ARGV.unshift 'mxcl'
assert_equal 1, ARGV.named.length
assert_equal 1, ARGV.kegs.length
assert_raises(FormulaUnavailableError) { ARGV.formulae }
@@ -395,7 +402,7 @@ class BeerTasting <Test::Unit::TestCase
nostdout do
assert_nothing_raised do
f=TestBall.new
- make 'http://example.com/testball-0.1.tbz'
+ make f.url
info f.name
clean f
prune
diff --git a/bin/brew b/bin/brew
index ba7080290..6ce18a4ac 100755
--- a/bin/brew
+++ b/bin/brew
@@ -95,20 +95,24 @@ begin
raise "We cannot find a c compiler, have you installed the latest Xcode?"
end
- require 'beer_events'
-
- watch_out_for_spill do
- ARGV.formulae.each do |f|
- if f.installed? and not ARGV.force?
- message = "Formula already installed: #{f.prefix}"
- if ARGV.formulae.count > 1
- opoo message
- else
- puts message # if only one is being installed a warning looks severe
- end
- next
+ fae = ARGV.formulae.reject do |f|
+ if f.installed? and not ARGV.force?
+ message = "Formula already installed: #{f.prefix}"
+ if ARGV.formulae.count > 1
+ opoo message
+ else
+ puts message # if only one is being installed a warning looks severe
end
+ true
+ end
+ end
+
+ fae=expand_deps ARGV.formulae
+ 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
pid=fork
@@ -162,9 +166,6 @@ begin
when 'unlink'
ARGV.kegs.each {|keg| puts "#{keg.unlink} links removed for #{keg}"}
- when 'unlink'
- ARGV.kegs.each {|keg| puts "#{keg.unlink} links removed for #{keg}"}
-
when 'rm', 'uninstall', 'remove'
ARGV.kegs.each do |keg|
puts "Uninstalling #{keg}..."