diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-06 10:44:34 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-07 20:59:43 +0100 |
| commit | 3d5f8042c64c30497a65e522c6e402eb4bab10c3 (patch) | |
| tree | c4af4019b25385a963cb632db369e25ef8ef5924 /apt-pkg/solver3.h | |
| parent | 601af4e8adac4cdd57a031db5d073f61fc1033dc (diff) | |
solver3: Use a package clause for optional roots
Instead of iterating over the version here and picking it, just
enqueue the package as well, which should allow us to select the
version at a later time.
This also causes a funny inverse problem now, though, as was evidenced
in one of the test cases: To summarize, if our optional roots are all
single items, they will be considered soft-unit, causing them to be
processed in order.
However it can be that an optional root has a specific version
selected because another version was rejected. Consider
X Conflicts A (= 1)
A, B have 2 versions: '2' available, '1' installed
B (= n) Depends A (= n)
Run `apt install X`. The expected result is for A and B to be
upgraded to version 2. With only a package root, if B appears
in the cache before A however, we will get:
Install X
Reject A (= 1)
Install B
Install B (= 1) # keep it installed
Reject A (= 2)
=> A is being removed as both versions are rejected
Hence we do also need to re-introduce the additional version
clause, now we get:
Install X
Reject A (= 1)
Install A (= 2) # it got "promoted" to a 'stronger' soft-unit
Install B
Fail B (= 1) # keep it installed
Install B (= 2)
Introduce a root state to hold all the clauses that don't have
another owner.
moo
Diffstat (limited to 'apt-pkg/solver3.h')
| -rw-r--r-- | apt-pkg/solver3.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index fc68a5cef..d3e22eaba 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -93,6 +93,8 @@ class Solver pkgCache &cache; // Policy is needed for determining candidate version. pkgDepCache::Policy &policy; + // Root state + std::unique_ptr<State> rootState; // States for packages std::vector<State> pkgStates{}; // States for versions @@ -425,6 +427,5 @@ inline APT::Solver::State &APT::Solver::operator[](Var r) return (*this)[cache.PkgP + P]; if (auto V = r.Ver()) return (*this)[cache.VerP + V]; - - abort(); + return *rootState.get(); } |
