diff options
| author | David Kalnischkies <david@kalnischkies.de> | 2024-05-16 13:41:48 +0000 |
|---|---|---|
| committer | David Kalnischkies <david@kalnischkies.de> | 2024-05-16 20:12:51 +0000 |
| commit | b1c3039dae19553bff19615fbb4d116aeaa644a7 (patch) | |
| tree | 3030b6e96764f1c090c89f29a9d51ff23bec8a24 | |
| parent | 15f7214fa2144eeff5ada93e680acd368e9e763a (diff) | |
Do not mark new if we have already installed providers
The test is actually documenting another bug hidden a bit by this one as
we do not need to install a NEW package in this situation as the upgrade
needing it was kept back, but it was protected from considering it to
be autoremoveable as all providers tend to be considered protected, but
by limiting us to installed providers if we have some we can drag those
new packages out of hiding.
Now, we "just" have to get right of the NEW package in a next step.
| -rw-r--r-- | apt-pkg/depcache.cc | 19 | ||||
| -rwxr-xr-x | test/integration/test-bug-604222-new-and-autoremove | 17 |
2 files changed, 33 insertions, 3 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 72cbf8dcc..4e8f5222a 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -2455,6 +2455,25 @@ static bool MarkPackage(pkgCache::PkgIterator const &Pkg, if (not unsatisfied_choice) fullyExplored[T->ID] = true; + + // do not follow newly installed providers if we have already installed providers + if (providers_by_source.size() >= 2) + { + if (std::any_of(providers_by_source.begin(), providers_by_source.end(), [](auto const PV) { + return std::any_of(PV.second.begin(), PV.second.end(), [](auto const &Prv) { + auto const PP = Prv.ParentPkg(); + return not PP.end() && PP->CurrentVer != 0; + });})) + { + for (auto &providers : providers_by_source) + providers.second.erase(std::remove_if(providers.second.begin(), providers.second.end(), + [](auto const &Prv) { + auto const PP = Prv.ParentPkg(); + return not PP.end() && PP->CurrentVer == 0; + }), providers.second.end()); + } + } + for (auto const &providers : providers_by_source) { for (auto const &PV : providers.second) diff --git a/test/integration/test-bug-604222-new-and-autoremove b/test/integration/test-bug-604222-new-and-autoremove index 78a288214..92219fc07 100755 --- a/test/integration/test-bug-604222-new-and-autoremove +++ b/test/integration/test-bug-604222-new-and-autoremove @@ -18,19 +18,30 @@ insertpackage 'stable' 'libkf5kipi-data' 'i386' '4:16.08.0-1' 'Breaks: libkipi-d insertpackage 'stable' 'libkipi-data' 'i386' '4:15.08.0-1' '' 'important' insertpackage 'stable' 'libgphoto2-l10n' 'all' '2' -insertpackage 'installed,stable' 'photoapp1' 'all' '1' 'Recommends: libgphoto2-l10n (= 1)' +insertinstalledpackage 'libfoto1' 'i386' '1' +insertpackage 'installed,stable' 'photoapp1' 'all' '1' 'Depends: libfoto1 +Recommends: libgphoto2-l10n (= 1)' insertinstalledpackage 'photoapp2' 'all' '1' +insertpackage 'stable' 'libfoto1t64' 'i386' '1' 'Provides: libfoto1' insertpackage 'stable' 'photoapp2' 'all' '2' 'Conflicts: photoapp1 +Depends: libfoto1t64 Recommends: libgphoto2-l10n (= 2)' setupaptarchive -testsuccessequal 'Reading package lists... +testsuccessequal "Reading package lists... Building dependency tree... Calculating upgrade... +The following package was automatically installed and is no longer required: + libfoto1t64 +Use 'apt autoremove' to remove it. +The following NEW packages will be installed: + libfoto1t64 The following packages have been kept back: photoapp2 -0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.' apt upgrade -s +0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded. +Inst libfoto1t64 (1 stable [i386]) +Conf libfoto1t64 (1 stable [i386])" apt upgrade -s insertinstalledpackage 'libvtk5.4' 'i386' '5.4.2-7' testsuccess aptmark markauto 'libvtk5.4' |
