#!/usr/bin/python3 import argparse def main(): parser = argparse.ArgumentParser(description="Calculate difference in package sizes") parser.add_argument("fromsizes", help="final sizes from a previous run of the compose") parser.add_argument("tosizes", help="final sizes from a previous run of the compose") args = parser.parse_args() # Read the final package list and sizes (in bytes) fromFile = open(args.fromsizes).read() fromSizes = dict((f.split(":")[0], int(f.split(":")[1].strip())) for f in fromFile.splitlines()) toFile = open(args.tosizes).read() toSizes = dict((f.split(":")[0], int(f.split(":")[1].strip())) for f in toFile.splitlines()) # Calculate size differences totalDiff = 0 for pkg in toSizes: name = pkg.rsplit(".", 1)[0] if pkg not in fromSizes: fromSizes[pkg] = 0 diff = toSizes[pkg]-fromSizes[pkg] print("%-25s %-10d %-10d %-10d" % (name, toSizes[pkg], fromSizes[pkg], diff)) if "i686" not in pkg: totalDiff += diff print("TOTAL DIFFERENCE = %s" % totalDiff) if __name__ == '__main__': main()