blob: 81ca574b0b48ab773aaedd9ae5aed4598bf1bfa8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/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.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):
depcache.mark_keep(p)
if depcache.inst_count != 0:
print(
"Error undoing the selection for %s (inst_count: %s)"
% (x, depcache.inst_count)
)
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)
|