summaryrefslogtreecommitdiff
path: root/apt-pkg/depcache.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-05-22 18:56:40 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-05-23 17:58:42 +0200
commit04a020d7a217d6b5af86c048c2974760053b8079 (patch)
treedd07954a2327cb2c00a19292ccd1562e18c18205 /apt-pkg/depcache.cc
parent9d0a37e9cf644f99666b60e5a1ca5131fd0c6519 (diff)
Reset candidate version explicitly for internal state-keeping
For a (partially) installed package like the one MarkInstall operates on at the moment we want to discard the candidate from, we have to first remove the package from the internal state keeping to have proper broken counts and such and only then reset the candidate version which is a trivial operation in comparison. Take a look at the testcase: Now, what is the problem? Correct, git:i386. Didn't see that coming, right? It is M-A:foreign so apt tries to switch the architecture of git here (which is pointless, it knows that this won't work, but lets fix that in another commit) will eventually realize that it can't install it and wants to discard the candidate of git:i386 first removing the broken indication like it should, removing the install flag and then reapplies the broken indication: Expect it doesn't as it wants to do that over the candidate version which the package no longer had so seemingly nothing is broken. It is a bit of a hairball to figure out which commit it is exactly that is wrong here as they are all influencing each other a bit, but >= 2.1 is an acceptable ballpark. Bisect says 57df273 but that is mostly a lie. Closes: #961266
Diffstat (limited to 'apt-pkg/depcache.cc')
-rw-r--r--apt-pkg/depcache.cc28
1 files changed, 16 insertions, 12 deletions
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 842630ec6..02a80b2e8 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -1111,7 +1111,15 @@ bool pkgDepCache::MarkInstall_StateChange(pkgCache::PkgIterator const &Pkg, bool
return true;
}
/*}}}*/
-bool pkgDepCache::MarkInstall_Discard(pkgCache::PkgIterator const &Pkg) /*{{{*/
+static bool MarkInstall_DiscardCandidate(pkgDepCache &Cache, pkgCache::PkgIterator const &Pkg) /*{{{*/
+{
+ auto &State = Cache[Pkg];
+ State.CandidateVer = State.InstallVer;
+ State.Update(Pkg, Cache);
+ return true;
+}
+ /*}}}*/
+bool pkgDepCache::MarkInstall_DiscardInstall(pkgCache::PkgIterator const &Pkg) /*{{{*/
{
StateCache &State = PkgState[Pkg->ID];
if (State.Mode == ModeKeep && State.InstallVer == State.CandidateVer && State.CandidateVer == Pkg.CurrentVer())
@@ -1119,15 +1127,14 @@ bool pkgDepCache::MarkInstall_Discard(pkgCache::PkgIterator const &Pkg) /*{{{*/
RemoveSizes(Pkg);
RemoveStates(Pkg);
if (Pkg->CurrentVer != 0)
- State.InstallVer = State.CandidateVer = Pkg.CurrentVer();
+ State.InstallVer = Pkg.CurrentVer();
else
- State.InstallVer = State.CandidateVer = nullptr;
+ State.InstallVer = nullptr;
State.Mode = ModeKeep;
- State.Update(Pkg, *this);
AddStates(Pkg);
Update(Pkg);
AddSizes(Pkg);
- return true;
+ return MarkInstall_DiscardCandidate(*this, Pkg);
}
/*}}}*/
static bool MarkInstall_CollectDependencies(pkgDepCache const &Cache, pkgCache::VerIterator const &PV, std::vector<pkgCache::DepIterator> &toInstall, std::vector<pkgCache::DepIterator> &toRemove) /*{{{*/
@@ -1202,7 +1209,7 @@ static bool MarkInstall_MarkDeleteForNotUpgradeable(pkgDepCache &Cache, bool con
}
if (propagateProctected)
{
- State.CandidateVer = nullptr;
+ MarkInstall_DiscardCandidate(Cache, Pkg);
Cache.MarkProtected(Pkg);
}
return true;
@@ -1230,10 +1237,7 @@ static bool MarkInstall_RemoveConflictsIfNotUpgradeable(pkgDepCache &Cache, bool
}
else if (propagateProctected)
{
- if (Pkg->CurrentVer != 0)
- State.CandidateVer = Pkg.CurrentVer();
- else
- State.CandidateVer = nullptr;
+ MarkInstall_DiscardCandidate(Cache, Pkg);
if (Pkg->CurrentVer == 0)
Cache.MarkProtected(Pkg);
}
@@ -1491,7 +1495,7 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst,
{
if (failEarly)
{
- MarkInstall_Discard(Pkg);
+ MarkInstall_DiscardInstall(Pkg);
return false;
}
hasFailed = true;
@@ -1519,7 +1523,7 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg, bool AutoInst,
{
if (failEarly)
{
- MarkInstall_Discard(Pkg);
+ MarkInstall_DiscardInstall(Pkg);
return false;
}
hasFailed = true;