+################################################################################
+
+def clean_fingerprints():
+ print "Cleaning out unused fingerprint entries..."
+
+ q = projectB.query("""
+SELECT f.id FROM fingerprint f
+ WHERE NOT EXISTS (SELECT 1 FROM binaries b WHERE b.sig_fpr = f.id)
+ AND NOT EXISTS (SELECT 1 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 += 1;
+ projectB.query("COMMIT WORK");
+
+ if count > 0:
+ sys.stderr.write("Cleared out %d fingerprint entries.\n" % (count));
+
+################################################################################
+
+def clean_queue_build():
+ global now_date;
+
+ if not Cnf.ValueList("Dinstall::QueueBuildSuites") or Options["No-Action"]:
+ return;
+
+ print "Cleaning out queue build symlinks..."
+
+ our_delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::QueueBuildStayOfExecution"])));
+ count = 0;
+
+ q = projectB.query("SELECT filename FROM queue_build WHERE last_used <= '%s'" % (our_delete_date));
+ for i in q.getresult():
+ filename = i[0];
+ if not os.path.exists(filename):
+ utils.warn("%s (from queue_build) doesn't exist." % (filename));
+ continue;
+ if not Cnf.FindB("Dinstall::SecurityQueueBuild") and not os.path.islink(filename):
+ utils.fubar("%s (from queue_build) should be a symlink but isn't." % (filename));
+ os.unlink(filename);
+ count += 1;
+ projectB.query("DELETE FROM queue_build WHERE last_used <= '%s'" % (our_delete_date));
+
+ if count:
+ sys.stderr.write("Cleaned %d queue_build files.\n" % (count));
+
+################################################################################
+