
When running brew -v install, long post_install output from the formula, presumably from upstream, may hide the important instructions in the caveats and confuse the user. For example, postgresql runs initdb which prints its own instructions for running the database, making the caveats scroll off screen. Per xu-cheng's instructions in Homebrew/homebrew#42565 : Remove the explicit call to caveats from the install, reinstall, and upgrade commands, as well as the dependency installer code in FormulaInstaller#install_dependency , and call caveats right before the summary code in FormulaInstaller#finish . Closes Homebrew/homebrew#42565. Signed-off-by: Xu Cheng <xucheng@me.com>
57 lines
1.3 KiB
Ruby
57 lines
1.3 KiB
Ruby
require "formula_installer"
|
|
|
|
module Homebrew
|
|
def reinstall
|
|
ARGV.resolved_formulae.each { |f| reinstall_formula(f) }
|
|
end
|
|
|
|
def reinstall_formula(f)
|
|
tab = Tab.for_formula(f)
|
|
options = tab.used_options | f.build.used_options
|
|
|
|
notice = "Reinstalling #{f.full_name}"
|
|
notice += " with #{options * ", "}" unless options.empty?
|
|
oh1 notice
|
|
|
|
if f.opt_prefix.directory?
|
|
keg = Keg.new(f.opt_prefix.resolved_path)
|
|
backup keg
|
|
end
|
|
|
|
fi = FormulaInstaller.new(f)
|
|
fi.options = options
|
|
fi.build_bottle = ARGV.build_bottle? || (!f.bottled? && tab.build_bottle?)
|
|
fi.build_from_source = ARGV.build_from_source?
|
|
fi.force_bottle = ARGV.force_bottle?
|
|
fi.verbose = ARGV.verbose?
|
|
fi.debug = ARGV.debug?
|
|
fi.prelude
|
|
fi.install
|
|
fi.finish
|
|
rescue FormulaInstallationAlreadyAttemptedError
|
|
# next
|
|
rescue Exception
|
|
ignore_interrupts { restore_backup(keg, f) }
|
|
raise
|
|
else
|
|
backup_path(keg).rmtree if backup_path(keg).exist?
|
|
end
|
|
|
|
def backup(keg)
|
|
keg.unlink
|
|
keg.rename backup_path(keg)
|
|
end
|
|
|
|
def restore_backup(keg, formula)
|
|
path = backup_path(keg)
|
|
if path.directory?
|
|
path.rename keg
|
|
keg.link unless formula.keg_only?
|
|
end
|
|
end
|
|
|
|
def backup_path(path)
|
|
Pathname.new "#{path}.reinstall"
|
|
end
|
|
end
|