diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-04 09:05:28 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-07 20:59:43 +0100 |
| commit | b33c6c36373f47b4c7490b0b6731233c1dc1ff05 (patch) | |
| tree | f85b91bd290929e96126364ee86c74cc3a6eee7e /apt-pkg | |
| parent | 5b7af08e4b23f00fc1de4dfe4178d867a560553d (diff) | |
solver3: Cache all configuration calls
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/solver3.cc | 13 | ||||
| -rw-r--r-- | apt-pkg/solver3.h | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index cab2d4371..b098d33ba 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -43,7 +43,6 @@ struct APT::Solver::CompareProviders3 /*{{{*/ pkgDepCache::Policy &Policy; pkgCache::PkgIterator const Pkg; APT::Solver &Solver; - bool upgrade{_config->FindB("APT::Solver::Upgrade", false)}; bool operator()(pkgCache::Version *AV, pkgCache::Version *BV) { @@ -69,7 +68,7 @@ struct APT::Solver::CompareProviders3 /*{{{*/ return false; // Candidate wins in upgrade scenario - if (upgrade) + if (Solver.IsUpgrade) { auto Cand = Solver.GetCandidateVer(A); if (AV == Cand || BV == Cand) @@ -90,7 +89,7 @@ struct APT::Solver::CompareProviders3 /*{{{*/ // Try obsolete choices only after exhausting non-obsolete choices such that we install // packages replacing them and don't keep back upgrades depending on the replacement to // keep the obsolete package installed. - if (upgrade) + if (Solver.IsUpgrade) if (auto obsoleteA = Solver.Obsolete(A), obsoleteB = Solver.Obsolete(B); obsoleteA != obsoleteB) return obsoleteB; // Prefer MA:same packages if other architectures for it are installed @@ -476,8 +475,6 @@ bool APT::Solver::PropagateReject(Var var) bool APT::Solver::EnqueueCommonDependencies(pkgCache::PkgIterator Pkg) { - if (not _config->FindB("APT::Solver::Enqueue-Common-Dependencies", true)) - return false; for (auto dep = Pkg.VersionList().DependsList(); not dep.end();) { pkgCache::DepIterator start; @@ -506,7 +503,6 @@ bool APT::Solver::EnqueueOrGroup(pkgCache::DepIterator start, pkgCache::DepItera { auto TgtPkg = start.TargetPkg(); auto Ver = start.ParentVer(); - auto fixPolicy = _config->FindB("APT::Get::Fix-Policy-Broken"); // Non-important dependencies can only be installed if they are currently satisfied, see the check further // below once we have calculated all possible solutions. @@ -549,7 +545,7 @@ bool APT::Solver::EnqueueOrGroup(pkgCache::DepIterator start, pkgCache::DepItera // If we are fixing the policy, we need to sort each alternative in an or group separately // FIXME: This is not really true, though, we should fix the CompareProviders to ignore the // installed state - if (fixPolicy) + if (FixPolicyBroken) std::stable_sort(workItem.solutions.begin() + begin, workItem.solutions.end(), CompareProviders3{cache, policy, TgtPkg, *this}); if (start == end) @@ -557,7 +553,7 @@ bool APT::Solver::EnqueueOrGroup(pkgCache::DepIterator start, pkgCache::DepItera ++start; } while (1); - if (not fixPolicy) + if (not FixPolicyBroken) std::stable_sort(workItem.solutions.begin(), workItem.solutions.end(), CompareProviders3{cache, policy, TgtPkg, *this}); if (std::all_of(workItem.solutions.begin(), workItem.solutions.end(), [this](auto var) -> auto @@ -942,7 +938,6 @@ bool APT::Solver::Solve() // \brief Apply the selections from the dep cache to the solver bool APT::Solver::FromDepCache(pkgDepCache &depcache) { - bool AllowRemoveManual = AllowRemove && _config->FindB("APT::Solver::RemoveManual", false); DefaultRootSetFunc2 rootSet(&cache); // Enforce strict pinning rules by rejecting all forbidden versions. diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index 2868616de..2e5c5ca13 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -160,12 +160,18 @@ class Solver int debug{_config->FindI("Debug::APT::Solver")}; // \brief If set, we try to keep automatically installed packages installed. bool KeepAuto{not _config->FindB("APT::Get::AutomaticRemove")}; + // \brief Determines if we are in upgrade mode. + bool IsUpgrade{_config->FindB("APT::Solver::Upgrade", false)}; // \brief If set, removals are allowed. bool AllowRemove{_config->FindB("APT::Solver::Remove", true)}; + // \brief If set, removal of manual packages is allowed. + bool AllowRemoveManual{AllowRemove && _config->FindB("APT::Solver::RemoveManual", false)}; // \brief If set, installs are allowed. bool AllowInstall{_config->FindB("APT::Solver::Install", true)}; // \brief If set, we use strict pinning. bool StrictPinning{_config->FindB("APT::Solver::Strict-Pinning", true)}; + // \brief If set, we install missing recommends and pick new best packages. + bool FixPolicyBroken{_config->FindB("APT::Get::Fix-Policy-Broken")}; // \brief Enqueue dependencies shared by all versions of the package. [[nodiscard]] bool EnqueueCommonDependencies(pkgCache::PkgIterator Pkg); |
