#! /usr/bin/python # # File: # Author: Toshio Kuratomi # Date: # Copyright: Toshio Kuratomi # License: GPL # Description: # Id: $Id$ """ """ __version__ = "0.1" __revision__ = "$Revision$" import sys, os, re if __name__ == "__main__": rpmRE = re.compile(r'^(.*)\.rpm$') cpioDeltaRE = re.compile(r'^([-_a-zA-Z]+)(-[0-9].*\.cpio\.delta)$') headerDeltaRE = re.compile(r'^([-_a-zA-Z]+)(-[0-9].*\.header\.delta)$') # Get directory listing dirlisting=os.listdir(".") rpms={} for file in dirlisting: match = rpmRE.search(file) if match: base=match.group(1) # Use the rpm files as keys into a dict rpms[base]={} rpms[base]["rpmSize"] = os.stat(file).st_size for file in dirlisting: match=cpioDeltaRE.search(file) if match: base=match.group(1) # Record (rpmSize, cpio.patchSize, header.patchSize) rpms[base]["cpioDeltaSize"] = os.stat(match.group()).st_size continue match=headerDeltaRE.search(file) if match: base=match.group(1) rpms[base]["headerDeltaSize"] = os.stat(match.group()).st_size totalRPM=0 totalDelta=0 for file in (rpms.keys()): rpms[file]["deltaSize"]=rpms[file]["cpioDeltaSize"]+rpms[file]["headerDeltaSize"] rpms[file]["savingsPercent"]=100.0*rpms[file]["deltaSize"]/rpms[file]["rpmSize"] totalRPM+=rpms[file]["rpmSize"] totalDelta+=rpms[file]["deltaSize"] print "%25s:%7.2lf%% of original:%7.2lf%% savings" % (file, rpms[file]["savingsPercent"], 100-rpms[file]["savingsPercent"]) print "Total RPM Size:",totalRPM," Total Delta Size:",totalDelta print " Total Savings:",totalRPM-totalDelta," %7.2lf%% savings" % (100-100.0*totalDelta/totalRPM,)