Fetching contributors…
Cannot retrieve contributors at this time
executable file 37 lines (28 sloc) 990 Bytes
import sys
import os
import apt
def printUsage():
print """Usage: \"%s\"
It shows the difference in installed-size of all installed debian packages during the
next upgrade in MB.
On interactive use only the most 15 bloated packages are shown.
In a pipe information about all packages is output to stdout.
""" % os.path.basename(sys.argv[0])
if len(sys.argv) >1:
cache = apt.Cache()
is_tty = os.isatty(sys.stdout.fileno())
packages = [ i for i in cache if i.is_upgradable == 1 ]
package_upgrade_size = [] # [(size, package_name), ...]
for p in packages:
diff_isize = p.candidate.installed_size/1024 - p.installed.installed_size/1024
package_upgrade_size.sort(key=lambda i: i.__getitem__(0))
if is_tty:
output_list = package_upgrade_size[-15:len(package_upgrade_size)]
output_list = package_upgrade_size
for i in output_list:
print "%s %s" %(i)