X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=rhona;h=c5e63df0cad7d0be6a6bc67eec947b5e3ccb2278;hb=336e084aeebe6c6c6f07b8c9172a7fe8fb93487f;hp=7c5dbb29011b381d6b52ba8d1ff44b6144143327;hpb=2a81cd17935def39fc82875aca2b0e61c8ff9eb5;p=dak.git diff --git a/rhona b/rhona index 7c5dbb29..c5e63df0 100755 --- a/rhona +++ b/rhona @@ -2,7 +2,7 @@ # rhona, cleans up unassociated binary and source packages # Copyright (C) 2000, 2001 James Troup -# $Id: rhona,v 1.19 2001-11-24 18:42:10 troup Exp $ +# $Id: rhona,v 1.21 2002-04-22 11:06:49 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ ################################################################################ -import os, pg, stat, string, sys, time +import os, pg, stat, sys, time import apt_pkg import utils @@ -237,6 +237,8 @@ def clean(): if count > 0: sys.stderr.write("Cleaned %d files, %s.\n" % (count, utils.size_type(size))); +################################################################################ + def clean_maintainers(): print "Cleaning out unused Maintainer entries..." @@ -260,6 +262,29 @@ SELECT m.id FROM maintainer m ################################################################################ +def clean_fingerprints(): + print "Cleaning out unused fingerprint entries..." + + q = projectB.query(""" +SELECT f.id FROM fingerprint f + WHERE NOT EXISTS (SELECT id FROM binaries b WHERE b.sig_fpr = f.id) + AND NOT EXISTS (SELECT id FROM source s WHERE s.sig_fpr = f.id)"""); + ql = q.getresult(); + + count = 0; + projectB.query("BEGIN WORK"); + for i in ql: + fingerprint_id = i[0]; + if not Options["No-Action"]: + projectB.query("DELETE FROM fingerprint WHERE id = %s" % (fingerprint_id)); + count = count + 1; + projectB.query("COMMIT WORK"); + + if count > 0: + sys.stderr.write("Cleared out %d fingerprint entries.\n" % (count)); + +################################################################################ + def main(): global Cnf, Options, projectB, delete_date, now_date; @@ -288,6 +313,7 @@ def main(): check_files(); clean(); clean_maintainers(); + clean_fingerprints(); ################################################################################