use ofail to set Homebrew.failed

This commit is contained in:
EricFromCanada 2020-07-29 19:41:39 -04:00
parent 571179ff0e
commit f5e1557154
4 changed files with 9 additions and 17 deletions

View File

@ -57,8 +57,7 @@ module Homebrew
methods.each do |method| methods.each do |method|
$stderr.puts Formatter.headline("Checking #{method}", color: :magenta) if args.debug? $stderr.puts Formatter.headline("Checking #{method}", color: :magenta) if args.debug?
unless checks.respond_to?(method) unless checks.respond_to?(method)
Homebrew.failed = true ofail "No check available by the name: #{method}"
puts "No check available by the name: #{method}"
next next
end end

View File

@ -150,8 +150,8 @@ module Homebrew
def fetch_patch(p, args:) def fetch_patch(p, args:)
fetch_fetchable p, args: args fetch_fetchable p, args: args
rescue ChecksumMismatchError => e rescue ChecksumMismatchError => e
Homebrew.failed = true
opoo "Patch reports different sha256: #{e.expected}" opoo "Patch reports different sha256: #{e.expected}"
Homebrew.failed = true
end end
def retry_fetch?(f, args:) def retry_fetch?(f, args:)

View File

@ -951,10 +951,9 @@ class FormulaInstaller
begin begin
keg.optlink(verbose: verbose?) keg.optlink(verbose: verbose?)
rescue Keg::LinkError => e rescue Keg::LinkError => e
onoe "Failed to create #{formula.opt_prefix}" ofail "Failed to create #{formula.opt_prefix}"
puts "Things that depend on #{formula.full_name} will probably not build." puts "Things that depend on #{formula.full_name} will probably not build."
puts e puts e
Homebrew.failed = true
end end
return return
end end
@ -991,25 +990,23 @@ class FormulaInstaller
link_overwrite_backup[conflict_file] = backup_file link_overwrite_backup[conflict_file] = backup_file
retry retry
end end
onoe "The `brew link` step did not complete successfully" ofail "The `brew link` step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e puts e
puts puts
puts "Possible conflicting files are:" puts "Possible conflicting files are:"
keg.link(dry_run: true, overwrite: true, verbose: verbose?) keg.link(dry_run: true, overwrite: true, verbose: verbose?)
@show_summary_heading = true @show_summary_heading = true
Homebrew.failed = true
rescue Keg::LinkError => e rescue Keg::LinkError => e
onoe "The `brew link` step did not complete successfully" ofail "The `brew link` step did not complete successfully"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e puts e
puts puts
puts "You can try again using:" puts "You can try again using:"
puts " brew link #{formula.name}" puts " brew link #{formula.name}"
@show_summary_heading = true @show_summary_heading = true
Homebrew.failed = true
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
onoe "An unexpected error occurred during the `brew link` step" ofail "An unexpected error occurred during the `brew link` step"
puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}" puts "The formula built, but is not symlinked into #{HOMEBREW_PREFIX}"
puts e puts e
puts e.backtrace if debug? puts e.backtrace if debug?
@ -1021,7 +1018,6 @@ class FormulaInstaller
FileUtils.mv backup, origin FileUtils.mv backup, origin
end end
end end
Homebrew.failed = true
raise raise
end end
@ -1043,20 +1039,18 @@ class FormulaInstaller
log = formula.var/"log" log = formula.var/"log"
log.mkpath if formula.plist.include? log.to_s log.mkpath if formula.plist.include? log.to_s
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
onoe "Failed to install plist file" ofail "Failed to install plist file"
odebug e, e.backtrace odebug e, e.backtrace
Homebrew.failed = true
end end
sig { params(keg: Keg).void } sig { params(keg: Keg).void }
def fix_dynamic_linkage(keg) def fix_dynamic_linkage(keg)
keg.fix_dynamic_linkage keg.fix_dynamic_linkage
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
onoe "Failed to fix install linkage" ofail "Failed to fix install linkage"
puts "The formula built, but you may encounter issues using it or linking other" puts "The formula built, but you may encounter issues using it or linking other"
puts "formulae against it." puts "formulae against it."
odebug e, e.backtrace odebug e, e.backtrace
Homebrew.failed = true
@show_summary_heading = true @show_summary_heading = true
end end

View File

@ -36,8 +36,7 @@ module Homebrew
upgrade_formula(f, args: args) upgrade_formula(f, args: args)
Cleanup.install_formula_clean!(f) Cleanup.install_formula_clean!(f)
rescue UnsatisfiedRequirements => e rescue UnsatisfiedRequirements => e
Homebrew.failed = true ofail "#{f}: #{e}"
onoe "#{f}: #{e}"
end end
end end
end end