]> piware.de Git - bin.git/blob - iso-deb-size-compare
add iso-deb-size-compare
[bin.git] / iso-deb-size-compare
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 import subprocess, sys
5
6 def deb_size_map(iso_path):
7     map = {} # package -> (version, size)
8     isoinfo = subprocess.Popen(['isoinfo', '-lR', '-i', iso_path],
9        stdout=subprocess.PIPE)
10     out = isoinfo.communicate()[0]
11     assert isoinfo.returncode == 0
12
13     for l in out.splitlines():
14         l = l.strip()
15         if not l.endswith('.deb'):
16             continue
17
18         fields = l.split()
19         size = int(fields[4])
20         fname = fields[11]
21
22         (pkg, version, _) = fname.split('_')
23         map[pkg] = (version, size)
24
25     return map
26
27 #
28 # main
29 #    
30
31 if len(sys.argv) != 3:
32     print >> sys.stderr, 'Usage: %s <old iso> <new iso>' % sys.argv[0]
33     sys.exit(1)
34
35 old_map = deb_size_map(sys.argv[1])
36 new_map = deb_size_map(sys.argv[2])
37
38 print '== Removed packages =='
39 sum = 0
40 for p, (v, s) in old_map.iteritems():
41     if p not in new_map:
42         print '%s (%.1f MB)' % (p, s / 1000000.)
43         sum += s
44 print 'TOTAL: -%.1f MB' % (sum/1000000.)
45
46 sum = 0
47 print '\n== Added packages =='
48 for p, (v, s) in new_map.iteritems():
49     if p not in old_map:
50         print '%s (%.1f MB)' % (p, s / 1000000.)
51         sum += s
52 print 'TOTAL: +%.1f MB' % (sum/1000000.)
53
54 print '\n== Changed packages =='
55 sum = 0
56 for p, (v, s) in old_map.iteritems():
57     if p not in new_map:
58         continue
59
60     new_s = new_map[p][1]
61     sum += new_s - s
62
63     # only show differences > 100 kB to filter out noise
64     if new_s - s > 100000:
65         print '%s (Δ %.1f MB - %s: %.1f MB   %s: %.1f MB)' % (
66         p, (new_s-s)/1000000., v, s/1000000., new_map[p][0], new_s/1000000.)
67
68 print 'TOTAL difference: %.1f MB' % (sum/1000000.)