summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-02-11 15:54:46 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-02-14 19:08:45 +0100
commit4a98dcf274123190a0ebff2bd223cbc9d11e35f9 (patch)
tree7efbf42b6e3bea67b6b117acfdf1315642bb98e6
parent4c48b5618ba15d4e33625cec81843891910e81a2 (diff)
solver3: Install Essential on dist-upgrade
This is a bit gnarly, but dist-upgrade is mapped to is an upgrade + removals allowed + installs allowed :D
-rw-r--r--apt-pkg/solver3.cc14
-rw-r--r--test/integration/solver3.broken2
-rwxr-xr-xtest/integration/test-bug-675449-essential-are-protected15
3 files changed, 28 insertions, 3 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index 44a5075da..f6ee1d243 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -950,6 +950,20 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache)
Discover(Var(P));
}
}
+ else if (IsUpgrade && AllowRemove && AllowInstall && (P->Flags & pkgCache::Flag::Essential))
+ {
+ Clause w{Var(), Group::InstallManual, false};
+ auto G = P.Group();
+ for (auto P = G.PackageList(); not P.end(); P = G.NextPkg(P))
+ if (P->Flags & pkgCache::Flag::Essential)
+ w.solutions.push_back(Var(P));
+ std::stable_sort(w.solutions.begin(), w.solutions.end(), CompareProviders3{cache, policy, P, *this});
+ if (unlikely(debug >= 1))
+ std::cerr << "Install essential package " << P << std::endl;
+ RegisterClause(std::move(w));
+ if (not AddWork(Work{rootState->clauses.back().get(), depth()}))
+ return false;
+ }
}
return Propagate();
diff --git a/test/integration/solver3.broken b/test/integration/solver3.broken
index 540bfbca1..74507b25f 100644
--- a/test/integration/solver3.broken
+++ b/test/integration/solver3.broken
@@ -6,9 +6,7 @@ test-apt-move-and-forget-manual-sections
test-bug-470115-new-and-tighten-recommends
test-bug-602412-dequote-redirect
test-bug-611729-mark-as-manual
-test-bug-675449-essential-are-protected
test-bug-745046-candidate-propagation-fails
-test-bug-767891-force-essential-important
test-bug-961266-hold-means-hold
test-dont-forget-conflicts-via-unknown-architectures
test-explore-or-groups-in-markinstall
diff --git a/test/integration/test-bug-675449-essential-are-protected b/test/integration/test-bug-675449-essential-are-protected
index e7460aeb7..36e7b645e 100755
--- a/test/integration/test-bug-675449-essential-are-protected
+++ b/test/integration/test-bug-675449-essential-are-protected
@@ -112,4 +112,17 @@ The following information may help to resolve the situation:
The following packages have unmet dependencies:
foo : Depends: libfoo but it is not going to be installed
-E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.' aptget purge libfoo -s
+E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.' aptget purge libfoo -s --solver internal
+
+testequal 'Reading package lists...
+Building dependency tree...
+Solving dependencies...
+Some packages could not be installed. This may mean that you have
+requested an impossible situation or if you are using the unstable
+distribution that some required packages have not yet been created
+or been moved out of Incoming.
+The following information may help to resolve the situation:
+
+The following packages have unmet dependencies:
+ foo : Depends: libfoo but it is not going to be installed
+E: Conflict: foo:amd64 -> libfoo:amd64 but not libfoo:amd64' aptget purge libfoo -s --solver 3.0