Skip to content

Commit

Permalink
upgrade: more liberal formula upgrade changes.
Browse files Browse the repository at this point in the history
Download the bottle manifests for the potential formulae we are going to
upgrade and, if they are have all their `runtime_dependencies` versions
currently met, don't try to download the bottle or upgrade the formula.
  • Loading branch information
MikeMcQuaid committed Sep 5, 2023
1 parent 51889e7 commit 72ded32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Library/Homebrew/formula_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class FormulaInstaller
extend Predicable

attr_reader :formula
attr_reader :bottle_tab_runtime_dependencies

attr_accessor :options, :link_keg

Expand Down Expand Up @@ -96,7 +97,7 @@ def initialize(
@requirement_messages = []
@poured_bottle = false
@start_time = nil
@bottle_tab_runtime_dependencies = {}
@bottle_tab_runtime_dependencies = {}.freeze

# Take the original formula instance, which might have been swapped from an API instance to a source instance
@formula = previously_fetched_formula if previously_fetched_formula
Expand Down
16 changes: 16 additions & 0 deletions Library/Homebrew/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def upgrade_formulae(
installed_on_request: false,
force_bottle: false,
build_from_source_formulae: [],
dependents: false,
interactive: false,
keep_tmp: false,
debug_symbols: false,
Expand Down Expand Up @@ -70,6 +71,20 @@ def upgrade_formulae(
)
unless dry_run
fi.prelude

# Don't need to install this bottle if all the runtime dependencies
# are already satisfied.
next if dependents && fi.bottle_tab_runtime_dependencies.presence&.none? do |dependency, hash|
installed_version = begin
Formula[dependency].any_installed_version

Check warning on line 79 in Library/Homebrew/upgrade.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/upgrade.rb#L79

Added line #L79 was not covered by tests
rescue FormulaUnavailableError
nil

Check warning on line 81 in Library/Homebrew/upgrade.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/upgrade.rb#L81

Added line #L81 was not covered by tests
end
next true unless installed_version

Version.new(hash["version"]) > installed_version.version

Check warning on line 85 in Library/Homebrew/upgrade.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/upgrade.rb#L85

Added line #L85 was not covered by tests
end

fi.fetch
end
fi
Expand Down Expand Up @@ -336,6 +351,7 @@ def check_installed_dependents(
installed_on_request: installed_on_request,
force_bottle: force_bottle,
build_from_source_formulae: build_from_source_formulae,
dependents: true,
interactive: interactive,
keep_tmp: keep_tmp,
debug_symbols: debug_symbols,
Expand Down

0 comments on commit 72ded32

Please sign in to comment.