diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
commit | 76926159194e180003aa78de97e5f287bf4325a5 (patch) | |
tree | 2cea7245cdc3f66355900c820c145eba90598766 /tests/old/pkgproblemresolver.py | |
parent | Initial commit. (diff) | |
download | python-apt-76926159194e180003aa78de97e5f287bf4325a5.tar.xz python-apt-76926159194e180003aa78de97e5f287bf4325a5.zip |
Adding upstream version 2.7.6.upstream/2.7.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/old/pkgproblemresolver.py')
-rw-r--r-- | tests/old/pkgproblemresolver.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/old/pkgproblemresolver.py b/tests/old/pkgproblemresolver.py new file mode 100644 index 0000000..89190cf --- /dev/null +++ b/tests/old/pkgproblemresolver.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python2.4 +# +# Test for the DepCache code +# + +import sys + +import apt_pkg + + +def main(): + apt_pkg.init() + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) + depcache.init() + i = 0 + all = cache.package_count + print("Running DepCache test on all packages") + print("(trying to install each and then mark it keep again):") + # first, get all pkgs + for pkg in cache.packages: + i += 1 + x = pkg.name + # then get each version + ver = depcache.get_candidate_ver(pkg) + if ver is not None: + depcache.mark_install(pkg) + if depcache.broken_count > 0: + fixer = apt_pkg.ProblemResolver(depcache) + fixer.clear(pkg) + fixer.protect(pkg) + # we first try to resolve the problem + # with the package that should be installed + # protected + try: + fixer.resolve(True) + except SystemError: + # the pkg seems to be broken, the + # returns a exception + fixer.clear(pkg) + fixer.resolve(True) + if not depcache.marked_install(pkg): + print("broken in archive: %s " % pkg.name) + fixer = None + if depcache.inst_count == 0: + if depcache.is_upgradable(pkg): + print("Error marking %s for install" % x) + for p in cache.packages: + if depcache.marked_install(p) or depcache.marked_upgrade(p): + depcache.mark_keep(p) + if depcache.inst_count != 0: + print("Error undoing the selection for %s" % x) + print("\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100))) + + print() + print("Trying upgrade:") + depcache.upgrade() + print("To install: %s " % depcache.inst_count) + print("To remove: %s " % depcache.del_count) + print("Kept back: %s " % depcache.keep_count) + + print("Trying DistUpgrade:") + depcache.upgrade(True) + print("To install: %s " % depcache.inst_count) + print("To remove: %s " % depcache.del_count) + print("Kept back: %s " % depcache.keep_count) + + +if __name__ == "__main__": + main() + sys.exit(0) |