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.
Defined Under Namespace
Classes: InstallationContext
Class Method Summary collapse
- .build_install_context(formula, flags:, 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 private
- .reinstall_formula(install_context, flags:, 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 private
Class Method Details
.build_install_context(formula, flags:, 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.
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 |
# File 'reinstall.rb', line 12 def self.build_install_context( formula, flags:, 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 link_keg = keg.linked? installed_as_dependency = tab.installed_as_dependency == true installed_on_request = tab.installed_on_request == true build_bottle = tab.built_bottle? backup keg else link_keg = nil installed_as_dependency = false installed_on_request = true build_bottle = false end = BuildOptions.new(Options.create(flags), formula.) = . |= formula.build. &= formula. fi = FormulaInstaller.new( formula, **{ options:, link_keg:, installed_as_dependency:, installed_on_request:, build_bottle:, force_bottle:, build_from_source_formulae:, git:, interactive:, keep_tmp:, debug_symbols:, force:, debug:, quiet:, verbose:, }.compact, ) InstallationContext.new(fi, keg, formula, ) end |
.reinstall_formula(install_context, flags:, 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.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'reinstall.rb', line 69 def self.reinstall_formula( install_context, flags:, 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 ) formula_installer = install_context.formula_installer keg = install_context.keg formula = install_context.formula = install_context. link_keg = keg&.linked? formula_installer.prelude formula_installer.fetch oh1 "Reinstalling #{Formatter.identifier(formula.full_name)} #{.to_a.join " "}" formula_installer.install formula_installer.finish rescue FormulaInstallationAlreadyAttemptedError nil # Any other exceptions we want to restore the previous keg and report the error. rescue Exception # rubocop:disable Lint/RescueException ignore_interrupts { restore_backup(keg, link_keg, verbose:) } raise else begin FileUtils.rm_r(backup_path(keg)) 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 |