From: Joerg Jaspert Date: Tue, 24 Feb 2009 18:23:44 +0000 (+0100) Subject: Merge commit 'mhy/master' into merge X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=c682a7a2f6c7cfb4d1e1ea7ff15e698ba55f873d;hp=74cf3b9ed589b4845048f51a96b3d6f50cca94f8;p=dak.git Merge commit 'mhy/master' into merge * commit 'mhy/master': use database to generate suite_architectures list remove debug output allow --maximum argument to clean_suites Signed-off-by: Joerg Jaspert --- diff --git a/dak/clean_suites.py b/dak/clean_suites.py index 5523d633..6b7171fa 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -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() diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 1c258bd5..4dc9d444 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -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)))