Pass debug? and verbose? to Cleaner.

This commit is contained in:
Markus Reiter 2020-08-02 03:01:42 +02:00
parent 26688145f0
commit add10377b8
2 changed files with 10 additions and 4 deletions

View File

@ -10,9 +10,15 @@
# * sets permissions on executables # * sets permissions on executables
# * removes unresolved symlinks # * removes unresolved symlinks
class Cleaner class Cleaner
extend Predicable
attr_predicate :verbose?, :debug?
# Create a cleaner for the given formula # Create a cleaner for the given formula
def initialize(f) def initialize(f, verbose: false, debug: false)
@f = f @f = f
@verbose = verbose
@debug = debug
end end
# Clean the keg of formula @f # Clean the keg of formula @f
@ -58,7 +64,7 @@ class Cleaner
# actual files gets removed correctly. # actual files gets removed correctly.
dirs.reverse_each do |d| dirs.reverse_each do |d|
if d.children.empty? if d.children.empty?
puts "rmdir: #{d} (empty)" if Homebrew.args.verbose? puts "rmdir: #{d} (empty)" if verbose?
d.rmdir d.rmdir
end end
end end
@ -109,7 +115,7 @@ class Cleaner
else else
0444 0444
end end
if Homebrew.args.debug? if debug?
old_perms = path.stat.mode & 0777 old_perms = path.stat.mode & 0777
odebug "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms odebug "Fixing #{path} permissions from #{old_perms.to_s(8)} to #{perms.to_s(8)}" if perms != old_perms
end end

View File

@ -956,7 +956,7 @@ class FormulaInstaller
def clean def clean
ohai "Cleaning" if verbose? ohai "Cleaning" if verbose?
Cleaner.new(formula).clean Cleaner.new(formula, verbose: verbose?, debug: debug?).clean
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
opoo "The cleaning step did not complete successfully" opoo "The cleaning step did not complete successfully"
puts "Still, the installation was successful, so we will link it into your prefix" puts "Still, the installation was successful, so we will link it into your prefix"