8
sys.path.insert(0, "../DistUpgrade")
10
from UpgradeTestBackend import UpgradeTestBackend
11
from UpgradeTestBackendQemu import *
16
if __name__ == "__main__":
19
apt_pkg.Config.Set("APT::Architecture","i386")
21
# FIXME: hardcoding pathes sucks
22
basedir = "./profile/intrepid-auto-install"
23
aptbasedir = os.path.join(basedir,"auto-install-test")
24
profile = os.path.join(basedir, "DistUpgrade.cfg")
25
backend = UpgradeTestBackendQemu(profile, profile)
28
# create dirs if needed
31
"var/lib/apt/lists/partial",
32
"var/cache/apt/archives/partial"]:
33
if not os.path.exists(os.path.join(aptbasedir,d)):
34
os.makedirs(os.path.join(aptbasedir,d))
38
print "copy status file"
39
backend._copyFromImage("/var/lib/dpkg/status",
40
os.path.join(aptbasedir,"var/lib/dpkg/","status"))
43
# build apt stuff (outside of the kvm)
44
mirror = backend.config.get("NonInteractive","Mirror")
45
dist = backend.config.get("Sources","From")
46
components = backend.config.getlist("NonInteractive","Components")
47
pockets = backend.config.getlist("NonInteractive","Pockets")
48
f=open(os.path.join(aptbasedir,"etc","apt","sources.list"),"w")
49
f.write("deb %s %s %s\n" % (mirror, dist, " ".join(components)))
50
for pocket in pockets:
51
f.write("deb %s %s-%s %s\n" % (mirror, dist, pocket, " ".join(components)))
55
cache = apt.Cache(rootdir=os.path.abspath(aptbasedir))
56
cache.update(apt.progress.TextFetchProgress())
57
cache.open(apt.progress.OpProgress())
59
# now test if we can install stuff
61
backend._runInImage(["apt-get","update"])
62
backend.saveVMSnapshot("clean-base")
66
resultdir = os.path.join(basedir,"result")
67
statusfile = open(os.path.join(resultdir,"pkgs_done.txt"),"w")
68
failures = open(os.path.join(resultdir,"failures.txt"),"w")
69
# now see if we can install and remove it again
72
print "\n\nPackage %i of %i (%s)" % (i, len(cache), float(i)/float(len(cache))*100)
74
# skip stuff in the ubuntu-minimal that we can't install or upgrade
75
if pkg.isInstalled and not pkg.isUpgradable:
77
# see if we can install/upgrade the pkg
80
except SystemError, e:
82
if not (pkg.markedInstall or pkg.markedUpgrade):
83
print "pkg: %s not installable" % pkg.name
84
failures.write("%s markInstall()\n " % pkg.name)
86
cache._depcache.Init()
88
statusfile.write("%s\n" % pkg.name)
90
ret = backend._runInImage(["DEBIAN_FRONTEND=noninteractive","apt-get","install", "-y",pkg.name])
91
print "apt returned: ", ret
93
print "apt returned a error"
94
failures.write("%s install (%s)\n" % (pkg.name,ret))
95
# FIXME: bugger, that does not seem to work, I'm unable
96
# to load the state later again when a new instance of
98
#backend.saveVMSnapshot("failed-install-%s" % pkg.name)
100
backend._copyFromImage("/var/log/apt/term.log",os.path.join(basedir,"result","%s-fail.txt" % pkg.name))
101
# now remove it again
102
ret = backend._runInImage(["DEBIAN_FRONTEND=noninteractive","apt-get","autoremove", "-y",pkg.name])
103
print "apt returned: ", ret
105
failures.write("%s remove (%s)\n" % (pkg.name,ret))
106
#backend.saveVMSnapshot("failed-autoremove-%s" % pkg.name)
108
backend._copyFromImage("/var/log/apt/term.log",os.path.join(basedir,"result","%s-fail.txt" % pkg.name))
109
backend.restoreVMSnapshot("clean-base")
113
# all done, stop the backend