X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=rhona;h=877cdb01a9c8e8a82b0805d17063c16446973da3;hb=e8eacb00ee41d7ab974ba913fff40e5c082b8e1a;hp=7b0d931037ffa5288b257e15b9da665945f4fb8a;hpb=bb8283ad6274e461fc78a00b2a52c6594c53e13d;p=dak.git diff --git a/rhona b/rhona index 7b0d9310..877cdb01 100755 --- a/rhona +++ b/rhona @@ -2,7 +2,7 @@ # rhona, cleans up unassociated binary (and source) packages # Copyright (C) 2000 James Troup -# $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 @@ -144,20 +144,23 @@ def check_sources(): 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; @@ -171,6 +174,8 @@ def main(): 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..."