Add Formula#logs
This commit is contained in:
parent
f5d6d80d5b
commit
16dfe3dd40
@ -6,7 +6,7 @@ require 'stringio'
|
|||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def gistify_logs f
|
def gistify_logs f
|
||||||
files = load_logs(f.name)
|
files = load_logs(f.logs)
|
||||||
|
|
||||||
s = StringIO.new
|
s = StringIO.new
|
||||||
Homebrew.dump_verbose_config(s)
|
Homebrew.dump_verbose_config(s)
|
||||||
@ -58,9 +58,8 @@ module Homebrew
|
|||||||
request.basic_auth(user, password)
|
request.basic_auth(user, password)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_logs name
|
def load_logs(dir)
|
||||||
logs = {}
|
logs = {}
|
||||||
dir = HOMEBREW_LOGS/name
|
|
||||||
dir.children.sort.each do |file|
|
dir.children.sort.each do |file|
|
||||||
contents = file.size? ? file.read : "empty log"
|
contents = file.size? ? file.read : "empty log"
|
||||||
logs[file.basename.to_s] = { :content => contents }
|
logs[file.basename.to_s] = { :content => contents }
|
||||||
|
|||||||
@ -18,9 +18,8 @@ module Homebrew
|
|||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
logd = HOMEBREW_LOGS/formula.name
|
formula.logs.mkpath
|
||||||
logd.mkpath
|
sandbox.record_log(formula.logs/"sandbox.postinstall.log")
|
||||||
sandbox.record_log(logd/"sandbox.postinstall.log")
|
|
||||||
sandbox.allow_write_temp_and_cache
|
sandbox.allow_write_temp_and_cache
|
||||||
sandbox.allow_write_log(formula)
|
sandbox.allow_write_log(formula)
|
||||||
sandbox.allow_write_cellar(formula)
|
sandbox.allow_write_cellar(formula)
|
||||||
|
|||||||
@ -38,9 +38,8 @@ module Homebrew
|
|||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
logd = HOMEBREW_LOGS/f.name
|
formula.logs.mkpath
|
||||||
logd.mkpath
|
sandbox.record_log(formula.logs/"sandbox.test.log")
|
||||||
sandbox.record_log(logd/"sandbox.test.log")
|
|
||||||
sandbox.allow_write_temp_and_cache
|
sandbox.allow_write_temp_and_cache
|
||||||
sandbox.allow_write_log(f)
|
sandbox.allow_write_log(f)
|
||||||
sandbox.exec(*args)
|
sandbox.exec(*args)
|
||||||
|
|||||||
@ -175,7 +175,7 @@ class BuildError < RuntimeError
|
|||||||
Homebrew.dump_build_env(env)
|
Homebrew.dump_build_env(env)
|
||||||
puts
|
puts
|
||||||
onoe "#{formula.name} #{formula.version} did not build"
|
onoe "#{formula.name} #{formula.version} did not build"
|
||||||
unless (logs = Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]).empty?
|
unless (logs = Dir["#{formula.logs}/*"]).empty?
|
||||||
puts "Logs:"
|
puts "Logs:"
|
||||||
puts logs.map{|fn| " #{fn}"}.join("\n")
|
puts logs.map{|fn| " #{fn}"}.join("\n")
|
||||||
end
|
end
|
||||||
|
|||||||
@ -410,6 +410,10 @@ class Formula
|
|||||||
# there after pouring a bottle.
|
# there after pouring a bottle.
|
||||||
def bottle_prefix; prefix+'.bottle' end
|
def bottle_prefix; prefix+'.bottle' end
|
||||||
|
|
||||||
|
def logs
|
||||||
|
HOMEBREW_LOGS+name
|
||||||
|
end
|
||||||
|
|
||||||
# override this to provide a plist
|
# override this to provide a plist
|
||||||
def plist; nil; end
|
def plist; nil; end
|
||||||
alias :startup_plist :plist
|
alias :startup_plist :plist
|
||||||
@ -510,7 +514,7 @@ class Formula
|
|||||||
begin
|
begin
|
||||||
yield self
|
yield self
|
||||||
ensure
|
ensure
|
||||||
cp Dir["config.log", "CMakeCache.txt"], HOMEBREW_LOGS+name
|
cp Dir["config.log", "CMakeCache.txt"], logs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -790,9 +794,8 @@ class Formula
|
|||||||
|
|
||||||
@exec_count ||= 0
|
@exec_count ||= 0
|
||||||
@exec_count += 1
|
@exec_count += 1
|
||||||
logd = HOMEBREW_LOGS/name
|
logfn = "#{logs}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
|
||||||
logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
|
logs.mkpath
|
||||||
mkdir_p(logd)
|
|
||||||
|
|
||||||
File.open(logfn, "w") do |log|
|
File.open(logfn, "w") do |log|
|
||||||
log.puts Time.now, "", cmd, args, ""
|
log.puts Time.now, "", cmd, args, ""
|
||||||
|
|||||||
@ -462,7 +462,7 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build
|
def build
|
||||||
FileUtils.rm Dir["#{HOMEBREW_LOGS}/#{formula.name}/*"]
|
FileUtils.rm_rf(formula.logs)
|
||||||
|
|
||||||
@start_time = Time.now
|
@start_time = Time.now
|
||||||
|
|
||||||
@ -481,9 +481,8 @@ class FormulaInstaller
|
|||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
logd = HOMEBREW_LOGS/formula.name
|
formula.logs.mkpath
|
||||||
logd.mkpath
|
sandbox.record_log(formula.logs/"sandbox.build.log")
|
||||||
sandbox.record_log(logd/"sandbox.build.log")
|
|
||||||
sandbox.allow_write_temp_and_cache
|
sandbox.allow_write_temp_and_cache
|
||||||
sandbox.allow_write_log(formula)
|
sandbox.allow_write_log(formula)
|
||||||
sandbox.allow_write_cellar(formula)
|
sandbox.allow_write_cellar(formula)
|
||||||
|
|||||||
@ -50,7 +50,7 @@ class Sandbox
|
|||||||
end
|
end
|
||||||
|
|
||||||
def allow_write_log(formula)
|
def allow_write_log(formula)
|
||||||
allow_write_path HOMEBREW_LOGS/formula.name
|
allow_write_path formula.logs
|
||||||
end
|
end
|
||||||
|
|
||||||
def deny_write_homebrew_library
|
def deny_write_homebrew_library
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user