blob: 3cc4094e7da5d9b6f3954365ed7673a25f3e4654 (
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
|
#!/usr/bin/python
# example how to deal with the depcache
import apt_pkg
import sys, os
import copy
from apt.progress import OpProgress, FetchProgress, InstallProgress
# init
apt_pkg.init()
progress = OpProgress()
cache = apt_pkg.GetCache(progress)
print "Available packages: %s " % cache.PackageCount
# get depcache
depcache = apt_pkg.GetDepCache(cache)
depcache.ReadPinFile()
depcache.Init(progress)
# do something
fprogress = FetchProgress()
iprogress = InstallProgress()
# can be used to set a custom fork method (like vte.Terminal.forkpty)
#iprogress.fork = os.fork
iter = cache["base-config"]
print "\n%s"%iter
# install or remove, the importend thing is to keep us busy :)
if iter.CurrentVer == None:
depcache.MarkInstall(iter)
else:
depcache.MarkDelete(iter)
res = depcache.Commit(fprogress, iprogress)
print res
print "Exiting"
sys.exit(0)
|