X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fexamine_package.py;h=ba2855d4aacdc3f9f567aca92b5c8d4f17e9fe0e;hb=164bd4615cb96a8b8d5bac8d67c0b5c57a7f64e2;hp=1749bb20a95038bbcede981ace19c7c50cfaf1a8;hpb=06ce98c8111a8b09e5603dbbd34324a216412d69;p=dak.git diff --git a/dak/examine_package.py b/dak/examine_package.py index 1749bb20..ba2855d4 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -32,10 +32,9 @@ ################################################################################ -import errno, os, re, sys -import dak.lib.utils +import errno, os, pg, re, sys, md5 import apt_pkg, apt_inst -import pg, dak.lib.database +import daklib.database, daklib.utils ################################################################################ @@ -79,9 +78,11 @@ maintainer_colour = arch_colour Cnf = None projectB = None -Cnf = dak.lib.utils.get_conf() +Cnf = daklib.utils.get_conf() projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) -dak.lib.database.init(Cnf, projectB) +daklib.database.init(Cnf, projectB) + +printed_copyrights = {} ################################################################################ @@ -144,7 +145,7 @@ def read_control (filename): maintainer = '' arch = '' - deb_file = dak.lib.utils.open_file(filename) + deb_file = daklib.utils.open_file(filename) try: extracts = apt_inst.debExtractControl(deb_file) control = apt_pkg.ParseSection(extracts) @@ -195,9 +196,9 @@ def read_control (filename): def read_dsc (dsc_filename): dsc = {} - dsc_file = dak.lib.utils.open_file(dsc_filename) + dsc_file = daklib.utils.open_file(dsc_filename) try: - dsc = dak.lib.utils.parse_changes(dsc_filename) + dsc = daklib.utils.parse_changes(dsc_filename) except: print "can't parse control info" dsc_file.close() @@ -303,7 +304,15 @@ def print_copyright (deb_filename): return o = os.popen("ar p %s data.tar.gz | tar xzOf - %s" % (deb_filename, copyright)) - print o.read() + copyright = o.read() + copyrightmd5 = md5.md5(copyright).hexdigest() + + if printed_copyrights.has_key(copyrightmd5): + print "Copyright is the same as %s.\n" % \ + (printed_copyrights[copyrightmd5]) + else: + print copyright + printed_copyrights[copyrightmd5] = "%s (%s)" % (package, deb_filename) def check_dsc (dsc_filename): print "---- .dsc file for %s ----" % (dsc_filename) @@ -346,7 +355,7 @@ def check_deb (deb_filename): # Read a file, strip the signature and return the modified contents as # a string. def strip_pgp_signature (filename): - file = dak.lib.utils.open_file (filename) + file = daklib.utils.open_file (filename) contents = "" inside_signature = 0 skip_next = 0 @@ -379,8 +388,8 @@ def display_changes (changes_filename): def check_changes (changes_filename): display_changes(changes_filename) - changes = dak.lib.utils.parse_changes (changes_filename) - files = dak.lib.utils.build_file_list(changes) + changes = daklib.utils.parse_changes (changes_filename) + files = daklib.utils.build_file_list(changes) for file in files.keys(): if file.endswith(".deb") or file.endswith(".udeb"): check_deb(file) @@ -391,7 +400,7 @@ def check_changes (changes_filename): def main (): global Cnf, projectB, db_files, waste, excluded -# Cnf = dak.lib.utils.get_conf() +# Cnf = daklib.utils.get_conf() Arguments = [('h',"help","Examine-Package::Options::Help")] for i in [ "help" ]: @@ -421,19 +430,19 @@ def main (): elif file.endswith(".dsc"): check_dsc(file) else: - dak.lib.utils.fubar("Unrecognised file type: '%s'." % (file)) + daklib.utils.fubar("Unrecognised file type: '%s'." % (file)) finally: # Reset stdout here so future less invocations aren't FUBAR less_fd.close() sys.stdout = stdout_fd except IOError, e: if errno.errorcode[e.errno] == 'EPIPE': - dak.lib.utils.warn("[examine-package] Caught EPIPE; skipping.") + daklib.utils.warn("[examine-package] Caught EPIPE; skipping.") pass else: raise except KeyboardInterrupt: - dak.lib.utils.warn("[examine-package] Caught C-c; skipping.") + daklib.utils.warn("[examine-package] Caught C-c; skipping.") pass #######################################################################################