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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/usr/bin/python -tt
# takes two manifest files and compares to find where things grew
# manifests should be created with
# rpm -qa --qf "%{SIZE}\t%{NAME}\n"
#
import os, sys, string
THRESH = 0.01
def readfile(fn):
pkgs = {}
f = open(fn, "r")
lines = f.readlines()
f.close()
for l in lines:
(size, name) = l.split()
pkgs[name] = size
return pkgs
old = sys.argv[1]
new = sys.argv[2]
oldpkgs = readfile(old)
newpkgs = readfile(new)
newlist = []
gonelist = []
growths = []
shrinkage = []
for (pkg, size) in newpkgs.items():
if not oldpkgs.has_key(pkg):
newlist.append((pkg, int(size)))
#print "new package %s: %s" %(pkg, size)
continue
oldsize = oldpkgs[pkg]
if oldsize == "0":
continue
if size > oldsize:
deltapct = (int(size) - int(oldsize)) / float(oldsize)
if deltapct > THRESH:
growths.append((pkg, int(size) - int(oldsize), deltapct*100, oldsize, size))
#print "%s grew by %.2f%% (%s->%s)" %(pkg, deltapct*100, oldsize, size)
elif size < oldsize:
deltapct = (int(oldsize) - int(size)) / float(size)
if deltapct > THRESH:
shrinkage.append((pkg, int(oldsize) - int(size), deltapct*100, oldsize, size))
#print "%s shrank by %.2f%% (%s->%s)" %(pkg, deltapct*100, oldsize, size)
for (pkg, size) in oldpkgs.items():
if not newpkgs.has_key(pkg):
gonelist.append((pkg, int(size)))
print "old has %d packages" %(len(oldpkgs),)
print "new has %d packages" %(len(newpkgs),)
growths.sort(key=lambda x: -x[1])
shrinkage.sort(key=lambda x: -x[1])
newlist.sort(key=lambda x: -x[1])
gonelist.sort(key=lambda x: -x[1])
print "\nGrowths:"
for growth in growths:
print "%s grew by %s (%.2f%%) (%s->%s)" % growth
print "\nShrinkage:"
for shrink in shrinkage:
print "%s shrank by %s (%.2f%%) (%s->%s)" % shrink
print "\nNew packages:"
for new in newlist:
print "%s: %s" % new
print "\nRemoved packages:"
for gone in gonelist:
print "%s: %s" % gone
|