From f404c8e06e07c2a89efb0f1ba997a7f1c0c472db Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 16 May 2024 14:51:28 +0000 Subject: Do not save new if we have already installed providers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Companion of the previous commit that uses the same reasoning, but from the other side of the logic (as we start from reverse deps here) so that we are dropping the useless NEW from the solution. Ideally this code would not live in -private, but in -pkg, but there is not really a pre-existent good central place for this currently as a sort-of fixup for our default resolver given this is the result of resolver decision to not do something which had ripple effects that aren't reverted along with it. It is a bit unlikely that this is fixing all instances that this bug has given we have dealt with a few instances of it already as they are relatively obscure situations to clean up after and the cost of being wrong (= autoremover generating breaks) is much higher than being correct (= no pointless install – that is likely installed later anyhow after the temporary automatic hold is lifted). And by virtue of being the result of mostly temporary situations its also unlikely to be debugable in hindsight months later; so if there is another situation, its better to deal with it in a new bugreport. Closes: #839546 --- apt-private/private-install.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'apt-private') diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 4f71f18c4..599caac6d 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -658,6 +658,24 @@ bool DoAutomaticRemove(CacheFile &Cache) if (not Cache->VS().CheckDep(PVerStr, R->CompareOp, R.TargetVer())) continue; } + // ignore new providers if we have installed providers + if (Pkg->CurrentVer == 0) + { + std::unique_ptr VList(R.AllTargets()); + bool has_installed_alt_prov = false; + for (pkgCache::Version **V = VList.get(); *V != 0; ++V) + { + pkgCache::VerIterator Ver(Cache, *V); + auto const P = Ver.ParentPkg(); + if (not P.end() && P->CurrentVer != 0 && Cache[P].InstallVer == *V) + { + has_installed_alt_prov = true; + break; + } + } + if (has_installed_alt_prov) + continue; + } if (Debug == true) std::clog << "Save " << APT::PrettyPkg(Cache, Pkg) << " as another installed package depends on it: " << APT::PrettyPkg(Cache, RP) << std::endl; Cache->MarkInstall(Pkg, false, 0, false); -- cgit v1.2.3-70-g09d2