summaryrefslogtreecommitdiffstats
path: root/livesizediff.py
blob: 195f58bf04db061a7702c3d2321f56b7dec7611f (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
#!/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)

for (pkg, size) in newpkgs.items():
    if not oldpkgs.has_key(pkg):
        print "new package %s: %s" %(pkg, size)
        continue
    oldsize = oldpkgs[pkg]
    if oldsize == "0":
        continue
    deltapct = (int(size) - int(oldsize)) / float(oldsize)
    if deltapct > THRESH:
        print "%s grew by %.2f%% (%s->%s)" %(pkg, deltapct*100, oldsize, size)

print "old has %d packages" %(len(oldpkgs),)
print "new has %d packages" %(len(newpkgs),)