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, self
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) ⇒ InstallationContext private
- .reinstall_formula(install_context) ⇒ void 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) ⇒ InstallationContext
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.
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 80 81 82 83 84 85 |
# File 'reinstall.rb', line 30 def 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. formula_installer = 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(formula_installer:, keg:, formula:, options:) end |
.reinstall_formula(install_context) ⇒ void
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.
This method returns an undefined value.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'reinstall.rb', line 88 def reinstall_formula(install_context) formula_installer = install_context.formula_installer keg = install_context.keg formula = install_context.formula = install_context. link_keg = keg&.linked? verbose = formula_installer.verbose? 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:) if keg } raise else if keg backup_keg = backup_path(keg) begin FileUtils.rm_r(backup_keg) if backup_keg.exist? rescue Errno::EACCES, Errno::ENOTEMPTY odie <<~EOS Could not remove #{backup_keg.parent.basename} backup keg! Do so manually: sudo rm -rf #{backup_keg} EOS end end end |