X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fcheck_overrides.py;h=e833aa75ff4a479b420ac6b82e97554c12e1877c;hb=7307848b321c5c4f05c87ee18a049163ef299ed1;hp=5cccfb6bbf07a6a69e2026db1f330d1b25d8a86b;hpb=0dada7c5846e0ae676bbe0b81c1065fe75ca9b86;p=dak.git diff --git a/dak/check_overrides.py b/dak/check_overrides.py index 5cccfb6b..e833aa75 100755 --- a/dak/check_overrides.py +++ b/dak/check_overrides.py @@ -1,8 +1,14 @@ #!/usr/bin/env python -""" Cruft checker and hole filler for overrides """ -# Copyright (C) 2000, 2001, 2002, 2004, 2006 James Troup -# Copyright (C) 2005 Jeroen van Wolffelaar +""" Cruft checker and hole filler for overrides + +@contact: Debian FTPMaster +@copyright: 2000, 2001, 2002, 2004, 2006 James Troup +@opyright: 2005 Jeroen van Wolffelaar +@copyright: 2011 Joerg Jaspert +@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 = {} @@ -77,11 +83,6 @@ Check for cruft in overrides. ################################################################################ -def gen_blacklist(dir): - for entry in os.listdir(dir): - entry = entry.split('_')[0] - blacklist[entry] = 1 - def process(osuite, affected_suites, originosuite, component, otype, session): global Logger, Options, sections, priorities @@ -155,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 @@ -244,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}) @@ -288,7 +291,7 @@ SELECT s.source FROM source s, src_associations sa, files f, location l, # we can copy packages[package] = 1 Logger.log(["copying missing override", osuite, component, - type, package, priorities[i[1]], sections[i[2]], i[3]]) + otype, package, priorities[i[1]], sections[i[2]], i[3]]) if not Options["No-Action"]: session.execute("""INSERT INTO override (package, suite, component, priority, section, type, maintainer) @@ -338,53 +341,48 @@ 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 suite in session.query(Suite).filter(Suite.overrideprocess==True): + originosuite = None + originremark = '' - gen_blacklist(cnf["Dir::Queue::Accepted"]) + if suite.overrideorigin is not None: + originosuite = get_suite(suite.overrideorigin, session) + if originosuite is None: + utils.fubar("%s has an override origin suite of %s but it doesn't exist!" % (suite.suite_name, suite.overrideorigin)) + originosuite = originosuite.suite_name + originremark = " taking missing from %s" % originosuite - for osuite in cnf.SubTree("Check-Overrides::OverrideSuites").List(): - if "1" != cnf["Check-Overrides::OverrideSuites::%s::Process" % osuite]: - continue + print "Processing %s%s..." % (suite.suite_name, originremark) - osuite = osuite.lower() + # Get a list of all suites that use the override file of 'suite.suite_name' as + # well as the suite + ocodename = suite.codename + suiteids = [x.suite_id for x in session.query(Suite).filter(Suite.overridecodename == ocodename).all()] + if suite.suite_id not in suiteids: + suiteids.append(suite.suite_id) - originosuite = None - originremark = "" - try: - originosuite = cnf["Check-Overrides::OverrideSuites::%s::OriginSuite" % osuite] - originosuite = originosuite.lower() - originremark = " taking missing from %s" % originosuite - except KeyError: - pass - - print "Processing %s%s..." % (osuite, originremark) - # 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) - - for component in cnf.SubTree("Component").List(): + if len(suiteids) < 1: + utils.fubar("Couldn't find id's of all suites: %s" % suiteids) + + for component in session.query(Component).all(): # 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 + component_name = component.component_name + 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]" \ + % (suite.suite_name, component_name, otype) sys.stdout.flush() - process(osuite, suiteids, originosuite, component, otype, session) + process(suite.suite_name, suiteids, originosuite, component_name, otype, session) Logger.close()