]> git.decadent.org.uk Git - dak.git/blobdiff - rhona
added extra overrides for testing too
[dak.git] / rhona
diff --git a/rhona b/rhona
index e3f5c022a2dfcf353e0e6d5183f5cc37ed3576e8..c7ee05bc92909685ee9b15125bb4314d293549e2 100755 (executable)
--- a/rhona
+++ b/rhona
@@ -2,7 +2,7 @@
 
 # rhona, cleans up unassociated binary and source packages
 # Copyright (C) 2000, 2001  James Troup <james@nocrew.org>
-# $Id: rhona,v 1.14 2001-05-31 02:19:30 troup Exp $
+# $Id: rhona,v 1.16 2001-06-22 23:30:21 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
@@ -39,9 +39,6 @@ projectB = None
 Cnf = None
 now_date = None;     # mark newly "deleted" things as deleted "now"
 delete_date = None;  # delete things marked "deleted" earler than this
-overrides = {};
-
-tried_too_hard_exc = "Tried too hard to find a free filename for %s; something's gone Pete Tong";
 
 ###################################################################################################
 
@@ -54,20 +51,7 @@ def usage (exit_code):
     sys.exit(exit_code)
 
 ###################################################################################################
-
-def find_next_free (dest):
-    extra = 0;
-    orig_dest = dest;
-    too_much = 100;
-    while os.path.exists(dest) and extra < too_much:
-        dest = orig_dest + '.' + repr(extra);
-        extra = extra + 1;
-    if extra >= too_much:
-        raise tried_too_hard_exc;
-    return dest;
     
-# FIXME: why can't we make (sane speed) UPDATEs out of these SELECTs?
-
 def check_binaries():
     global delete_date, now_date;
     
@@ -106,8 +90,7 @@ def check_sources():
 
     print "Checking for orphaned source packages..."
 
-    # Get the list of source packages not in a suite and not linked to
-    # by any binary packages.
+    # Get the list of source packages not in a suite.
 
     q = projectB.query("""
 SELECT s.id, s.file FROM source s
@@ -219,7 +202,7 @@ def clean():
     for i in q.getresult():
         filename = i[0] + i[1];
         if not os.path.exists(filename):
-            sys.stderr.write("E: can not find %s.\n" % (filename));
+            utils.warn("can not find '%s'." % (filename));
             continue;
         if os.path.isfile(filename):
             if os.path.islink(filename):
@@ -235,15 +218,14 @@ def clean():
                 dest_filename = dest + '/' + os.path.basename(filename);
                 # If the destination file exists; try to find another filename to use
                 if os.path.exists(dest_filename):
-                    dest_filename = find_next_free(dest_filename);
+                    dest_filename = utils.find_next_free(dest_filename);
                 
                 if Cnf["Rhona::Options::No-Action"]:
                     print "Cleaning %s -> %s ..." % (filename, dest_filename);
                 else:
                     utils.move(filename, dest_filename);
         else:
-            sys.stderr.write("%s is neither symlink nor file?!\n" % (filename));
-            sys.exit(1);
+            utils.fubar("%s is neither symlink nor file?!" % (filename));
             
     # Delete from the 'files' table
     if not Cnf["Rhona::Options::No-Action"]:
@@ -300,10 +282,6 @@ def main():
         print "rhona version 0.0000000000";
         usage(0);
 
-    override_filename = Cnf["Dir::OverrideDir"] + Cnf["Rhona::OverrideFilename"];
-    if not os.access(override_filename, os.R_OK):
-        sys.stderr.write("W: Could not find source-only override file '%s'.\n" % (override_filename));
-
     now_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()));
     delete_date = time.strftime("%Y-%m-%d %H:%M", time.localtime(time.time()-int(Cnf["Rhona::StayOfExecution"])));