Module: Homebrew::Reinstall Private
- Defined in:
- reinstall.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Class Method Summary collapse
Class Method Details
.reinstall_formula(formula, flags:, installed_on_request: false, force_bottle: false, build_from_source_formulae: [], interactive: false, keep_tmp: false, debug_symbols: false, force: false, debug: false, quiet: false, verbose: false, git: false) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'reinstall.rb', line 10 def self.reinstall_formula( formula, flags:, installed_on_request: false, force_bottle: false, build_from_source_formulae: [], interactive: false, keep_tmp: false, debug_symbols: false, force: false, debug: false, quiet: false, verbose: false, git: false ) if formula.opt_prefix.directory? keg = Keg.new(formula.opt_prefix.resolved_path) tab = keg.tab keg_had_linked_opt = true keg_was_linked = keg.linked? backup keg end = BuildOptions.new(Options.create(flags), formula.) = . |= formula.build. &= formula. fi = FormulaInstaller.new( formula, **{ options:, link_keg: keg_had_linked_opt ? keg_was_linked : nil, installed_as_dependency: tab&.installed_as_dependency, installed_on_request: installed_on_request || tab&.installed_on_request, build_bottle: tab&.built_bottle?, force_bottle:, build_from_source_formulae:, git:, interactive:, keep_tmp:, debug_symbols:, force:, debug:, quiet:, verbose:, }.compact, ) fi.prelude fi.fetch oh1 "Reinstalling #{Formatter.identifier(formula.full_name)} #{.to_a.join " "}" fi.install fi.finish rescue FormulaInstallationAlreadyAttemptedError nil rescue Exception # rubocop:disable Lint/RescueException ignore_interrupts { restore_backup(keg, keg_was_linked, verbose:) } raise else begin backup_path(keg).rmtree if backup_path(keg).exist? rescue Errno::EACCES, Errno::ENOTEMPTY odie <<~EOS Could not remove #{backup_path(keg).parent.basename} backup keg! Do so manually: sudo rm -rf #{backup_path(keg)} EOS end end |