X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fcheck_transitions.py;h=209642587938498d90b94cd15ea286c35d10f2fb;hb=105153673ddf17fa20705d07d73b0f100c577546;hp=089c60efa0c3c658020780619313677650f45de9;hpb=7a7563b8e19f99783505669ba603ef2d534c6603;p=dak.git diff --git a/dak/check_transitions.py b/dak/check_transitions.py index 089c60ef..20964258 100755 --- a/dak/check_transitions.py +++ b/dak/check_transitions.py @@ -23,7 +23,7 @@ ################################################################################ -import os, sys +import os, pg, sys import apt_pkg import daklib.database import daklib.utils @@ -44,24 +44,29 @@ def init(): Cnf = daklib.utils.get_conf() - Arguments = [('h',"help","Dinstall::Options::Help"), - ('n',"no-action","Dinstall::Options::No-Action")] + Arguments = [('h',"help","Check-Transitions::Options::Help"), + ('n',"no-action","Check-Transitions::Options::No-Action")] for i in ["help", "no-action"]: - Cnf["Dinstall::Options::%s" % (i)] = "" + if not Cnf.has_key("Check-Transitions::Options::%s" % (i)): + Cnf["Check-Transitions::Options::%s" % (i)] = "" + + apt_pkg.ParseCommandLine(Cnf, Arguments, sys.argv) + + Options = Cnf.SubTree("Check-Transitions::Options") projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])) daklib.database.init(Cnf, projectB) - Options = Cnf.SubTree("Dinstall::Options") - if Options["Help"]: + if Options["help"]: usage() ################################################################################ def usage (exit_code=0): print """Usage: check_transitions [OPTION]... + Check the release managers transition file for correctness and outdated transitions -h, --help show this help and exit. -n, --no-action don't do anything""" sys.exit(exit_code) @@ -70,6 +75,9 @@ def usage (exit_code=0): def main(): global Cnf + + init() + # Only check if there is a file defined (and existant) with checks. It's a little bit # specific to Debian, not much use for others, so return early there. if not Cnf.has_key("Dinstall::Reject::ReleaseTransitions") or not os.path.exists("%s" % (Cnf["Dinstall::Reject::ReleaseTransitions"])): @@ -79,8 +87,9 @@ def main(): # Parse the yaml file sourcefile = file(Cnf["Dinstall::Reject::ReleaseTransitions"], 'r') + sourcecontent = sourcefile.read() try: - transitions = load(sourcefile) + transitions = load(sourcecontent) except error, msg: # This shouldn't happen, the release team has a wrapper to check the file, but better # safe then sorry @@ -88,10 +97,10 @@ def main(): sys.exit(2) to_dump = 0 - + to_remove = [] # Now look through all defined transitions - for trans in transition: - t = transition[trans] + for trans in transitions: + t = transitions[trans] source = t["source"] new_vers = t["new"] @@ -99,30 +108,40 @@ def main(): curvers = daklib.database.get_testing_version(source) print """ - Looking at transition: %s - Source: %s - New Version: %s - Responsible: %s - Reason: %s - Blocked Packages (total: %d): - """ % (trans, source, new_vers, t["rm"], t["reason"]) - for i in t["packages"]: - print " %s" % (i) - - if curvers and apt_pkg.VersionCompare(new_vers, curvers) == 1: - # This is still valid, the current version in database is older than - # the new version we wait for - print "This transition is still ongoing" +Looking at transition: %s + Source: %s + New Version: %s + Responsible: %s + Description: %s + Blocked Packages (total: %d): %s +""" % (trans, source, new_vers, t["rm"], t["reason"], len(t["packages"]), ", ".join(t["packages"])) + + if curvers == None: + # No package in testing + print "Transition source %s not in testing, transition still ongoing." % (source) else: - print "This transition is over, the target package reached testing, removing" - print "%s wanted version: %s, has %s" % (source, new_vers, curvers) - del transition[trans] - to_dump = 1 + compare = apt_pkg.VersionCompare(curvers, new_vers) + print "Apt compare says: %s" % (compare) + if compare < 0: + # This is still valid, the current version in database is older than + # the new version we wait for + print "This transition is still ongoing, we currently have version %s" % (curvers) + else: + print "This transition is over, the target package reached testing, removing" + print "%s wanted version: %s, has %s" % (source, new_vers, curvers) + to_remove.append(trans) + to_dump = 1 print "-------------------------------------------------------------------------" if to_dump: - destfile = file(Cnf["Dinstall::Reject::ReleaseTransitions"], 'w') - dump(transition, destfile) + for remove in to_remove: + if Options["no-action"]: + print "I: I would remove the %s transition" % (remove) + else: + del transitions[remove] + if not Options["no-action"]: + destfile = file(Cnf["Dinstall::Reject::ReleaseTransitions"], 'w') + dump(transitions, destfile) ################################################################################