summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2025-07-22 19:58:14 +0200
committerJulian Andres Klode <jak@debian.org>2025-08-26 13:41:35 +0200
commitdb78e2f8eafb1009bd47e488fc39d8b420f4c749 (patch)
tree2e56f81714e94389463615269e84b8e889374c8d
parente7ad79fddc6aa46b8f5efce890928db47be7b48b (diff)
solver3: Sort dependency targets against current alternative
Instead of inadvertently sorting dependency targets against the first alternative in an or group, sort them against the current alternative as we should. Otherwise we ended up sorting gnome-shell | notification-daemon With Package: notification-daemon Package: awesome Provides: notification-daemon into gnome-shell | awesome | notification-daemon <-we sorted this part wrongly-> This fixes a minor difference in test-release-candidate-switching in one case, but not the other where the difference was actually caused by the loss of install argument ordering information in the new solver, so just flip the arguments so both solvers produce the same outcome.
-rw-r--r--apt-pkg/solver3.cc5
-rwxr-xr-xtest/integration/test-release-candidate-switching18
-rwxr-xr-xtest/integration/test-resolver-prefers-real-package58
3 files changed, 67 insertions, 14 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index c2877946c..2c381f098 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -843,8 +843,6 @@ void APT::Solver::RegisterCommonDependencies(pkgCache::PkgIterator Pkg)
APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, pkgCache::DepIterator end, Var reason)
{
- auto TgtPkg = start.TargetPkg();
-
// Non-important dependencies can only be installed if they are currently satisfied, see the check further
// below once we have calculated all possible solutions.
if (start.ParentPkg()->CurrentVer == 0 && not policy.IsImportantDep(start))
@@ -880,8 +878,7 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p
clause.solutions.push_back(Var(pkgCache::VerIterator(cache, *tgt)));
}
delete[] all;
-
- std::stable_sort(clause.solutions.begin() + begin, clause.solutions.end(), CompareProviders3{cache, policy, TgtPkg, *this});
+ std::stable_sort(clause.solutions.begin() + begin, clause.solutions.end(), CompareProviders3{cache, policy, start.TargetPkg(), *this});
}
if (start == end)
break;
diff --git a/test/integration/test-release-candidate-switching b/test/integration/test-release-candidate-switching
index 52d3e5a12..18396252f 100755
--- a/test/integration/test-release-candidate-switching
+++ b/test/integration/test-release-candidate-switching
@@ -117,8 +117,6 @@ Need to get 0 B/252 B of archives.
After this operation, 258 kB of additional disk space will be used.
E: Trivial Only specified but this is not a trivial operation." aptget install amarok/experimental --trivial-only -V
-phonon_backend_default="phonon-backend-null (4:4.20.0+sid)"
-[ "$APT_SOLVER" != "3.0" ] || phonon_backend_default="phonon-backend-xine (4:4.6.0really4.4.2-1+sid)"
testfailureequal "Reading package lists...
Building dependency tree...
Selected version '2.3.2-2+exp' (experimental [i386]) for 'amarok-null'
@@ -129,14 +127,14 @@ The following additional packages will be installed:
amarok-utils (2.3.2-2+exp)
libc6 (2.11.2-7+sid)
libmtp8 (0.3.1+sid)
- $phonon_backend_default
+ phonon-backend-null (4:4.20.0+sid)
The following NEW packages will be installed:
amarok-common (2.3.2-2+exp)
amarok-null (2.3.2-2+exp)
amarok-utils (2.3.2-2+exp)
libc6 (2.11.2-7+sid)
libmtp8 (0.3.1+sid)
- $phonon_backend_default
+ phonon-backend-null (4:4.20.0+sid)
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/252 B of archives.
After this operation, 258 kB of additional disk space will be used.
@@ -145,16 +143,16 @@ E: Trivial Only specified but this is not a trivial operation." aptget install a
# do not select the same version multiple times
testfailureequal "Reading package lists...
Building dependency tree...
-Selected version '2.3.2-2+exp' (experimental [i386]) for 'amarok'
-Selected version '2.3.2-2+exp' (experimental [all]) for 'amarok-common' because of 'amarok'
-Selected version '2.3.2-2+exp' (experimental [i386]) for 'amarok-utils' because of 'amarok'
Selected version '2.3.2-2+exp' (experimental [i386]) for 'amarok-null'
+Selected version '2.3.2-2+exp' (experimental [all]) for 'amarok-common' because of 'amarok-null'
+Selected version '2.3.2-2+exp' (experimental [i386]) for 'amarok-utils' because of 'amarok-null'
+Selected version '2.3.2-2+exp' (experimental [i386]) for 'amarok'
The following additional packages will be installed:
amarok-common (2.3.2-2+exp)
amarok-utils (2.3.2-2+exp)
libc6 (2.11.2-7+sid)
libmtp8 (0.3.1+sid)
- phonon-backend-xine (4:4.6.0really4.4.2-1+sid)
+ phonon-backend-null (4:4.20.0+sid)
The following NEW packages will be installed:
amarok (2.3.2-2+exp)
amarok-common (2.3.2-2+exp)
@@ -162,11 +160,11 @@ The following NEW packages will be installed:
amarok-utils (2.3.2-2+exp)
libc6 (2.11.2-7+sid)
libmtp8 (0.3.1+sid)
- phonon-backend-xine (4:4.6.0really4.4.2-1+sid)
+ phonon-backend-null (4:4.20.0+sid)
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/294 B of archives.
After this operation, 301 kB of additional disk space will be used.
-E: Trivial Only specified but this is not a trivial operation." aptget install amarok/experimental amarok-null/experimental --trivial-only -V
+E: Trivial Only specified but this is not a trivial operation." aptget install amarok-null/experimental amarok/experimental --trivial-only -V
# … but thighten the version if needed
# in theory, the second line is wrong, but printing the right version is too much of a hassle
diff --git a/test/integration/test-resolver-prefers-real-package b/test/integration/test-resolver-prefers-real-package
new file mode 100755
index 000000000..d692eb0be
--- /dev/null
+++ b/test/integration/test-resolver-prefers-real-package
@@ -0,0 +1,58 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+setupenvironment
+configarchitecture 'amd64'
+
+insertpackage 'unstable' 'update-notifier' 'all' '1' 'Depends: gnome-shell | notification-daemon'
+insertpackage 'unstable' 'gnome-shell' 'all' '1' 'Provides: notification-daemon'
+
+# The classic solver prefers the last entry in the Packages file, whereas solver3 goes alphabetically
+insertpackage 'unstable' 'cinnamon' 'all' '1' 'Provides: notification-daemon'
+insertpackage 'unstable' 'awesome' 'all' '1' 'Provides: notification-daemon'
+insertpackage 'unstable' 'notification-daemon' 'all' '1'
+
+setupaptarchive
+
+# Forbid more and more preferred choices to inspect the ordering the solver chooses
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+The following additional packages will be installed:
+ gnome-shell
+The following NEW packages will be installed:
+ gnome-shell update-notifier
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst gnome-shell (1 unstable [all])
+Inst update-notifier (1 unstable [all])
+Conf gnome-shell (1 unstable [all])
+Conf update-notifier (1 unstable [all])" apt install update-notifier -s
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+Package 'gnome-shell' is not installed, so not removed
+The following additional packages will be installed:
+ notification-daemon
+The following NEW packages will be installed:
+ notification-daemon update-notifier
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst notification-daemon (1 unstable [all])
+Inst update-notifier (1 unstable [all])
+Conf notification-daemon (1 unstable [all])
+Conf update-notifier (1 unstable [all])" apt install update-notifier gnome-shell- -s
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+Package 'gnome-shell' is not installed, so not removed
+Package 'notification-daemon' is not installed, so not removed
+The following additional packages will be installed:
+ awesome
+The following NEW packages will be installed:
+ awesome update-notifier
+0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
+Inst awesome (1 unstable [all])
+Inst update-notifier (1 unstable [all])
+Conf awesome (1 unstable [all])
+Conf update-notifier (1 unstable [all])" apt install update-notifier gnome-shell- notification-daemon- -s