From fb5aefd4a053d718637ea8690c6eeba2d6e56008 Mon Sep 17 00:00:00 2001
From: Max Howell
Date: Fri, 24 Jul 2009 15:10:01 +0100
Subject: Refactor--object orientate where sensible
---
Library/Homebrew/brewkit.rb | 371 +-------------------------------------------
1 file changed, 3 insertions(+), 368 deletions(-)
(limited to 'Library/Homebrew/brewkit.rb')
diff --git a/Library/Homebrew/brewkit.rb b/Library/Homebrew/brewkit.rb
index a32f015d5..f5d819f1b 100644
--- a/Library/Homebrew/brewkit.rb
+++ b/Library/Homebrew/brewkit.rb
@@ -15,9 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with Homebrew. If not, see .
-require 'pathname'
require 'osx/cocoa' # to get number of cores
-require 'env'
+require 'formula'
# optimise all the way to eleven, references:
# http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel
@@ -38,343 +37,7 @@ unless $root.to_s == '/usr/local'
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 cache
- cache=File.expand_path "~/Library/Caches/Homebrew"
- FileUtils.mkpath cache
- return cache
-end
-
-class BuildError 1
- `strip #{args} #{path}`
- else
- # strip unlinks the file and recreates it, thus breaking hard links!
- # is this expected behaviour? patch does it too… still,mktm this fixes it
- tmp=`mktemp -t #{path.basename}`.strip
- `strip -o #{tmp} #{path}`
- `cat #{tmp} > #{path}`
- File.unlink tmp
- end
- end
- path.chmod perms
- end
- end}
-
- # remove empty directories
- `perl -MFile::Find -e"finddepth(sub{rmdir},'#{prefix}')"`
- end
-
-protected
- def uncompress path
- path.dirname
- end
-
-private
- 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 method_added method
- raise 'You cannot override Formula.brew' if method == 'brew'
- end
-end
-
-# somewhat useful, it'll raise if you call prefix, but it'll unpack a tar/zip
-# for you, check the md5, and allow you to yield from brew
-class UnidentifiedFormula &1") do |f|
- until f.eof?
- s=f.gets
- if ARGV.include? '--verbose'
- puts s
- else
- out+=s
- end
- end
- end
-
- unless $? == 0
- puts out unless ARGV.include? '--verbose' #already did that above
- raise BuildError.new(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
--
cgit v1.2.3