summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-01-30 13:04:47 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-01-30 14:50:15 +0100
commita20242cf3a7321e78cfd4afd892d67255d8282ba (patch)
treeb4d666d0dcc651878e7d67e51606dea3c8f98997
parent184ac78d3dd21b9d6c3b539703de803f0f7132a7 (diff)
solver3: Soft unit propagation for optional items
If both items are optional, unit items should be processed first.
-rw-r--r--apt-pkg/solver3.cc9
-rwxr-xr-xtest/integration/test-bug-735967-lib32-to-i386-unavailable8
2 files changed, 14 insertions, 3 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index da80222e8..b876636c6 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -187,8 +187,13 @@ bool APT::Solver::Work::operator<(APT::Solver::Work const &b) const
return not b.optional && b.size < 2;
if (group != b.group)
return group > b.group;
- if (optional && b.optional && reason.empty() != b.reason.empty())
- return reason.empty();
+ if (optional && b.optional)
+ {
+ if ((size < 2) != (b.size < 2))
+ return b.size < 2;
+ if (reason.empty() != b.reason.empty())
+ return reason.empty();
+ }
// An optional item is less important than a required one.
if (optional != b.optional)
return optional;
diff --git a/test/integration/test-bug-735967-lib32-to-i386-unavailable b/test/integration/test-bug-735967-lib32-to-i386-unavailable
index cc925d161..a44e58570 100755
--- a/test/integration/test-bug-735967-lib32-to-i386-unavailable
+++ b/test/integration/test-bug-735967-lib32-to-i386-unavailable
@@ -35,6 +35,12 @@ testsuccess aptget update
testsuccessequal 'Reading package lists...
Building dependency tree...
Calculating upgrade...
+The following packages have been kept back:
+ lib32nss-mdns libnss-mdns
+0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.' aptget dist-upgrade -s --solver 3.0
+testsuccessequal 'Reading package lists...
+Building dependency tree...
+Calculating upgrade...
The following packages will be REMOVED:
lib32nss-mdns
The following packages will be upgraded:
@@ -42,7 +48,7 @@ The following packages will be upgraded:
1 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
Remv lib32nss-mdns [0.9-1]
Inst libnss-mdns [0.9-1] (0.10-6 unstable [amd64])
-Conf libnss-mdns (0.10-6 unstable [amd64])' aptget dist-upgrade -s
+Conf libnss-mdns (0.10-6 unstable [amd64])' aptget dist-upgrade -s --solver internal
testfailuremsg 'E: Unsatisfiable dependency group libfoo:amd64=1 -> libfoo-bin:amd64' aptget install foo -s --solver 3.0
testfailureequal 'Reading package lists...