diff options
| author | Julian Andres Klode <jak@debian.org> | 2025-06-10 14:57:17 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2025-06-10 14:57:17 +0000 |
| commit | 9e6772f6bb13c2606a86e4046a9c4ebfe768881a (patch) | |
| tree | 9e308b4938dd804cd91d435b1662099714892915 /apt-pkg | |
| parent | e3d854ebfa62662752cdf68136208f907d0a7cd7 (diff) | |
| parent | b99ec5f1d80962e39e9debb05f1a7c7840e7d97c (diff) | |
Merge branch 'solver3' into 'main'
solver3: various fixes
See merge request apt-team/apt!492
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/solver3.cc | 16 | ||||
| -rw-r--r-- | apt-pkg/solver3.h | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index a458acb0b..c2877946c 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -216,6 +216,8 @@ APT::Solver::Solver(pkgCache &cache, pkgDepCache::Policy &policy, EDSP::Request: rootState->decision = Decision::MUST; } +APT::Solver::~Solver() = default; + // This function determines if a work item is less important than another. bool APT::Solver::Work::operator<(APT::Solver::Work const &b) const { @@ -499,7 +501,9 @@ bool APT::Solver::ObsoletedByNewerSourceVersion(pkgCache::VerIterator cand) cons for (auto ver = cand.Cache()->FindGrp(cand.SourcePkgName()).VersionsInSource(); not ver.end(); ver = ver.NextInSource()) { // We are only interested in other packages in the same source package; built for the same architecture. - if (ver->ParentPkg == cand->ParentPkg || ver.ParentPkg()->Arch != cand.ParentPkg()->Arch || cache.VS->CmpVersion(ver.SourceVerStr(), cand.SourceVerStr()) <= 0) + if (ver->ParentPkg == cand->ParentPkg || ver.ParentPkg()->Arch != cand.ParentPkg()->Arch || + (ver->MultiArch & pkgCache::Version::All) != (cand->MultiArch & pkgCache::Version::All) || + cache.VS->CmpVersion(ver.SourceVerStr(), cand.SourceVerStr()) <= 0) continue; // We also take equal priority here, given that we have a higher version @@ -960,6 +964,16 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p std::cerr << "Promoting new clause to hard dependency: " << clause.toString(cache) << std::endl; clause.optional = false; } + else if (not existing.end() && importantToKeep(start) && satisfied) + { + if (unlikely(debug >= 3)) + std::cerr << "Restricting existing Recommends to installed packages: " << clause.toString(cache, true) << std::endl; + // Erase the non-installed solutions. We will process this last and try to keep the previously installed + // "best" solution installed. + clause.solutions.erase(std::remove_if(clause.solutions.begin(), clause.solutions.end(), [this](auto var) + { return var.CastPkg(cache)->CurrentVer == nullptr; }), + clause.solutions.end()); + } } return clause; diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index a333d684a..2331af869 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -287,6 +287,7 @@ class Solver // \brief Basic solver initializer. This cannot fail. Solver(pkgCache &Cache, pkgDepCache::Policy &Policy, EDSP::Request::Flags requestFlags); + ~Solver(); // Assume that the variable is decided as specified. [[nodiscard]] bool Assume(Var var, bool decision, const Clause *reason = nullptr); |
