summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-06-03 13:03:37 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-06-03 13:41:14 +0200
commit96359a576f59eb8bc461bdd4c5eadeb17fe8f0ca (patch)
treec7bc9c280b96cf67f373bd530421cafd39780c58 /apt-pkg
parent771ddb195586c638cbfc635fa6726733532bcfd0 (diff)
Deal with duplicates in the solution space of a dep
While we process the possible solutions we might modify other solutions like discarding their candidates and such, so that then we reach them they might no longer be proper candidates. We also try to drop duplicates early on to avoid the simple cases of these which test-explore-or-groups-in-markinstall triggers via its explicit duplication but could also come via multiple provides. It only worked previously as were ignoring current versions which usually is okay expect if they are marked for removal and we want to reinstate them so the ProblemResolver can decide which one later on.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/depcache.cc49
1 files changed, 27 insertions, 22 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index b1447bb6c..2eac1ba41 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1258,28 +1258,31 @@ static bool MarkInstall_CollectDependencies(pkgDepCache const &Cache, pkgCache::
/*}}}*/
static APT::VersionVector getAllPossibleSolutions(pkgDepCache &Cache, pkgCache::DepIterator Start, pkgCache::DepIterator const &End, APT::CacheSetHelper::VerSelector const selector, bool const sorted) /*{{{*/
{
- pkgCacheFile CacheFile{&Cache};
- APT::VersionVector toUpgrade, toNewInstall;
- do
+ pkgCacheFile CacheFile{&Cache};
+ APT::VersionVector toUpgrade, toNewInstall;
+ do
+ {
+ APT::VersionVector verlist = APT::VersionVector::FromDependency(CacheFile, Start, selector);
+ if (not sorted)
{
- APT::VersionVector verlist = APT::VersionVector::FromDependency(CacheFile, Start, selector);
- if (not sorted)
- {
- std::move(verlist.begin(), verlist.end(), std::back_inserter(toUpgrade));
- continue;
- }
- std::sort(verlist.begin(), verlist.end(), CompareProviders{Cache, Start});
- for (auto &&Ver : verlist)
- {
- auto P = Ver.ParentPkg();
- if (P->CurrentVer != 0)
- toUpgrade.emplace_back(std::move(Ver));
- else
- toNewInstall.emplace_back(std::move(Ver));
- }
- } while (Start++ != End);
- std::move(toNewInstall.begin(), toNewInstall.end(), std::back_inserter(toUpgrade));
- return toUpgrade;
+ std::move(verlist.begin(), verlist.end(), std::back_inserter(toUpgrade));
+ continue;
+ }
+ std::sort(verlist.begin(), verlist.end(), CompareProviders{Cache, Start});
+ for (auto &&Ver : verlist)
+ {
+ auto P = Ver.ParentPkg();
+ if (P->CurrentVer != 0)
+ toUpgrade.emplace_back(std::move(Ver));
+ else
+ toNewInstall.emplace_back(std::move(Ver));
+ }
+ } while (Start++ != End);
+ std::move(toNewInstall.begin(), toNewInstall.end(), std::back_inserter(toUpgrade));
+ if (not sorted)
+ std::sort(toUpgrade.begin(), toUpgrade.end(), [](pkgCache::VerIterator const &A, pkgCache::VerIterator const &B) { return A->ID < B->ID; });
+ toUpgrade.erase(std::unique(toUpgrade.begin(), toUpgrade.end()), toUpgrade.end());
+ return toUpgrade;
}
/*}}}*/
static bool MarkInstall_MarkDeleteForNotUpgradeable(pkgDepCache &Cache, bool const DebugAutoInstall, pkgCache::VerIterator const &PV, unsigned long const Depth, pkgCache::PkgIterator const &Pkg, bool const propagateProctected)/*{{{*/
@@ -1313,6 +1316,8 @@ static bool MarkInstall_RemoveConflictsIfNotUpgradeable(pkgDepCache &Cache, bool
{
auto const Pkg = Ver.ParentPkg();
auto &State = Cache[Pkg];
+ if (State.CandidateVer != Ver)
+ continue;
if (Pkg.CurrentVer() != Ver)
{
if (State.Install() && not Cache.MarkKeep(Pkg, false, false, Depth))
@@ -1466,7 +1471,7 @@ static bool MarkInstall_InstallDependencies(pkgDepCache &Cache, bool const Debug
for (auto const &InstVer : possibleSolutions)
{
auto const InstPkg = InstVer.ParentPkg();
- if (Cache[InstPkg].CandidateVer == nullptr || Cache[InstPkg].CandidateVer == InstPkg.CurrentVer())
+ if (Cache[InstPkg].CandidateVer != InstVer)
continue;
if (DebugAutoInstall)
std::clog << OutputInDepth(Depth) << "Installing " << InstPkg.FullName()