Merge pull request #18768 from Homebrew/revamp_installed_on_request

Revamp installed_on_request handling
This commit is contained in:
Mike McQuaid 2024-11-20 08:29:14 +00:00 committed by GitHub
commit d8242dafd1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 36 additions and 28 deletions

View File

@ -138,7 +138,6 @@ module Homebrew
Homebrew::Reinstall.reinstall_formula(
formula,
flags: args.flags_only,
installed_on_request: args.named.present?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
@ -156,7 +155,6 @@ module Homebrew
Upgrade.check_installed_dependents(
formulae,
flags: args.flags_only,
installed_on_request: args.named.present?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,

View File

@ -220,7 +220,6 @@ module Homebrew
formulae_to_install,
flags: args.flags_only,
dry_run: args.dry_run?,
installed_on_request: args.named.present?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,
@ -237,7 +236,6 @@ module Homebrew
formulae_to_install,
flags: args.flags_only,
dry_run: args.dry_run?,
installed_on_request: args.named.present?,
force_bottle: args.force_bottle?,
build_from_source_formulae: args.build_from_source_formulae,
interactive: args.interactive?,

View File

@ -84,7 +84,7 @@ class FormulaInstaller
formula,
link_keg: false,
installed_as_dependency: false,
installed_on_request: true,
installed_on_request: false,
show_header: false,
build_bottle: false,
skip_post_install: false,

View File

@ -259,6 +259,8 @@ module Homebrew
formula_installer = FormulaInstaller.new(
formula,
options: build_options.used_options,
installed_on_request: true,
installed_as_dependency: false,
build_bottle:,
force_bottle:,
bottle_arch:,

View File

@ -10,7 +10,6 @@ module Homebrew
def self.reinstall_formula(
formula,
flags:,
installed_on_request: false,
force_bottle: false,
build_from_source_formulae: [],
interactive: false,
@ -25,9 +24,16 @@ module Homebrew
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?
link_keg = keg.linked?
installed_as_dependency = tab.installed_as_dependency
installed_on_request = tab.installed_on_request
build_bottle = tab.built_bottle?
backup keg
else
link_keg = nil
installed_as_dependency = false
installed_on_request = true
build_bottle = false
end
build_options = BuildOptions.new(Options.create(flags), formula.options)
@ -39,10 +45,10 @@ module Homebrew
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?,
link_keg:,
installed_as_dependency:,
installed_on_request:,
build_bottle:,
force_bottle:,
build_from_source_formulae:,
git:,
@ -65,7 +71,7 @@ module Homebrew
rescue FormulaInstallationAlreadyAttemptedError
nil
rescue Exception # rubocop:disable Lint/RescueException
ignore_interrupts { restore_backup(keg, keg_was_linked, verbose:) }
ignore_interrupts { restore_backup(keg, link_keg, verbose:) }
raise
else
begin

View File

@ -202,7 +202,7 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
def install_test_formula(name, content = nil, build_bottle: false)
setup_test_formula(name, content)
fi = FormulaInstaller.new(Formula[name], build_bottle:)
fi = FormulaInstaller.new(Formula[name], build_bottle:, installed_on_request: true)
fi.prelude
fi.fetch
fi.install

View File

@ -15,7 +15,6 @@ module Homebrew
formulae_to_install,
flags:,
dry_run: false,
installed_on_request: false,
force_bottle: false,
build_from_source_formulae: [],
dependents: false,
@ -55,7 +54,6 @@ module Homebrew
fi = create_formula_installer(
formula,
flags:,
installed_on_request:,
force_bottle:,
build_from_source_formulae:,
interactive:,
@ -114,7 +112,6 @@ module Homebrew
private_class_method def self.create_formula_installer(
formula,
flags:,
installed_on_request: false,
force_bottle: false,
build_from_source_formulae: [],
interactive: false,
@ -126,15 +123,23 @@ module Homebrew
quiet: false,
verbose: false
)
if formula.opt_prefix.directory?
keg = Keg.new(formula.opt_prefix.resolved_path)
keg_had_linked_opt = true
keg_was_linked = keg.linked?
keg = if formula.optlinked?
Keg.new(formula.opt_prefix.resolved_path)
else
formula.installed_kegs.find(&:optlinked?)
end
if formula.opt_prefix.directory?
keg = Keg.new(formula.opt_prefix.resolved_path)
if keg
tab = keg.tab
link_keg = keg.linked?
installed_as_dependency = tab.installed_as_dependency
installed_on_request = tab.installed_on_request
build_bottle = tab.built_bottle?
else
link_keg = nil
installed_as_dependency = false
installed_on_request = true
build_bottle = false
end
build_options = BuildOptions.new(Options.create(flags), formula.options)
@ -146,10 +151,10 @@ module Homebrew
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?,
link_keg:,
installed_as_dependency:,
installed_on_request:,
build_bottle:,
force_bottle:,
build_from_source_formulae:,
interactive:,
@ -338,7 +343,6 @@ module Homebrew
upgrade_formulae(
upgradeable_dependents,
flags:,
installed_on_request:,
force_bottle:,
build_from_source_formulae:,
dependents: true,