From bb0252875e0a4f1100532231a2a8c6594e2ddd9e Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sat, 30 Mar 2024 03:29:51 +0000 Subject: [PATCH 1/3] utils/bottles: fix outdated bottle check --- Library/Homebrew/software_spec.rb | 2 +- Library/Homebrew/utils/bottles.rb | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 978522a42d..96592eb4dc 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -340,7 +340,7 @@ class Bottle extend Forwardable - attr_reader :name, :resource, :cellar, :rebuild + attr_reader :name, :resource, :tag, :cellar, :rebuild def_delegators :resource, :url, :verify_download_integrity def_delegators :resource, :cached_download diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 06cb02b602..20f1f965fe 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -33,16 +33,15 @@ module Utils end def file_outdated?(formula, file) + file = file.resolved_path + filename = file.basename.to_s return false if formula.bottle.blank? - bottle_ext, bottle_tag, = extname_tag_rebuild(filename) - return false if bottle_ext.blank? - return false if bottle_tag != tag.to_s + _, bottle_tag, bottle_rebuild = extname_tag_rebuild(filename) + return false if bottle_tag.blank? - bottle_url_ext, = extname_tag_rebuild(formula.bottle.url) - - bottle_ext && bottle_url_ext && bottle_ext != bottle_url_ext + bottle_tag != formula.bottle.tag.to_s || bottle_rebuild.to_i != formula.bottle.rebuild end def extname_tag_rebuild(filename) From 92d44912e2657a1605772438ebf89b755bd2280e Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sat, 30 Mar 2024 03:30:31 +0000 Subject: [PATCH 2/3] cleanup: better handle version_scheme scenarios --- Library/Homebrew/cleanup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 8d0c9e9f44..4790d65f8a 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -143,7 +143,7 @@ module Homebrew return true unless patch_hashes&.include?(Checksum.new(version.to_s)) elsif resource_name && (resource_version = formula.stable&.resources&.dig(resource_name)&.version) return true if resource_version != version - elsif formula.version > version + elsif (formula.latest_version_installed? && formula.version != version) || formula.version > version return true end From 58de9e0dda7009e245875dbbf2dfebf3983a110c Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Sat, 30 Mar 2024 03:30:58 +0000 Subject: [PATCH 3/3] cleanup: better support bottle manifests --- Library/Homebrew/cleanup.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 4790d65f8a..6a0e94fdd1 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -134,6 +134,14 @@ module Homebrew nil end + if formula.blank? && formula_name.delete_suffix!("_bottle_manifest") + formula = begin + Formulary.from_rack(HOMEBREW_CELLAR/formula_name) + rescue FormulaUnavailableError, TapFormulaAmbiguityError + nil + end + end + return false if formula.blank? resource_name = basename_str[/\A.*?--(.*?)--?(?:#{Regexp.escape(version.to_s)})/, 1] @@ -328,7 +336,7 @@ module Homebrew def cleanup_formula(formula, quiet: false, ds_store: true, cache_db: true) formula.eligible_kegs_for_cleanup(quiet:) .each(&method(:cleanup_keg)) - cleanup_cache(Pathname.glob(cache/"#{formula.name}--*").map { |path| { path:, type: nil } }) + cleanup_cache(Pathname.glob(cache/"#{formula.name}{_bottle_manifest,}--*").map { |path| { path:, type: nil } }) rm_ds_store([formula.rack]) if ds_store cleanup_cache_db(formula.rack) if cache_db cleanup_lockfiles(FormulaLock.new(formula.name).path)