]> git.decadent.org.uk Git - dak.git/blobdiff - dak/check_overrides.py
Kill unused OverrideType from the config file
[dak.git] / dak / check_overrides.py
index 2987f9be10978ff58a2abc22f287a92d8bfb47e7..523cdefe52f4e85dfd62369d4cd4066fffdf132b 100755 (executable)
@@ -1,8 +1,14 @@
 #!/usr/bin/env python
 
-""" Cruft checker and hole filler for overrides """
-# Copyright (C) 2000, 2001, 2002, 2004, 2006  James Troup <james@nocrew.org>
-# Copyright (C) 2005  Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
+""" Cruft checker and hole filler for overrides
+
+@contact: Debian FTPMaster <ftpmaster@debian.org>
+@copyright: 2000, 2001, 2002, 2004, 2006  James Troup <james@nocrew.org>
+@opyright: 2005  Jeroen van Wolffelaar <jeroen@wolffelaar.nl>
+@copyright: 2011  Joerg Jaspert <joerg@debian.org>
+@license: GNU General Public License version 2 or later
+
+"""
 
 # 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
@@ -58,8 +64,8 @@ from daklib import utils
 
 ################################################################################
 
-Options = None
-Logger = None
+Options = None                 #: Commandline arguments parsed into this
+Logger = None                  #: Our logging object
 sections = {}
 priorities = {}
 blacklist = {}
@@ -150,7 +156,8 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
                 if not Options["No-Action"]:
                     session.execute("""DELETE FROM override WHERE package = :package
                                           AND suite = :suite_id AND component = :component_id
-                                          AND type = :type_id""",
+                                          AND type = :type_id
+                                          AND created < now() - interval '14 days'""",
                                     {'package': package, 'suite_id': osuite_id,
                                      'component_id': component_id, 'type_id': type_id})
         # create source overrides based on binary overrides, as source
@@ -239,7 +246,8 @@ SELECT s.source FROM source s, src_associations sa, files f, location l,
                 if not Options["No-Action"]:
                     session.execute("""DELETE FROM override
                                         WHERE package = :package AND suite = :suite_id
-                                          AND component = :component_id AND type = :type_id""",
+                                          AND component = :component_id AND type = :type_id
+                                          AND created < now() - interval '14 days'""",
                                     {'package': package, 'suite_id': osuite_id,
                                      'component_id': component_id, 'type_id': type_id})
 
@@ -333,9 +341,9 @@ def main ():
         priorities[entry] = name
 
     if not Options["No-Action"]:
-        Logger = daklog.Logger(cnf, "check-overrides")
+        Logger = daklog.Logger("check-overrides")
     else:
-        Logger = daklog.Logger(cnf, "check-overrides", 1)
+        Logger = daklog.Logger("check-overrides", 1)
 
     for osuite in cnf.SubTree("Check-Overrides::OverrideSuites").List():
         if "1" != cnf["Check-Overrides::OverrideSuites::%s::Process" % osuite]:
@@ -353,29 +361,26 @@ def main ():
             pass
 
         print "Processing %s%s..." % (osuite, originremark)
+        suiteobj = get_suite(osuite)
         # Get a list of all suites that use the override file of 'osuite'
-        ocodename = cnf["Suite::%s::codename" % osuite].lower()
-        suites = []
-        suiteids = []
-        for suite in cnf.SubTree("Suite").List():
-            if ocodename == cnf["Suite::%s::OverrideCodeName" % suite].lower():
-                suites.append(suite)
-                s = get_suite(suite.lower(), session)
-                if s is not None:
-                    suiteids.append(s.suite_id)
-
-        if len(suiteids) != len(suites) or len(suiteids) < 1:
-            utils.fubar("Couldn't find id's of all suites: %s" % suites)
+        ocodename = suiteobj.codename
+        suiteids = [x.suite_id for x in session.query(Suite).filter(Suite.overridecodename == ocodename).all()]
+
+        if len(suiteids) < 1:
+            utils.fubar("Couldn't find id's of all suites: %s" % suiteids)
 
         for component in cnf.SubTree("Component").List():
             # It is crucial for the dsc override creation based on binary
             # overrides that 'dsc' goes first
-            otypes = cnf.ValueList("OverrideType")
-            otypes.remove("dsc")
-            otypes = ["dsc"] + otypes
+            otypes = ['dsc']
+            for ot in session.query(OverrideType):
+                if ot.overridetype == 'dsc':
+                    continue
+                otypes.append(ot.overridetype)
+
             for otype in otypes:
-                print "Processing %s [%s - %s] using %s..." \
-                    % (osuite, component, otype, suites)
+                print "Processing %s [%s - %s]" \
+                    % (osuite, component, otype)
                 sys.stdout.flush()
                 process(osuite, suiteids, originosuite, component, otype, session)