#!/usr/bin/python # # Copyright 2007, Canonical, Daniel Holbach # # GPL 3 import os import sys import glob USAGE = \ """compare-packages [] compares contents of binary packages of in the current directory with those in """ def check_args(): directory = "/var/cache/pbuilder/result" sourcepackage = "" if len(sys.argv) < 2: print USAGE sys.exit(1) if sys.argv[1] in [ '-h', '--help' ]: print USAGE sys.exit(0) if len(sys.argv) > 1: sourcepackage = sys.argv[1] if len(sys.argv) > 2: directory = sys.argv[2] return (sourcepackage, directory) def main(): (sourcepackage, directory) = check_args() (dummy, output, dummy) = os.popen3("apt-cache showsrc %s | grep ^Binary" % \ (sourcepackage)) binarypackages = output.read().split(":")[1].strip().split(", ") if not os.path.exists("/usr/bin/debdiff"): print >> sys.stderr, \ "'/usr/bin/debdiff' not found, please install 'devscripts'." sys.exit(1) if not os.path.isdir(directory): print >> sys.stderr, "Directory %s not found." % directory sys.exit(1) for package in binarypackages: old = glob.glob("./%s*.deb" % package) new = glob.glob("%s/%s*.deb" % (directory, package)) if not new or not old: print "Skipping %s, no matching new and old package found." % package else: print "Comparing %s and %s" % (old[0], new[0]) sys.stdout.flush() os.system("debdiff %s %s" % (old[0], new[0])) print '' print '---' if __name__ == '__main__': main()