mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Prettier command output
Absorb stdout unless --verbose is specified
This commit is contained in:
parent
bbee88869a
commit
bab81f6d00
@ -1,14 +1,20 @@
|
|||||||
# Copyright 2009 Max Howell <max@methylblue.com>
|
# Copyright 2009 Max Howell <max@methylblue.com>
|
||||||
# Licensed as per the GPL version 3
|
# Licensed as per the GPL version 3
|
||||||
require 'find'
|
require 'find'
|
||||||
require 'pathname'
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
|
require 'pathname'
|
||||||
|
|
||||||
$agent = "Homebrew 0.1 (Ruby; Mac OS X 10.5 Leopard)"
|
$agent = "Homebrew 0.1 (Ruby; Mac OS X 10.5 Leopard)"
|
||||||
$cellar = Pathname.new(__FILE__).dirname.parent.realpath
|
$cellar = Pathname.new(__FILE__).dirname.parent.realpath
|
||||||
|
|
||||||
ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
|
ENV['MACOSX_DEPLOYMENT_TARGET']='10.5'
|
||||||
ENV['CFLAGS']=ENV['CXXFLAGS']='-O3 -w'
|
ENV['CFLAGS']=ENV['CXXFLAGS']='-O3 -w'
|
||||||
|
|
||||||
|
def h1 title
|
||||||
|
puts "\033[0;34m==>\033[0;0;1m #{title} \033[0;0m"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
class Formula
|
class Formula
|
||||||
# if you reimplement, assign @name, @version, @url and @md5
|
# if you reimplement, assign @name, @version, @url and @md5
|
||||||
def initialize(url, md5)
|
def initialize(url, md5)
|
||||||
@ -38,10 +44,12 @@ class Formula
|
|||||||
prefix=$cellar+@name+@version
|
prefix=$cellar+@name+@version
|
||||||
raise "#{prefix} already exists!" if prefix.exist?
|
raise "#{prefix} already exists!" if prefix.exist?
|
||||||
|
|
||||||
|
h1 "Preparing build"
|
||||||
|
|
||||||
appsupport = File.expand_path "~/Library/Application Support/Homebrew"
|
appsupport = File.expand_path "~/Library/Application Support/Homebrew"
|
||||||
FileUtils.mkpath appsupport unless File.exist? appsupport
|
FileUtils.mkpath appsupport unless File.exist? appsupport
|
||||||
Dir.chdir appsupport do
|
Dir.chdir appsupport do
|
||||||
tgz=Pathname.new self.fetch
|
tgz=Pathname.new fetch()
|
||||||
raise "MD5 mismatch" unless `md5 -q "#{tgz}"`.strip == @md5.downcase
|
raise "MD5 mismatch" unless `md5 -q "#{tgz}"`.strip == @md5.downcase
|
||||||
|
|
||||||
# we make an additional subdirectory so know exactly what we are
|
# 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.
|
# stay in appsupport in case any odd files gets created etc.
|
||||||
`#{$cellar}/homebrew/brew ln #{prefix}` if prefix.exist?
|
`#{$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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -110,6 +118,24 @@ def inreplace(path, before, after)
|
|||||||
`perl -pi -e "s|#{before}|#{after}|g" "#{path}"`
|
`perl -pi -e "s|#{before}|#{after}|g" "#{path}"`
|
||||||
end
|
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
|
########################################################################script
|
||||||
if $0 == __FILE__
|
if $0 == __FILE__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user