Generate logs in verbose mode

Closes Homebrew/homebrew#23654.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Stefan 2013-10-27 07:05:13 +01:00 committed by Jack Nagel
parent 643469a17c
commit 71f0ad069d

View File

@ -567,40 +567,39 @@ class Formula
ENV.remove_cc_etc ENV.remove_cc_etc
end end
if ARGV.verbose? @exec_count ||= 0
safe_system cmd, *args @exec_count += 1
else logd = HOMEBREW_LOGS/name
@exec_count ||= 0 logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd.to_s).split(' ').first]
@exec_count += 1 mkdir_p(logd)
logd = HOMEBREW_LOGS/name
logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd.to_s).split(' ').first]
mkdir_p(logd)
rd, wr = IO.pipe rd, wr = IO.pipe
fork do fork do
rd.close rd.close
$stdout.reopen wr $stdout.reopen wr
$stderr.reopen wr $stderr.reopen wr
args.collect!{|arg| arg.to_s} args.collect!{|arg| arg.to_s}
exec(cmd.to_s, *args) rescue nil exec(cmd.to_s, *args) rescue nil
puts "Failed to execute: #{cmd}" puts "Failed to execute: #{cmd}"
exit! 1 # never gets here unless exec threw or failed exit! 1 # never gets here unless exec threw or failed
end
wr.close
File.open(logfn, 'w') do |f|
while buf = rd.gets
f.puts buf
puts buf if ARGV.verbose?
end end
wr.close
File.open(logfn, 'w') do |f| Process.wait
f.write(rd.read) until rd.eof?
Process.wait unless $?.success?
f.flush
unless $?.success? Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose?
f.flush f.puts
Kernel.system "/usr/bin/tail", "-n", "5", logfn require 'cmd/--config'
f.puts Homebrew.write_build_config(f)
require 'cmd/--config' raise ErrorDuringExecution
Homebrew.write_build_config(f)
raise ErrorDuringExecution
end
end end
end end
rescue ErrorDuringExecution rescue ErrorDuringExecution