summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-09-05 14:58:50 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2024-11-11 12:30:01 +0100
commit2f5aab4afaa61ec9b9c690dea4a0b7d650bb2374 (patch)
treeae25c5fc3b1433aa44304aa7bf7670f322b6697e
parent49d3d6b2c3dbc0d30e46131dd288f4e106ea2fe6 (diff)
Return an error if ResolveByKeep() is unsuccessful
In case of held packages or packages that otherwise can't be kept back, we should return an error and not require the client to check the broken_count after calling us. LP: #2078720
-rw-r--r--apt-pkg/algorithms.cc3
-rwxr-xr-xtest/integration/test-resolve-by-keep-obsolete-removals18
2 files changed, 21 insertions, 0 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 6131ecd11..72184748a 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -1423,6 +1423,9 @@ bool pkgProblemResolver::ResolveByKeepInternal()
delete[] PList;
+ if (Cache.BrokenCount() != 0)
+ return _error->Error(_("Unable to correct problems, you have held broken packages."));
+
if (Debug)
Cache.CheckConsistency("keep done");
diff --git a/test/integration/test-resolve-by-keep-obsolete-removals b/test/integration/test-resolve-by-keep-obsolete-removals
index ab08ea81a..3fe824f25 100755
--- a/test/integration/test-resolve-by-keep-obsolete-removals
+++ b/test/integration/test-resolve-by-keep-obsolete-removals
@@ -27,3 +27,21 @@ Package foo:amd64 foo:amd64 Depends on obsolete-dependency:amd64 < 1.0 @ii mR >
Keeping Package obsolete-dependency:amd64 due to Depends
C: foo:amd64 < 2.0 @ii mK >
C: obsolete-dependency:amd64 < 1.0 @ii mK >" runapt ${APTTESTHELPERSBINDIR}/testkeep obsolete-dependency
+
+# We have protected our decision to remove the obsolete dependency, so we fail to resolve it.
+testfailureequal "A: foo:amd64 < 2.0 @ii mK >
+A: obsolete-dependency:amd64 < 1.0 @ii mK >
+B: foo:amd64 < 2.0 @ii mK Ib >
+B: obsolete-dependency:amd64 < 1.0 @ii pmR >
+Entering ResolveByKeep
+ Dependencies are not satisfied for foo:amd64 < 2.0 @ii mK Ib >
+Keeping package foo:amd64
+ Dependencies are not satisfied for foo:amd64 < 2.0 @ii mK Ib >
+Package foo:amd64 foo:amd64 Depends on obsolete-dependency:amd64 < 1.0 @ii pmR >
+ Dependencies are not satisfied for foo:amd64 < 2.0 @ii mK Ib >
+ Dependencies are not satisfied for foo:amd64 < 2.0 @ii mK Ib >
+ Dependencies are not satisfied for foo:amd64 < 2.0 @ii mK Ib >
+ Dependencies are not satisfied for foo:amd64 < 2.0 @ii mK Ib >
+C: foo:amd64 < 2.0 @ii mK Ib >
+C: obsolete-dependency:amd64 < 1.0 @ii pmR >
+E: Unable to correct problems, you have held broken packages." runapt ${APTTESTHELPERSBINDIR}/testkeep obsolete-dependency --hold