#!/usr/bin/env python
# rhona, cleans up unassociated binary and source packages
-# Copyright (C) 2000, 2001 James Troup <james@nocrew.org>
-# $Id: rhona,v 1.21 2002-04-22 11:06:49 troup Exp $
+# Copyright (C) 2000, 2001, 2002 James Troup <james@nocrew.org>
+# $Id: rhona,v 1.24 2002-05-23 12:18:32 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
################################################################################
+def clean_accepted_autobuild():
+ global now_date;
+
+ if not Cnf.ValueList("Dinstall::AcceptedAutoBuildSuites") or Options["No-Action"]:
+ return;
+
+ print "Cleaning out accepted autobuild symlinks..."
+
+ our_delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::AcceptedAutoBuildStayOfExecution"])));
+ count = 0;
+
+ q = projectB.query("SELECT filename FROM accepted_autobuild 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 accepted_autobuild) doesn't exist." % (filename));
+ continue;
+ if not Cnf.FindB("Dinstall::SecurityAcceptedAutoBuild") and not os.path.islink(filename):
+ utils.fubar("%s (from accepted_autobuild) should be a symlink but isn't." % (filename));
+ os.unlink(filename);
+ count = count + 1;
+ projectB.query("DELETE FROM accepted_autobuild WHERE last_used <= '%s'" % (our_delete_date));
+
+ if count:
+ sys.stderr.write("Cleaned %d accepted-autobuild files.\n" % (count));
+
+################################################################################
+
def main():
global Cnf, Options, projectB, delete_date, now_date;
clean();
clean_maintainers();
clean_fingerprints();
+ clean_accepted_autobuild();
################################################################################