]> git.decadent.org.uk Git - dak.git/commitdiff
Merge commit 'mhy/master' into merge
authorJoerg Jaspert <joerg@debian.org>
Tue, 24 Feb 2009 18:23:44 +0000 (19:23 +0100)
committerJoerg Jaspert <joerg@debian.org>
Tue, 24 Feb 2009 18:23:44 +0000 (19:23 +0100)
* commit 'mhy/master':
  use database to generate suite_architectures list
  remove debug output
  allow --maximum argument to clean_suites

Signed-off-by: Joerg Jaspert <joerg@debian.org>
dak/clean_suites.py
dak/generate_releases.py

index 5523d63353bfa34f1eddb44174f6e74b8aed18de..6b7171fa8bf99589e20aae99cd61577e73fbac53 100755 (executable)
@@ -39,6 +39,7 @@ Cnf = None
 Options = None
 now_date = None;     # mark newly "deleted" things as deleted "now"
 delete_date = None;  # delete things marked "deleted" earler than this
+max_delete = None
 
 ################################################################################
 
@@ -47,7 +48,8 @@ def usage (exit_code=0):
 Clean old packages from suites.
 
   -n, --no-action            don't do anything
-  -h, --help                 show this help and exit"""
+  -h, --help                 show this help and exit
+  -m, --maximum              maximum number of files to remove"""
     sys.exit(exit_code)
 
 ################################################################################
@@ -183,7 +185,7 @@ def clean_binaries():
 ########################################
 
 def clean():
-    global delete_date, now_date
+    global delete_date, now_date, max_delete
     count = 0
     size = 0
 
@@ -204,7 +206,11 @@ def clean():
         sys.stdout.write("done. (%d seconds)]\n" % (int(time.time()-before)))
 
     # Delete files from the pool
-    q = projectB.query("SELECT l.path, f.filename FROM location l, files f WHERE f.last_used <= '%s' AND l.id = f.location" % (delete_date))
+    query = "SELECT l.path, f.filename FROM location l, files f WHERE f.last_used <= '%s' AND l.id = f.location" % (delete_data)
+    if max_delete is not None:
+        query += " LIMIT %d" % maximum
+        sys.stdout.write("Limiting removals to %d" % Cnf["Clean-Suites::Options::Maximum"])
+
     for i in q.getresult():
         filename = i[0] + i[1]
         if not os.path.exists(filename):
@@ -321,19 +327,31 @@ def clean_queue_build():
 ################################################################################
 
 def main():
-    global Cnf, Options, projectB, delete_date, now_date
+    global Cnf, Options, projectB, delete_date, now_date, max_delete
 
     Cnf = utils.get_conf()
-    for i in ["Help", "No-Action" ]:
+    for i in ["Help", "No-Action", "Maximum" ]:
         if not Cnf.has_key("Clean-Suites::Options::%s" % (i)):
             Cnf["Clean-Suites::Options::%s" % (i)] = ""
 
     Arguments = [('h',"help","Clean-Suites::Options::Help"),
-                 ('n',"no-action","Clean-Suites::Options::No-Action")]
+                 ('n',"no-action","Clean-Suites::Options::No-Action"),
+                 ('m',"maximum","Clean-Suites::Options::Maximum", "HasArg")]
 
     apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
     Options = Cnf.SubTree("Clean-Suites::Options")
 
+    if Cnf["Clean-Suites::Options::Maximum"] != "":
+        try:
+            # Only use Maximum if it's an integer
+            max_delete = int(Cnf["Clean-Suites::Options::Maximum"])
+            if max_delete < 1:
+                utils.fubar("If given, Maximum must be at least 1")
+        except ValueError, e:
+            utils.fubar("If given, Maximum must be an integer")
+    else:
+        max_delete = None
+
     if Options["Help"]:
         usage()
 
index 1c258bd5c511d292757d59f678d86fcbab0f56b3..4dc9d444de166e5d23a2959041f1884e63cef3a9 100755 (executable)
@@ -26,6 +26,7 @@ import sys, os, stat, time, pg
 import gzip, bz2
 import apt_pkg
 from daklib import utils
+from daklib import database
 from daklib.dak_exceptions import *
 
 ################################################################################
@@ -176,6 +177,10 @@ def main ():
             if qs[0][0] != "-": version = qs[0][0]
             if qs[0][1]: description = qs[0][1]
 
+        architectures = database.get_suite_architectures(suite)
+        if architectures == None:
+            architectures = []
+
         if SuiteBlock.has_key("NotAutomatic"):
             notautomatic = "yes"
         else:
@@ -221,7 +226,7 @@ def main ():
 
         if notautomatic != "":
             out.write("NotAutomatic: %s\n" % (notautomatic))
-        out.write("Architectures: %s\n" % (" ".join(filter(utils.real_arch, SuiteBlock.ValueList("Architectures")))))
+        out.write("Architectures: %s\n" % (" ".join(filter(utils.real_arch, architectures))))
         if components:
             out.write("Components: %s\n" % (" ".join(components)))