aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMax Howell2009-06-04 19:21:19 +0100
committerMax Howell2009-06-04 19:36:58 +0100
commite91aeafc82edb2b79af67e342009cd019cd1ede5 (patch)
tree2c12888da095f544f650787ad447aa2edb94d8c1 /Library
parent84ad47bc3c8029847e5c41ab4646a6b9455b370a (diff)
downloadhomebrew-e91aeafc82edb2b79af67e342009cd019cd1ede5.tar.bz2
Created /Library moved brew tool to /bin
Moved Forumla and Cellar/homebrew into Library. This way the homebrew core files are more sensibly placed, Cellar is more internally consistent and only generated. And Homebrew is ready for use straight out of the tarball.
Diffstat (limited to 'Library')
-rw-r--r--Library/Formula/ack.rb10
-rw-r--r--Library/Formula/asciidoc.rb12
-rw-r--r--Library/Formula/boost.rb16
-rw-r--r--Library/Formula/cmake.rb13
-rw-r--r--Library/Formula/dmd.rb42
-rw-r--r--Library/Formula/fftw.rb21
-rw-r--r--Library/Formula/git.rb20
-rw-r--r--Library/Formula/grc.rb70
-rw-r--r--Library/Formula/lame.rb12
-rw-r--r--Library/Formula/liblastfm.rb19
-rw-r--r--Library/Formula/libogg.rb12
-rw-r--r--Library/Formula/libsamplerate.rb12
-rw-r--r--Library/Formula/mad.rb12
-rw-r--r--Library/Formula/pkg-config.rb14
-rw-r--r--Library/Formula/pngcrush.rb12
-rw-r--r--Library/Formula/qt.rb43
-rw-r--r--Library/Formula/taglib.rb12
-rw-r--r--Library/Formula/term.rb10
-rw-r--r--Library/Formula/wget.rb13
-rw-r--r--Library/Formula/xmlrpc-c.rb16
-rw-r--r--Library/Formula/yajl.rb21
-rw-r--r--Library/Homebrew/brewkit.rb359
-rw-r--r--Library/Homebrew/env.rb22
-rwxr-xr-xLibrary/Homebrew/unittest.rb72
24 files changed, 865 insertions, 0 deletions
diff --git a/Library/Formula/ack.rb b/Library/Formula/ack.rb
new file mode 100644
index 000000000..4bab09c89
--- /dev/null
+++ b/Library/Formula/ack.rb
@@ -0,0 +1,10 @@
+require 'brewkit'
+
+class Ack <UncompressedScriptFormula
+ def initialize
+ @version='1.88'
+ @url="http://ack.googlecode.com/svn/tags/#{@version}/ack"
+ @md5='8009a13ab0fc66047bea0ea2ad89419c'
+ @homepage='http://betterthangrep.com/'
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/asciidoc.rb b/Library/Formula/asciidoc.rb
new file mode 100644
index 000000000..6b53ff83c
--- /dev/null
+++ b/Library/Formula/asciidoc.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class Asciidoc <Formula
+ @url='http://www.methods.co.nz/asciidoc/asciidoc-8.4.4.tar.gz'
+ @md5='579bcd5762b177ee0ddccece8c34724b'
+ @homepage='http://www.methods.co.nz/asciidoc'
+
+ def install
+ system "./configure --disable-debug --prefix='#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/boost.rb b/Library/Formula/boost.rb
new file mode 100644
index 000000000..2022ef952
--- /dev/null
+++ b/Library/Formula/boost.rb
@@ -0,0 +1,16 @@
+require 'brewkit'
+
+class Boost <Formula
+ @homepage='http://www.boost.org'
+ @url='http://kent.dl.sourceforge.net/sourceforge/boost/boost_1_39_0.tar.bz2'
+ @md5='a17281fd88c48e0d866e1a12deecbcc0'
+
+ def install
+ #TODO we can save 6300 links if we just had the intelligence to symlink
+ #the include/boost dir and not more
+
+ # we specify libdir too because the script is apparently broken
+ system "./bootstrap.sh --prefix='#{prefix}' --libdir='#{lib}'"
+ system "./bjam --layout=system --prefix='#{prefix}' --libdir='#{lib}' install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/cmake.rb b/Library/Formula/cmake.rb
new file mode 100644
index 000000000..ee35e3eef
--- /dev/null
+++ b/Library/Formula/cmake.rb
@@ -0,0 +1,13 @@
+require 'brewkit'
+
+class Cmake <Formula
+ @url='http://www.cmake.org/files/v2.6/cmake-2.6.3.tar.gz'
+ @md5='5ba47a94ce276f326abca1fd72a7e7c6'
+
+ def install
+ system "./bootstrap --prefix=#{prefix} --system-libs"
+ system "make install"
+
+ ['man','doc'].each { |d| (prefix+d).mv prefix+'share' }
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/dmd.rb b/Library/Formula/dmd.rb
new file mode 100644
index 000000000..9ad5784be
--- /dev/null
+++ b/Library/Formula/dmd.rb
@@ -0,0 +1,42 @@
+require 'brewkit'
+
+class Dmd <Formula
+ @homepage='http://www.digitalmars.com/d/'
+ @url='http://ftp.digitalmars.com/dmd.1.043.zip'
+ @md5='6c83b7296cb84090a9ebc11ab0fb94a2'
+
+ def doc
+ #use d and not dmd, rationale: meh
+ prefix+'share'+'doc'+'d'
+ end
+
+ def install
+ ohai "install"
+ FileUtils.cp_r 'osx/bin', prefix
+ FileUtils.cp_r 'osx/lib', prefix
+ FileUtils.cp_r 'man/man1', man
+ FileUtils.cp_r 'src', prefix
+
+ #lol
+ man5=man+'man5'
+ man5.mkpath
+ (man+'man1'+'dmd.conf.5').mv man5
+ #lol ends
+
+ html=doc+'html'
+ samples=doc+'examples' #examples is the more typical directory name
+ html.mkpath
+ samples.mkpath
+
+ FileUtils.cp_r Dir['html/d/*'], html unless ARGV.include? '--no-html'
+ FileUtils.cp_r Dir['samples/d/*'], samples unless ARGV.include? '--no-samples'
+
+ # zip files suck TODO FileUtils.chmod
+ Dir.chdir(bin) { `chmod u+x dmd dumpobj obj2asm` }
+
+ (prefix+'bin'+'dmd.conf').open('w') do |f|
+ f.puts "[Environment]"
+ f.puts "DFLAGS=-I#{prefix}/src/phobos -L-L#{prefix}/lib"
+ end
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/fftw.rb b/Library/Formula/fftw.rb
new file mode 100644
index 000000000..e79002fc4
--- /dev/null
+++ b/Library/Formula/fftw.rb
@@ -0,0 +1,21 @@
+require 'brewkit'
+
+class Fftw <Formula
+ @homepage='http://www.fftw.org'
+ @url='http://www.fftw.org/fftw-3.2.1.tar.gz'
+ @md5='712d3f33625a0a76f5758648d4b925f7'
+
+ def install
+ configure=<<-EOS
+ ./configure --enable-shared --disable-debug --prefix='#{prefix}'
+ --enable-threads --enable-single --enable-sse
+ --disable-dependency-tracking
+ --disable-fortran
+ EOS
+ system configure.gsub("\n", ' ').strip.squeeze(' ')
+ system "make install"
+
+ #wtf file?
+ (prefix+'share'+'info'+'dir').unlink
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/git.rb b/Library/Formula/git.rb
new file mode 100644
index 000000000..56cf84e95
--- /dev/null
+++ b/Library/Formula/git.rb
@@ -0,0 +1,20 @@
+require 'brewkit'
+
+class GitManuals <Formula
+ @url='http://kernel.org/pub/software/scm/git/git-manpages-1.6.3.1.tar.bz2'
+ @md5='971d573e8f261feb83290a59728c2b33'
+end
+
+class Git <Formula
+ @url='http://kernel.org/pub/software/scm/git/git-1.6.3.1.tar.bz2'
+ @md5='c1f4aab741359c29f0fbf28563ac7387'
+ @homepage='http://git-scm.com'
+
+ def install
+ # the manuals come separately, well sort of, it's easier this way though
+ GitManuals.new.brew { FileUtils.mv Dir['*'], man }
+
+ system "./configure --prefix='#{prefix}' --disable-debug"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/grc.rb b/Library/Formula/grc.rb
new file mode 100644
index 000000000..87a146567
--- /dev/null
+++ b/Library/Formula/grc.rb
@@ -0,0 +1,70 @@
+require 'brewkit'
+
+def profile_string
+ <<-sput
+################################################################## >> Homebrew
+GRC=`which grc`
+if [ "$TERM" != dumb ] && [ -n GRC ]
+then
+ alias colourify="$GRC -es --colour=auto"
+ alias configure='colourify ./configure'
+ alias diff='colourify diff'
+ alias make='colourify make'
+ alias gcc='colourify gcc'
+ alias g++='colourify g++'
+ alias as='colourify as'
+ alias gas='colourify gas'
+ alias ld='colourify ld'
+ alias netstat='colourify netstat'
+ alias ping='colourify ping'
+ alias traceroute='colourify /usr/sbin/traceroute'
+fi
+################################################################## << Homebrew
+ sput
+end
+
+######################################################################### ARGV
+case ARGV[0]
+ when '--profile' then
+ puts profile_string
+ exit 0
+end
+
+######################################################################### cook
+class Grc <Formula
+ @homepage='http://korpus.juls.savba.sk/~garabik/software/grc.html'
+ @url='http://korpus.juls.savba.sk/~garabik/software/grc/grc_1.1.tar.gz'
+ @md5='eeb612aba2fff14cbaf1f3bec7e1eb60'
+
+ def install
+ ohai "make"
+ #TODO we should deprefixify since it's python and thus possible
+ inreplace 'grc', '/etc', prefix+'etc'
+ inreplace 'grc.1', '/etc', prefix+'etc'
+ inreplace 'grcat', '/usr/local', prefix
+ inreplace 'grcat.1', '/usr/local', prefix
+
+ FileUtils.mkpath prefix
+ Dir.chdir prefix do
+ FileUtils.mkpath 'bin'
+ FileUtils.mkpath 'share/grc'
+ FileUtils.mkpath 'share/man/man1'
+ FileUtils.mkpath 'etc'
+ end
+
+ `cp -fv grc grcat #{prefix}/bin`
+ `cp -fv conf.* #{prefix}/share/grc`
+ `cp -fv grc.conf #{prefix}/etc`
+ `cp -fv grc.1 grcat.1 #{prefix}/share/man/man1`
+ end
+
+ def caveats
+ <<-EOS
+ grc won't work as is. One option is to add some aliases to your ~/.profile
+ file. Homebrew can do that for you, just execute this command:
+
+ brew grc --profile >> ~/.profile
+
+ EOS
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/lame.rb b/Library/Formula/lame.rb
new file mode 100644
index 000000000..2c248285c
--- /dev/null
+++ b/Library/Formula/lame.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class Lame <Formula
+ @homepage='http://lame.sourceforge.net/'
+ @url='http://kent.dl.sourceforge.net/sourceforge/lame/lame-398-2.tar.gz'
+ @md5='719dae0ee675d0c16e0e89952930ed35'
+
+ def install
+ system "./configure --disable-debug --prefix='#{prefix}' --enable-nasm"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/liblastfm.rb b/Library/Formula/liblastfm.rb
new file mode 100644
index 000000000..6f2b6a375
--- /dev/null
+++ b/Library/Formula/liblastfm.rb
@@ -0,0 +1,19 @@
+require 'brewkit'
+
+class Liblastfm <Formula
+ @homepage='http://github.com/mxcl/liblastfm/'
+ @url='http://static.last.fm/src/liblastfm-0.3.0.tar.bz2'
+ @md5='3f73222ebc31635941832b01e7a494b6'
+
+ def deps
+ dep_test_bin 'qmake' or 'qt'
+ dep_test_lib 'fftw3f' or 'fftw'
+ dep_test_lib 'samplerate' or 'libsamplerate'
+ end
+
+ def install
+ system "./configure --release --prefix '#{prefix}'"
+ system "make"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/libogg.rb b/Library/Formula/libogg.rb
new file mode 100644
index 000000000..178835342
--- /dev/null
+++ b/Library/Formula/libogg.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class Libogg <Formula
+ @homepage='http://www.xiph.org/ogg/'
+ @url='http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz'
+ @md5='eaf7dc6ebbff30975de7527a80831585'
+
+ def install
+ system "./configure --disable-debug --prefix='#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/libsamplerate.rb b/Library/Formula/libsamplerate.rb
new file mode 100644
index 000000000..d6dedc6c7
--- /dev/null
+++ b/Library/Formula/libsamplerate.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class Libsamplerate <Formula
+ @homepage='http://www.mega-nerd.com/SRC'
+ @url='http://www.mega-nerd.com/SRC/libsamplerate-0.1.7.tar.gz'
+ @md5='ad093e60ec44f0a60de8e29983ddbc0f'
+
+ def install
+ system "./configure --disable-debug --prefix='#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/mad.rb b/Library/Formula/mad.rb
new file mode 100644
index 000000000..0bbcab8f9
--- /dev/null
+++ b/Library/Formula/mad.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class Mad <Formula
+ @homepage='http://www.underbit.com/products/mad/'
+ @url='http://kent.dl.sourceforge.net/sourceforge/mad/libmad-0.15.1b.tar.gz'
+ @md5='1be543bc30c56fb6bea1d7bf6a64e66c'
+
+ def install
+ system "./configure --disable-debugging --enable-fpm=intel --prefix='#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/pkg-config.rb b/Library/Formula/pkg-config.rb
new file mode 100644
index 000000000..9254c5a65
--- /dev/null
+++ b/Library/Formula/pkg-config.rb
@@ -0,0 +1,14 @@
+require 'brewkit'
+
+class PkgConfig <Formula
+ @homepage='http://pkgconfig.freedesktop.org'
+ @url='http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz'
+ @md5='d922a88782b64441d06547632fd85744'
+
+ #TODO depend on our glib? --with-installed-glib
+
+ def install
+ system "./configure --with-pc-path=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:#{$root}/lib/pkgconfig --disable-debug --prefix='#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/pngcrush.rb b/Library/Formula/pngcrush.rb
new file mode 100644
index 000000000..00a889403
--- /dev/null
+++ b/Library/Formula/pngcrush.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class Pngcrush <Formula
+ @homepage='http://pmt.sourceforge.net/pngcrush/'
+ @url='http://kent.dl.sourceforge.net/sourceforge/pmt/pngcrush-1.6.17.tar.bz2'
+ @md5='8ba31ae9b1b14e7648df320fd1ed27c7'
+
+ def install
+ system "make"
+ FileUtils.cp 'pngcrush', bin
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/qt.rb b/Library/Formula/qt.rb
new file mode 100644
index 000000000..9ce82d600
--- /dev/null
+++ b/Library/Formula/qt.rb
@@ -0,0 +1,43 @@
+require 'brewkit'
+
+class Qt <Formula
+ @url='http://get.qtsoftware.com/qt/source/qt-mac-opensource-src-4.5.1.tar.gz'
+ @md5='9fc0e96197df6db48a0628ac4d63e0dd'
+ @homepage='http://www.qtsoftware.com'
+
+ def install
+ if version == '4.5.1'
+ # Reported 6 months ago (at 4.5.0-rc1), still not fixed in the this release! :(
+ makefiles=['plugins/sqldrivers/sqlite/sqlite.pro', '3rdparty/webkit/WebCore/WebCore.pro']
+ makefiles.each { |makefile| `echo 'LIBS += -lsqlite3' >> src/#{makefile}` }
+ end
+
+ configure=<<-EOS
+ ./configure -prefix '#{prefix}'
+ -system-sqlite -system-libpng -system-zlib
+ -nomake demos -nomake examples -no-qt3support
+ -release -cocoa -arch x86
+ -confirm-license -opensource
+ -I /usr/X11R6/include -L /usr/X11R6/lib
+ -fast
+ EOS
+
+ system configure.gsub("\n", ' ').strip.squeeze(' ')
+ system "make install"
+
+ # fuck weird prl files
+ `find #{lib} -name \*.prl -delete`
+ # fuck crazy disk usage
+ `rm -r #{prefix+'doc'+'html'} #{prefix+'doc'+'src'}`
+ # wtf are these anyway?
+ `rm -r #{bin}/Assistant_adp.app #{bin}/pixeltool.app #{bin}/qhelpconverter.app`
+ # we specified no debug already! :P
+ `rm #{lib}/libQtUiTools_debug.a`
+ # meh
+ `rm #{prefix}/q3porting.xml`
+ end
+
+ def caveats
+ "We agreed to the Qt opensource license for you.\nIf this is unacceptable you should uninstall :P"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/taglib.rb b/Library/Formula/taglib.rb
new file mode 100644
index 000000000..2811decec
--- /dev/null
+++ b/Library/Formula/taglib.rb
@@ -0,0 +1,12 @@
+require 'brewkit'
+
+class Taglib <Formula
+ @url='http://developer.kde.org/~wheeler/files/src/taglib-1.5.tar.gz'
+ @md5='7b557dde7425c6deb7bbedd65b4f2717'
+ @homepage='http://developer.kde.org/~wheeler/taglib.html'
+
+ def install
+ system "./configure --disable-debug --prefix='#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/term.rb b/Library/Formula/term.rb
new file mode 100644
index 000000000..427d3607a
--- /dev/null
+++ b/Library/Formula/term.rb
@@ -0,0 +1,10 @@
+require 'brewkit'
+
+class Term <UncompressedScriptFormula
+ def initialize
+ @url='http://github.com/liyanage/macosx-shell-scripts/raw/e29f7eaa1eb13d78056dec85dc517626ab1d93e3/term'
+ @md5='1bbf4509a50224b27ac8c20d3fe8682e'
+ @version='2.1'
+ @homepage='http://gist.github.com/116587'
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/wget.rb b/Library/Formula/wget.rb
new file mode 100644
index 000000000..2ba5722e0
--- /dev/null
+++ b/Library/Formula/wget.rb
@@ -0,0 +1,13 @@
+require 'brewkit'
+
+class Wget <Formula
+ @homepage='http://www.gnu.org/software/wget/'
+ @url='http://ftp.gnu.org/gnu/wget/wget-1.11.4.tar.bz2'
+ @md5='f5076a8c2ec2b7f334cb6e3059820f9c'
+
+ def install
+ system "./configure --disable-debug --prefix='#{prefix}'"
+ system "make"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/xmlrpc-c.rb b/Library/Formula/xmlrpc-c.rb
new file mode 100644
index 000000000..27d6f3a1e
--- /dev/null
+++ b/Library/Formula/xmlrpc-c.rb
@@ -0,0 +1,16 @@
+require 'brewkit'
+
+class XmlrpcC <Formula
+ @url='http://kent.dl.sourceforge.net/sourceforge/xmlrpc-c/xmlrpc-c-1.06.33.tgz'
+ @md5='7dda4d8c5d26ae877d3809e428ce7962'
+ @homepage='http://xmlrpc-c.sourceforge.net/'
+
+ def install
+ ENV['MAKEFLAGS']='' #parallel build doesn't work
+ # choosing --enable-libxml2-backend to lose some weight and not statically
+ # link in expat
+ #NOTE seemingly it isn't possible to build dylibs with this thing
+ system "./configure --disable-debug --enable-libxml2-backend --prefix='#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Formula/yajl.rb b/Library/Formula/yajl.rb
new file mode 100644
index 000000000..f72432dda
--- /dev/null
+++ b/Library/Formula/yajl.rb
@@ -0,0 +1,21 @@
+require 'brewkit'
+
+class Yajl <Formula
+ @homepage='http://lloyd.github.com/yajl/'
+ @url='http://github.com/lloyd/yajl/tarball/1.0.5'
+ @md5='f4a3cbc764c43231ed1aedc54438b69b'
+
+ def deps
+ dep_test_bin 'cmake'
+ end
+
+ def install
+ ENV['MAKEFLAGS']='' # can't do parallel builds
+
+ # I have pushed this fix upstream
+ inreplace 'configure', 'cmake \.\.', "cmake -DCMAKE_INSTALL_PREFIX='#{prefix}' \.\." if @version == "1.0.5"
+
+ system "./configure --prefix '#{prefix}'"
+ system "make install"
+ end
+end \ No newline at end of file
diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb
new file mode 100644
index 000000000..8ca71d332
--- /dev/null
+++ b/Library/Homebrew/brewkit.rb
@@ -0,0 +1,359 @@
+# Copyright 2009 Max Howell <max@methylblue.com>
+#
+# This file is part of Homebrew.
+#
+# Homebrew is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Homebrew is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
+
+require 'pathname'
+require 'osx/cocoa' # to get number of cores
+require "#{File.dirname __FILE__}/env"
+
+HOMEBREW_VERSION='0.1'
+
+# optimise all the way to eleven, references:
+# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
+# http://forums.mozillazine.org/viewtopic.php?f=12&t=577299
+# http://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/i386-and-x86_002d64-Options.html
+ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
+ENV['CFLAGS']=ENV['CXXFLAGS']='-O3 -w -pipe -fomit-frame-pointer -march=prescott'
+
+# lets use gcc 4.2, it is newer and "better", at least I believe so, mail me
+# if I'm wrong
+ENV['CC']='gcc-4.2'
+ENV['CXX']='g++-4.2'
+ENV['MAKEFLAGS']="-j#{OSX::NSProcessInfo.processInfo.processorCount}"
+
+unless $root.to_s == '/usr/local'
+ ENV['CPPFLAGS']='-I'+$root+'include'
+ ENV['LDFLAGS']='-L'+$root+'lib'
+end
+
+
+def ohai title
+ n=`tput cols`.strip.to_i-4
+ puts "\033[0;34m==>\033[0;0;1m #{title[0,n]}\033[0;0m"
+end
+
+def appsupport
+ appsupport = File.expand_path "~/Library/Application Support/Homebrew"
+ FileUtils.mkpath appsupport unless File.exist? appsupport
+ return appsupport
+end
+
+
+# make our code neater
+class Pathname
+ def mv dst
+ FileUtils.mv to_s, dst
+ end
+ def cp dst
+ if file?
+ FileUtils.cp to_s, dst
+ else
+ FileUtils.cp_r to_s, dst
+ end
+ end
+end
+
+
+class Formula
+ require 'find'
+ require 'fileutils'
+
+ # fuck knows, ruby is weird
+ def self.url
+ @url
+ end
+ def url
+ self.class.url
+ end
+ def self.md5
+ @md5
+ end
+ def md5
+ self.class.md5
+ end
+ def self.homepage
+ @homepage
+ end
+ def homepage
+ self.class.homepage
+ end
+ # end ruby is weird section
+
+ def initialize
+ # fuck knows, ruby is weird
+ @url=url if @url.nil?
+ raise "@url.nil?" if @url.nil?
+ @md5=md5 if @md5.nil?
+ # end ruby is weird section
+
+ # pls improve this version extraction crap
+ filename=File.basename @url
+ i=filename.index /[-_]\d/
+ unless i.nil?
+ /^((\d+[._])*(\d+-)?\d+[abc]?)/.match filename[i+1,1000] #1000 because rubysucks
+ @version=$1
+ # if there are no dots replace underscores, boost do this, the bastards!
+ @version.gsub!('_', '.') unless @version.include? '.'
+ else
+ # no divisor or a '.' divisor, eg. dmd.1.11.zip
+ /^[a-zA-Z._-]*((\d+\.)*\d+)/.match filename
+ @version = $1
+ end
+ end
+
+private
+ def maybe_mkpath path
+ path.mkpath unless path.exist?
+ return path
+ end
+
+public
+ def prefix
+ raise "@name.nil!" if @name.nil?
+ raise "@version.nil?" if @version.nil?
+ $cellar+@name+@version
+ end
+ def bin
+ maybe_mkpath prefix+'bin'
+ end
+ def doc
+ maybe_mkpath prefix+'share'+'doc'+name
+ end
+ def man
+ maybe_mkpath prefix+'share'+'man'
+ end
+ def lib
+ maybe_mkpath prefix+'lib'
+ end
+ def include
+ maybe_mkpath prefix+'include'
+ end
+
+ def name=name
+ raise "Name assigned twice, I'm not letting you do that!" if @name
+ @name=name
+ end
+
+protected
+ def caveats
+ nil
+ end
+
+public
+ #yields a Pathname object for the installation prefix
+ def brew
+ # disabled until the regexp makes sense :P
+ #raise "@name does not validate to our regexp" unless /^\w+$/ =~ @name
+
+ ohai "Downloading #{@url}"
+
+ Dir.chdir appsupport do
+ tgz=Pathname.new(fetch()).realpath
+ md5=`md5 -q "#{tgz}"`.strip
+ raise "MD5 mismatch: #{md5}" unless md5 and md5 == @md5.downcase
+
+ # we make an additional subdirectory so know exactly what we are
+ # recursively deleting later
+ # we use mktemp rather than appsupport/blah because some build scripts
+ # can't handle being built in a directory with spaces in it :P
+ tmp=nil
+ begin
+ tmp=`mktemp -dt #{File.basename @url}`.strip
+ Dir.chdir tmp do
+ Dir.chdir uncompress(tgz) do
+ yield self
+ if caveats
+ ohai "Caveats"
+ puts caveats
+ end
+ #TODO copy changelog or CHANGES file to pkg root,
+ #TODO maybe README, etc. to versioned root
+ end
+ end
+ rescue Interrupt, RuntimeError
+ if ARGV.include? '--debug'
+ # debug mode allows the packager to intercept a failed build and
+ # investigate the problems
+ puts "Rescued build at: #{tmp}"
+ exit! 1
+ else
+ FileUtils.rm_rf prefix
+ raise
+ end
+ ensure
+ FileUtils.rm_rf tmp if tmp
+ FileUtils.rm tgz if tgz and not self.cache?
+ end
+ end
+ end
+
+ def clean
+ prefix.find do |path|
+ if path==prefix #rubysucks
+ next
+ elsif path.file?
+ if path.extname == '.la'
+ path.unlink
+ else
+ fo=`file -h #{path}`
+ args=nil
+ args='-SxX' if fo =~ /Mach-O dynamically linked shared library/
+ args='' if fo =~ /Mach-O executable/ #defaults strip everything
+ if args
+ puts "Stripping: #{path}" if ARGV.include? '--verbose'
+ `strip #{args} #{path}`
+ end
+ end
+ elsif path.directory? and path!=prefix+'bin' and path!=prefix+'lib'
+ Find.prune
+ end
+ end
+ end
+
+ def version
+ @version
+ end
+ def name
+ @name
+ end
+
+protected
+ def fetch
+ %r[http://(www.)?github.com/.*/(zip|tar)ball/].match @url
+ if $2
+ # curl doesn't do the redirect magic that we would like, so we get a
+ # stupidly named file, this is why wget would be beter, but oh well
+ tgz="#{@name}-#{@version}.#{$2=='tar' ? 'tgz' : $2}"
+ oarg="-o #{tgz}"
+ else
+ oarg='-O' #use the filename that curl gets
+ tgz=File.expand_path File.basename(@url)
+ end
+
+ agent="Homebrew #{HOMEBREW_VERSION} (Ruby #{VERSION}; Mac OS X 10.5 Leopard)"
+
+ unless File.exists? tgz
+ `curl -#LA "#{agent}" #{oarg} "#{@url}"`
+ raise "Download failed" unless $? == 0
+ else
+ puts "File already downloaded and cached"
+ end
+ return tgz
+ end
+
+ def uncompress(path)
+ if path.extname == '.zip'
+ `unzip -qq "#{path}"`
+ else
+ `tar xf "#{path}"`
+ end
+
+ raise "Compression tool failed" if $? != 0
+
+ entries=Dir['*']
+ if entries.nil? or entries.length == 0
+ raise "Empty tarball!"
+ elsif entries.length == 1
+ # if one dir enter it as that will be where the build is
+ entries.first
+ else
+ # if there's more than one dir, then this is the build directory already
+ Dir.pwd
+ end
+ end
+
+ def cache?
+ true
+ end
+
+private
+ def method_added(method)
+ raise 'You cannot override Formula.brew' if method == 'brew'
+ end
+end
+
+# see ack.rb for an example usage
+class UncompressedScriptFormula <Formula
+ def uncompress path
+ path.dirname
+ end
+ def cache?
+ false
+ end
+ def install
+ FileUtils.cp name, bin
+ (bin+name).chmod 0544
+ end
+end
+
+class GithubGistFormula <Formula
+ def initialize(url, md5)
+ @url=url
+ @name=File.basename url
+ @version=File.basename(File.dirname(url))[0,6]
+ @md5=md5
+
+ brew do |prefix|
+ bin=prefix+'bin'
+ bin.mkpath
+ FileUtils.cp @name, bin
+ (bin+@name).chmod 0544
+ nil
+ end
+ end
+
+ def uncompress path
+ path.dirname
+ end
+end
+
+def inreplace(path, before, after)
+ before=before.to_s.gsub('"', '\"').gsub('/', '\/')
+ after=after.to_s.gsub('"', '\"').gsub('/', '\/')
+
+ # we're not using Ruby because the perl script is more concise
+ #TODO the above escapes are worse, use a proper ruby script :P
+ #TODO optimise it by taking before and after as arrays
+ #Bah, just make the script writers do it themselves with a standard collect block
+ #TODO use ed -- less to escape
+ `perl -pi -e "s/#{before}/#{after}/g" "#{path}"`
+end
+
+def system cmd
+ ohai cmd
+
+ out=''
+ IO.popen("#{cmd} 2>&1") do |f|
+ until f.eof?
+ s=f.gets
+ out+=s
+ puts s if ARGV.include? '--verbose'
+ end
+ end
+
+ unless $? == 0
+ puts out unless ARGV.include? '--verbose' #already did that above
+ raise "Failure during: #{cmd}"
+ end
+end
+
+########################################################################script
+if $0 == __FILE__
+ d=$cellar.parent+'bin'
+ d.mkpath unless d.exist?
+ Dir.chdir d
+ Pathname.new('brew').make_symlink Pathname.new('../Cellar')+'homebrew'+'brew'
+end \ No newline at end of file
diff --git a/Library/Homebrew/env.rb b/Library/Homebrew/env.rb
new file mode 100644
index 000000000..e1beac1c1
--- /dev/null
+++ b/Library/Homebrew/env.rb
@@ -0,0 +1,22 @@
+# Copyright 2009 Max Howell <max@methylblue.com>
+#
+# This file is part of Homebrew.
+#
+# Homebrew is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Homebrew is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
+
+require 'pathname'
+
+$root=Pathname.new(__FILE__).dirname.parent.parent.realpath
+$formula=$root+'Library'+'Formula'
+$cellar=$root+'Cellar' \ No newline at end of file
diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb
new file mode 100755
index 000000000..5ec8f0e5d
--- /dev/null
+++ b/Library/Homebrew/unittest.rb
@@ -0,0 +1,72 @@
+#!/usr/bin/ruby
+require 'test/unit'
+require "#{__FILE__}/../brewkit"
+
+class TestFormula <Formula
+ def initialize url, md5
+ @url=url
+ @md5=md5
+ @name='test'
+ super()
+ end
+end
+
+
+class BeerTasting <Test::Unit::TestCase
+ def test_version_all_dots
+ r=TestFormula.new "http://example.com/foo.bar.la.1.14.zip", 'nomd5'
+ assert_equal '1.14', r.version
+ end
+
+ def test_version_underscore_separator
+ r=TestFormula.new "http://example.com/grc_1.1.tar.gz", 'nomd5'
+ assert_equal '1.1', r.version
+ end
+
+ def test_version_underscores_all_the_way
+ r=TestFormula.new "http://example.com/boost_1_39_0.tar.bz2", 'nomd5'
+ assert_equal '1.39.0', r.version
+ end
+
+ def test_version_internal_dash
+ r=TestFormula.new "http://example.com/foo-arse-1.1-2.tar.gz", 'nomd5'
+ assert_equal '1.1-2', r.version
+ end
+
+ def test_version_single_digit
+ r=TestFormula.new "http://example.com/foo_bar.45.tar.gz", 'nomd5'
+ assert_equal '45', r.version
+ end
+
+ def test_noseparator_single_digit
+ r=TestFormula.new "http://example.com/foo_bar45.tar.gz", 'nomd5'
+ assert_equal '45', r.version
+ end
+
+ def test_version_developer_that_hates_us_format
+ r=TestFormula.new "http://example.com/foo-bar-la.1.2.3.tar.gz", 'nomd5'
+ assert_equal '1.2.3', r.version
+ end
+
+ def test_version_regular
+ r=TestFormula.new "http://example.com/foo_bar-1.21.tar.gz", 'nomd5'
+ assert_equal '1.21', r.version
+ end
+
+ def test_yet_another_version
+ r=TestFormula.new "http://example.com/mad-0.15.1b.tar.gz", 'nomd5'
+ assert_equal '0.15.1b', r.version
+ end
+
+ def test_prefix
+ url='http://www.methylblue.com/test-0.1.tar.gz'
+ md5='d496ea538a21dc4bb8524a8888baf88c'
+
+ TestFormula.new(url, md5).brew do |f|
+ prefix=f.prefix
+ # we test for +/unittest/0.1 because we derive @name from $0
+ assert_equal File.expand_path(prefix), ($cellar+'test'+'0.1').to_s
+ assert_kind_of Pathname, prefix
+ end
+ end
+end \ No newline at end of file