diff options
| author | Julian Andres Klode <jak@debian.org> | 2024-11-11 11:59:03 +0000 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2024-11-11 11:59:03 +0000 |
| commit | 9a44f3b318d6b7017d1d3dde02b884c906195c86 (patch) | |
| tree | 768ac005d38e38d84ae93efe003bd98fefc72954 /test | |
| parent | 1fecaeb8293a3980f6fff312cb1d9f159e7c6b28 (diff) | |
| parent | 2f5aab4afaa61ec9b9c690dea4a0b7d650bb2374 (diff) | |
Merge branch 'keep-more' into 'main'
Fix keeping back removals of obsolete packages
See merge request apt-team/apt!373
Diffstat (limited to 'test')
| -rw-r--r-- | test/integration/solver3.broken | 1 | ||||
| -rwxr-xr-x | test/integration/test-resolve-by-keep-obsolete-removals | 47 | ||||
| -rw-r--r-- | test/interactive-helper/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | test/interactive-helper/testkeep.cc | 57 |
4 files changed, 107 insertions, 0 deletions
diff --git a/test/integration/solver3.broken b/test/integration/solver3.broken index 75ddbe5df..dd06ed0eb 100644 --- a/test/integration/solver3.broken +++ b/test/integration/solver3.broken @@ -26,6 +26,7 @@ test-phased-updates-upgrade test-prevent-markinstall-multiarch-same-versionscrew test-release-candidate-switching test-resolve-by-keep-new-recommends +test-resolve-by-keep-obsolete-removals test-ubuntu-bug-1304403-obsolete-priority-standard test-ubuntu-bug-1990586 test-ubuntu-bug-2025462-phased-dist-upgrade diff --git a/test/integration/test-resolve-by-keep-obsolete-removals b/test/integration/test-resolve-by-keep-obsolete-removals new file mode 100755 index 000000000..3fe824f25 --- /dev/null +++ b/test/integration/test-resolve-by-keep-obsolete-removals @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +TESTDIR="$(readlink -f "$(dirname "$0")")" +. "$TESTDIR/framework" +setupenvironment + +configarchitecture "amd64" + +insertpackage 'installed' 'obsolete-dependency' 'amd64' '1.0' +insertpackage 'installed,unstable' 'foo' 'amd64' '2.0' 'Depends: obsolete-dependency' + +setupaptarchive + +echo 'Debug::pkgProblemResolver "1";' > rootdir/etc/apt/apt.conf.d/debug-problemresolver + +# We mark obsolete dependency for removal in B, then in C it is restored. +testsuccessequal "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 mR > +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 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 diff --git a/test/interactive-helper/CMakeLists.txt b/test/interactive-helper/CMakeLists.txt index 8e8764353..bfca6c8f6 100644 --- a/test/interactive-helper/CMakeLists.txt +++ b/test/interactive-helper/CMakeLists.txt @@ -14,6 +14,8 @@ add_executable(mthdcat mthdcat.cc) target_link_libraries(mthdcat ${APTPKG_LIB}) add_executable(testdeb testdeb.cc) target_link_libraries(testdeb ${APTPKG_LIB}) +add_executable(testkeep testkeep.cc) +target_link_libraries(testkeep ${APTPKG_LIB}) add_executable(extract-control extract-control.cc) target_link_libraries(extract-control ${APTPKG_LIB}) add_executable(aptwebserver aptwebserver.cc) diff --git a/test/interactive-helper/testkeep.cc b/test/interactive-helper/testkeep.cc new file mode 100644 index 000000000..f65f43203 --- /dev/null +++ b/test/interactive-helper/testkeep.cc @@ -0,0 +1,57 @@ +#include <config.h> + +#include <apt-pkg/init.h> +#include <apt-pkg/algorithms.h> +#include <apt-pkg/cachefile.h> +#include <apt-pkg/error.h> +#include <apt-pkg/pkgsystem.h> +#include <apt-pkg/prettyprinters.h> + +#include <iostream> +#include <string> + +static bool test(const char *name, bool hold) +{ + pkgCacheFile cache; + if (not cache.Open()) + return false; + + for (auto Pkg = cache->PkgBegin(); Pkg.end() == false; ++Pkg) + std::cout << "A: " << APT::PrettyPkg(cache, Pkg) << std::endl; + + cache->MarkDelete(cache->FindPkg(name)); + if (hold) + cache->MarkProtected(cache->FindPkg(name)); + + for (auto Pkg = cache->PkgBegin(); Pkg.end() == false; ++Pkg) + std::cout << "B: " << APT::PrettyPkg(cache, Pkg) << std::endl; + + pkgProblemResolver resolve(cache); + bool res = resolve.ResolveByKeep(); + + for (auto Pkg = cache->PkgBegin(); Pkg.end() == false; ++Pkg) + std::cout << "C: " << APT::PrettyPkg(cache, Pkg) << std::endl; + + return res; +} + +int main(int argc, const char *argv[]) +{ + if (argc != 2 && argc != 3) + { + return _error->Error("Expected one argument"); + goto err; + } + if (not pkgInitConfig(*_config)) + goto err; + if (not pkgInitSystem(*_config, _system)) + goto err; + if (not test(argv[1], argc > 2 && strcmp(argv[2], "--hold") == 0)) + goto err; + + return 0; +err: + _error->DumpErrors(); + return 1; +} + |
