diff options
| author | Julian Andres Klode <jak@debian.org> | 2025-03-09 14:25:51 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-03-09 14:25:51 +0000 |
| commit | ef5abb4e0702372e945c516a31befff03f641a5d (patch) | |
| tree | 1032f7f4727c45306c1de38faa24c9e5bbc34c9e /apt-pkg/solver3.cc | |
| parent | 153bbf448f91eb347574624890c36f97cd168b53 (diff) | |
| parent | 5daf6dbfd272be2f8e3c59d4bab4be8c119b7aa1 (diff) | |
Merge branch 'solver3' into 'main'
solver3: Do not prefer new installs over manually installed obsoletes
See merge request apt-team/apt!458
Diffstat (limited to 'apt-pkg/solver3.cc')
| -rw-r--r-- | apt-pkg/solver3.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index 9f27951e8..c993c1096 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -497,8 +497,10 @@ bool APT::Solver::ObsoletedByNewerSourceVersion(pkgCache::VerIterator cand) cons return false; } -bool APT::Solver::Obsolete(pkgCache::PkgIterator pkg) const +bool APT::Solver::Obsolete(pkgCache::PkgIterator pkg, bool AllowManual) const { + if ((*this)[pkg].flags.manual && not AllowManual) + return false; if (pkgObsolete[pkg] != 0) return pkgObsolete[pkg] == 2; @@ -804,7 +806,7 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p { return var.CastPkg(cache)->CurrentVer == 0; })) clause.group = Group::SatisfyNew; if (std::any_of(clause.solutions.begin(), clause.solutions.end(), [this](auto var) -> auto - { return Obsolete(var.CastPkg(cache)); })) + { return Obsolete(var.CastPkg(cache), true); })) clause.group = Group::SatisfyObsolete; // Try to perserve satisfied Recommends. FIXME: We should check if the Recommends was there in the installed version? if (clause.optional && start.ParentPkg()->CurrentVer) @@ -1102,6 +1104,7 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache) 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. |
