# rhona, cleans up unassociated binary (and source) packages
# Copyright (C) 2000 James Troup <james@nocrew.org>
-# $Id: rhona,v 1.2 2000-11-24 04:04:23 troup Exp $
+# $Id: rhona,v 1.3 2000-12-13 03:18:50 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
projectB.query("UPDATE files SET last_used = NULL WHERE id = %s" % (i[0]));
projectB.query("COMMIT WORK");
+def clean_binaries():
+ date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::StayOfExecution"])));
+ print projectB.query("DELETE FROM binaries WHERE file IN (SELECT id FROM files WHERE last_used < '%s')" % (date));
+
def clean():
date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::StayOfExecution"])));
- q = projectB.query("SELECT l.path, f.filename FROM location l, files f WHERE f.last_used < '%s' AND l.id = f.location" % (date))
- ql = q.getresult();
- for i in ql:
+ # Delete from source + dsc_files
+ q = projectB.query("SELECT l.path, f.filename FROM location l, files f WHERE f.last_used < '%s' AND l.id = f.location" % (date));
+ for i in q.getresult():
filename = i[0] + i[1];
- dest = Cnf["Rhona::Morgue"]+os.path.basename(filename);
if not os.path.exists(filename):
sys.stderr.write("E: can not find %s.\n" % (filename));
continue;
- print "Cleaning %s to %s..." % (filename, dest)
+ dest = Cnf["Dir::Morgue"] + '/' + Cnf["Rhona::MorgueSubDir"];
+ print "Cleaning %s to %s..." % (filename, dest);
#utils.move(filename, dest);
- #projectB.query("DELETE FROM binaries WHERE id = %s" % (i[0]));
- #FIXME: need to remove from "or source" + files + dsc_files.. etc.
+ # delete from files
def main():
global Cnf, projectB;
print "Checking for orphaned binary packages..."
check_binaries();
+ print "Cleaning binaries from the DB..."
+ clean_binaries();
print "Checking for orphaned source packages..."
check_sources();
print "Cleaning orphaned packages..."