Class: Homebrew::Cmd::Reinstall Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::Cmd::Reinstall
- Defined in:
- cmd/reinstall.rb,
sorbet/rbi/dsl/homebrew/cmd/reinstall.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::Cmd::Reinstall::Args private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::Cmd::Reinstall::Args
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 |
# File 'sorbet/rbi/dsl/homebrew/cmd/reinstall.rbi', line 10 def args; end |
#run ⇒ 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.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'cmd/reinstall.rb', line 118 def run formulae = T.let([], T::Array[Formula]) casks = T.let([], T::Array[Cask::Cask]) unavailable_errors = T.let( [], T::Array[T.any(FormulaOrCaskUnavailableError, NoSuchKegError)], ) args.named.to_formulae_and_casks_and_unavailable(method: :resolve).each do |item| case item when FormulaOrCaskUnavailableError, NoSuchKegError unavailable_errors << item when Formula formulae << item when Cask::Cask casks << item end end if args.build_from_source? unless DevelopmentTools.installed? raise BuildFlagsError.new(["--build-from-source"], bottled: formulae.all?(&:bottled?)) end unless Homebrew::EnvConfig.developer? opoo "building from source is not supported!" puts "You're on your own. Failures are expected so don't create any issues, please!" end end formulae = Homebrew::Attestation.sort_formulae_for_install(formulae) if Homebrew::Attestation.enabled? shared_download_queue = T.let(nil, T.nilable(Homebrew::DownloadQueue)) casks_prefetched = T.let(false, T::Boolean) unless formulae.empty? Install.perform_preinstall_checks_once reinstall_contexts = formulae.filter_map do |formula| if formula.pinned? onoe "#{formula.full_name} is pinned. You must unpin it to reinstall." next end Migrator.migrate_if_needed(formula, force: args.force?) Homebrew::Reinstall.build_install_context( formula.latest_formula, flags: args.flags_only, force_bottle: args.force_bottle?, build_from_source_formulae: args.build_from_source_formulae, interactive: args.interactive?, keep_tmp: args.keep_tmp?, debug_symbols: args.debug_symbols?, force: args.force?, debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?, git: args.git?, ) end dependants = Upgrade.dependants( formulae, flags: args.flags_only, ask: args.ask?, force_bottle: args.force_bottle?, build_from_source_formulae: args.build_from_source_formulae, interactive: args.interactive?, keep_tmp: args.keep_tmp?, debug_symbols: args.debug_symbols?, force: args.force?, debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?, ) formulae_installers = reinstall_contexts.map(&:formula_installer) # Main block: if asking the user is enabled, show dependency and size information. Install.ask_formulae(formulae_installers, dependants, args: args) if args.ask? valid_formula_installers = if casks.any? shared_download_queue = Homebrew::DownloadQueue.new(pour: true) begin Install.show_combined_fetch_downloads_heading( formula_names: formulae_installers.map { |fi| fi.formula.name }, cask_names: casks.map(&:full_name), ) valid_formula_installers = Install.enqueue_formulae(formulae_installers, download_queue: shared_download_queue) require "cask/installer" fetch_cask_installers = casks.map do |cask| Cask::Installer.new( cask, binaries: args.binaries?, verbose: args.verbose?, force: args.force?, skip_cask_deps: args.skip_cask_deps?, require_sha: args.require_sha?, reinstall: true, quarantine: args.quarantine?, zap: args.zap?, download_queue: shared_download_queue, defer_fetch: true, ) end Install.enqueue_cask_installers(fetch_cask_installers) shared_download_queue.fetch casks_prefetched = true valid_formula_installers ensure shared_download_queue.shutdown end else Install.fetch_formulae(formulae_installers) end exit 1 if Homebrew.failed? reinstall_contexts.each do |reinstall_context| next unless valid_formula_installers.include?(reinstall_context.formula_installer) Homebrew::Reinstall.reinstall_formula(reinstall_context) Cleanup.install_formula_clean!(reinstall_context.formula) end Upgrade.upgrade_dependents( dependants, formulae, flags: args.flags_only, force_bottle: args.force_bottle?, build_from_source_formulae: args.build_from_source_formulae, interactive: args.interactive?, keep_tmp: args.keep_tmp?, debug_symbols: args.debug_symbols?, force: args.force?, debug: args.debug?, quiet: args.quiet?, verbose: args.verbose? ) end if casks.any? Install.ask_casks casks if args.ask? begin Cask::Reinstall.reinstall_casks( *casks, binaries: args.binaries?, verbose: args.verbose?, force: args.force?, require_sha: args.require_sha?, skip_cask_deps: args.skip_cask_deps?, quarantine: args.quarantine?, zap: args.zap?, skip_prefetch: casks_prefetched, download_queue: nil, ) rescue => e ofail e end end unavailable_errors.each { |e| ofail e } Cleanup.periodic_clean! Homebrew..(display_times: args.display_times?) end |