From 5daf6dbfd272be2f8e3c59d4bab4be8c119b7aa1 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sun, 9 Mar 2025 14:52:53 +0100 Subject: solver3: Do not prefer new installs over manually installed obsoletes Only move obsolete packages last that are automatically installed, as we don't want to remove manually installed obsolete packages. Add some missing const annotations to the operator[] arguments as well that were needed. LP: #2100247 --- apt-pkg/solver3.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'apt-pkg/solver3.h') diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index 9d4a195ec..b7000c52e 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -146,21 +146,21 @@ class Solver ContiguousCacheMap verStates; // \brief Helper function for safe access to package state. - inline State &operator[](pkgCache::Package *P) + inline State &operator[](const pkgCache::Package *P) { return pkgStates[P]; } - inline const State &operator[](pkgCache::Package *P) const + inline const State &operator[](const pkgCache::Package *P) const { return pkgStates[P]; } // \brief Helper function for safe access to version state. - inline State &operator[](pkgCache::Version *V) + inline State &operator[](const pkgCache::Version *V) { return verStates[V]; } - inline const State &operator[](pkgCache::Version *V) const + inline const State &operator[](const pkgCache::Version *V) const { return verStates[V]; } @@ -169,7 +169,9 @@ class Solver inline const State &operator[](Var r) const; mutable FastContiguousCacheMap pkgObsolete; - bool Obsolete(pkgCache::PkgIterator pkg) const; + // \brief Check if package is obsolete. + // \param AllowManual controls whether manual packages can be obsolete + bool Obsolete(pkgCache::PkgIterator pkg, bool AllowManual=false) const; bool ObsoletedByNewerSourceVersion(pkgCache::VerIterator cand) const; mutable FastContiguousCacheMap priorities; @@ -471,6 +473,7 @@ struct APT::Solver::State struct { bool discovered{}; + bool manual{}; } flags; static_assert(sizeof(flags) <= sizeof(int)); -- cgit v1.2.3-70-g09d2