aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Howell2009-05-21 02:24:45 +0100
committerMax Howell2009-05-21 02:24:45 +0100
commitbab81f6d00ae1298c33162475f2aebb04b0b1c66 (patch)
tree1dc2ef49269f9e9362c07eca571033b5a15d2c17
parentbbee88869a550656de8a288a456a5cb3a9c4a7f7 (diff)
downloadbrew-bab81f6d00ae1298c33162475f2aebb04b0b1c66.tar.bz2
Prettier command output
Absorb stdout unless --verbose is specified
-rw-r--r--Cellar/homebrew/brewkit.rb32
1 files changed, 29 insertions, 3 deletions
diff --git a/Cellar/homebrew/brewkit.rb b/Cellar/homebrew/brewkit.rb
index d4b828b66..98aaec14e 100644
--- a/Cellar/homebrew/brewkit.rb
+++ b/Cellar/homebrew/brewkit.rb
@@ -1,14 +1,20 @@
# Copyright 2009 Max Howell <max@methylblue.com>
# Licensed as per the GPL version 3
require 'find'
-require 'pathname'
require 'fileutils'
+require 'pathname'
+
$agent = "Homebrew 0.1 (Ruby; Mac OS X 10.5 Leopard)"
$cellar = Pathname.new(__FILE__).dirname.parent.realpath
ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
ENV['CFLAGS']=ENV['CXXFLAGS']='-O3 -w'
+def h1 title
+ puts "\033[0;34m==>\033[0;0;1m #{title} \033[0;0m"
+end
+
+
class Formula
# if you reimplement, assign @name, @version, @url and @md5
def initialize(url, md5)
@@ -38,10 +44,12 @@ class Formula
prefix=$cellar+@name+@version
raise "#{prefix} already exists!" if prefix.exist?
+ h1 "Preparing build"
+
appsupport = File.expand_path "~/Library/Application Support/Homebrew"
FileUtils.mkpath appsupport unless File.exist? appsupport
Dir.chdir appsupport do
- tgz=Pathname.new self.fetch
+ tgz=Pathname.new fetch()
raise "MD5 mismatch" unless `md5 -q "#{tgz}"`.strip == @md5.downcase
# we make an additional subdirectory so know exactly what we are
@@ -65,7 +73,7 @@ class Formula
# stay in appsupport in case any odd files gets created etc.
`#{$cellar}/homebrew/brew ln #{prefix}` if prefix.exist?
- puts "#{prefix}: "+`find #{prefix} | wc -l`.strip+' files, '+`du -hd0 #{prefix} | cut -d"\t" -f1`.strip
+ puts "#{prefix}: "+`find #{prefix} -type f | wc -l`.strip+' files, '+`du -hd0 #{prefix} | cut -d"\t" -f1`.strip
end
end
@@ -110,6 +118,24 @@ def inreplace(path, before, after)
`perl -pi -e "s|#{before}|#{after}|g" "#{path}"`
end
+def system cmd
+ h1 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__