summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-03-20 14:30:54 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-03-20 14:32:42 +0100
commit109fdcac9a16ffa06b06366134dcaaef7e2b3379 (patch)
tree33a0b2cfece27e9751b9c33e9f825d93f74df2b7 /apt-pkg
parent7ef14b64596bd0ca78feaea5fda22b8d524de286 (diff)
solver3: Record manual flag before discovering packages
When discovering packages we look at the manual flag to avoid reordering obsolete manually installed packages last. We inadvertently initialized that flag interlaced with discovering packages so if we discovered packages depending on obsolete, but manually installed, packages first, we were not aware they were manually installed and demoted them. I am struggling to come up with a test case for this as I can't get the package objects in the cache to be in the right order for the bug to trigger. LP: #2102720
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/solver3.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index 4030b9de1..4d988b523 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -1099,6 +1099,11 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache)
}
}
+ // Clause discovery depends on the manual flag, so we need to set the manual flag first before we discover any packages
+ for (auto P = cache.PkgBegin(); not P.end(); P++)
+ if (P->CurrentVer && not(depcache[P].Flags & pkgCache::Flag::Auto) && (depcache[P].Keep() || depcache[P].Install()))
+ (*this)[P].flags.manual = true;
+
for (auto P = cache.PkgBegin(); not P.end(); P++)
{
if (P->VersionList == nullptr)
@@ -1142,8 +1147,6 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache)
if (unlikely(debug >= 1))
std::cerr << "Install " << P.FullName() << " (" << (isEssential ? "E" : "") << (isAuto ? "M" : "") << (Root ? "R" : "") << ")"
<< "\n";
-
- (*this)[P].flags.manual = not isAuto;
if (not isOptional)
{
// Pre-empt the non-optional requests, as we don't want to queue them, we can just "unit propagate" here.