From a20242cf3a7321e78cfd4afd892d67255d8282ba Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 30 Jan 2025 13:04:47 +0100 Subject: solver3: Soft unit propagation for optional items If both items are optional, unit items should be processed first. --- apt-pkg/solver3.cc | 9 +++++++-- test/integration/test-bug-735967-lib32-to-i386-unavailable | 8 +++++++- 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 @@ -32,6 +32,12 @@ setupaptarchive --no-update configarchitecture 'amd64' 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... @@ -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... -- cgit v1.2.3-70-g09d2