summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-07-01 16:27:15 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2024-07-01 16:28:53 +0200
commitb636668788fe8b1f7183b21eaf7b87f34209169e (patch)
tree0b8db4d36be442227318780bd4665fe948a81433
parent053c889838bdc2c6efd3a542ec3dfd547a5df53e (diff)
solver3: Do not accidentally promote Replaces and Enhances to dependencies
As part of the refactoring, we allowed the code to work on unimportant dependencies as we needed to promote Suggests to Depends if they are currently satisfied. However, Replaces and Enhances were not considered properly and both are not negative dependencies so they were accidentally promoted to Depends too if they were currently satisfied.
-rw-r--r--apt-pkg/solver3.cc4
-rwxr-xr-xtest/integration/test-solver3-dependencies65
2 files changed, 68 insertions, 1 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index dc70adbde..f94fa6736 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -480,7 +480,9 @@ bool APT::Solver::EnqueueOrGroup(pkgCache::DepIterator start, pkgCache::DepItera
// below once we have calculated all possible solutions.
if (start.ParentPkg()->CurrentVer == 0 && not policy.IsImportantDep(start))
return true;
-
+ // Replaces and Enhances are not a real dependency.
+ if (start->Type == pkgCache::Dep::Replaces || start->Type == pkgCache::Dep::Enhances)
+ return true;
if (unlikely(debug >= 3))
std::cerr << "Found dependency critical " << Ver.ParentPkg().FullName() << "=" << Ver.VerStr() << " -> " << start.TargetPkg().FullName() << "\n";
diff --git a/test/integration/test-solver3-dependencies b/test/integration/test-solver3-dependencies
new file mode 100755
index 000000000..330ded8f9
--- /dev/null
+++ b/test/integration/test-solver3-dependencies
@@ -0,0 +1,65 @@
+#!/bin/sh
+set -e
+
+TESTDIR="$(readlink -f "$(dirname "$0")")"
+. "$TESTDIR/framework"
+setupenvironment
+configarchitecture 'amd64'
+
+insertinstalledpackage 'replaces' 'all' '2' 'Replaces: replaced (<< 3)'
+insertinstalledpackage 'replaced' 'all' '2'
+
+insertinstalledpackage 'enhances' 'all' '2' 'Enhances: enhanced (<< 3)'
+insertinstalledpackage 'enhanced' 'all' '2'
+
+insertpackage 'unstable' 'replaces' 'all' '3' 'Replaces: replaced (<< 3)'
+insertpackage 'unstable' 'enhances' 'all' '3' 'Enhances: enhanced (<< 3)'
+insertpackage 'unstable' 'replaced' 'all' '3'
+insertpackage 'unstable' 'enhanced' 'all' '3'
+
+setupaptarchive
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+Calculating upgrade...
+The following packages will be upgraded:
+ enhanced enhances replaced replaces
+4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst enhanced [2] (3 unstable [all])
+Inst enhances [2] (3 unstable [all])
+Inst replaced [2] (3 unstable [all])
+Inst replaces [2] (3 unstable [all])
+Conf enhanced (3 unstable [all])
+Conf enhances (3 unstable [all])
+Conf replaced (3 unstable [all])
+Conf replaces (3 unstable [all])" aptget upgrade -s
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+Calculating upgrade...
+The following packages will be upgraded:
+ enhanced enhances replaced replaces
+4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst enhanced [2] (3 unstable [all])
+Inst enhances [2] (3 unstable [all])
+Inst replaced [2] (3 unstable [all])
+Inst replaces [2] (3 unstable [all])
+Conf enhanced (3 unstable [all])
+Conf enhances (3 unstable [all])
+Conf replaced (3 unstable [all])
+Conf replaces (3 unstable [all])" apt upgrade -s
+
+testsuccessequal "Reading package lists...
+Building dependency tree...
+Calculating upgrade...
+The following packages will be upgraded:
+ enhanced enhances replaced replaces
+4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+Inst enhanced [2] (3 unstable [all])
+Inst enhances [2] (3 unstable [all])
+Inst replaced [2] (3 unstable [all])
+Inst replaces [2] (3 unstable [all])
+Conf enhanced (3 unstable [all])
+Conf enhances (3 unstable [all])
+Conf replaced (3 unstable [all])
+Conf replaces (3 unstable [all])" apt dist-upgrade -s