From: Joerg Jaspert Date: Sun, 2 Mar 2008 16:37:58 +0000 (+0100) Subject: Add check_transitions so the yaml file can easily be checked. Make it known to dak X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=7a7563b8e19f99783505669ba603ef2d534c6603;p=dak.git Add check_transitions so the yaml file can easily be checked. Make it known to dak --- diff --git a/ChangeLog b/ChangeLog index 66f68142..6aba702a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-03-02 Joerg Jaspert + * dak/dak.py (init): Tell it about check_transitions + + * dak/check_transitions.py (usage): Added, checks the transitions + file (if any) + * daklib/database.py (get_testing_version): Added. Returns the version for the source in testing, if any diff --git a/dak/check_transitions.py b/dak/check_transitions.py new file mode 100755 index 00000000..089c60ef --- /dev/null +++ b/dak/check_transitions.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python + +# Check the release managers transition file for correctness and outdated transitions +# Copyright (C) 2008 Joerg Jaspert + +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +################################################################################ + +# if klecker.d.o died, I swear to god, I'm going to migrate to gentoo. + +################################################################################ + +import os, sys +import apt_pkg +import daklib.database +import daklib.utils + +from syck import * + +# Globals +Cnf = None +Options = None +projectB = None + +################################################################################ + +def init(): + global Cnf, Options, projectB + + apt_pkg.init() + + Cnf = daklib.utils.get_conf() + + Arguments = [('h',"help","Dinstall::Options::Help"), + ('n',"no-action","Dinstall::Options::No-Action")] + + for i in ["help", "no-action"]: + Cnf["Dinstall::Options::%s" % (i)] = "" + + 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"]: + usage() + +################################################################################ + +def usage (exit_code=0): + print """Usage: check_transitions [OPTION]... + -h, --help show this help and exit. + -n, --no-action don't do anything""" + sys.exit(exit_code) + +################################################################################ + +def main(): + global Cnf + # 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"])): + daklib.utils.warn("Dinstall::Reject::ReleaseTransitions not defined or file %s not existant." % + (Cnf["Dinstall::Reject::ReleaseTransitions"])) + sys.exit(1) + + # Parse the yaml file + sourcefile = file(Cnf["Dinstall::Reject::ReleaseTransitions"], 'r') + try: + transitions = load(sourcefile) + except error, msg: + # This shouldn't happen, the release team has a wrapper to check the file, but better + # safe then sorry + daklib.utils.warn("Not checking transitions, the transitions file is broken: %s." % (msg)) + sys.exit(2) + + to_dump = 0 + + # Now look through all defined transitions + for trans in transition: + t = transition[trans] + source = t["source"] + new_vers = t["new"] + + # Will be None if nothing is in testing. + 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" + 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 + print "-------------------------------------------------------------------------" + + if to_dump: + destfile = file(Cnf["Dinstall::Reject::ReleaseTransitions"], 'w') + dump(transition, destfile) + +################################################################################ + +if __name__ == '__main__': + main() diff --git a/dak/dak.py b/dak/dak.py index 10da0411..859f67f5 100755 --- a/dak/dak.py +++ b/dak/dak.py @@ -91,7 +91,9 @@ def init(): "Clean cruft from incoming"), ("clean-proposed-updates", "Remove obsolete .changes from proposed-updates"), - + + ("check-transitions", + "Check release transition file"), ("check-overrides", "Override cruft checks"), ("check-proposed-updates", diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index d0fc9c02..a958d23e 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -1008,8 +1008,7 @@ def check_transition(sourcepkg): # 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") and - not os.path.exists("%s" % (Cnf["Dinstall::Reject::ReleaseTransitions"])): + if not Cnf.has_key("Dinstall::Reject::ReleaseTransitions") or not os.path.exists("%s" % (Cnf["Dinstall::Reject::ReleaseTransitions"])): return # Parse the yaml file @@ -1019,7 +1018,7 @@ def check_transition(sourcepkg): except error, msg: # This shouldn't happen, the release team has a wrapper to check the file, but better # safe then sorry - utils.warn("Not checking transitions, the transitions file is broken: %s." % (msg)) + daklib.utils.warn("Not checking transitions, the transitions file is broken: %s." % (msg)) return # Now look through all defined transitions diff --git a/daklib/database.py b/daklib/database.py old mode 100644 new mode 100755 index a40696e2..3a6c9aec --- a/daklib/database.py +++ b/daklib/database.py @@ -223,6 +223,28 @@ def get_source_id (source, version): return source_id +def get_testing_version(source): + global testing_version_cache + + if testing_version_cache.has_key(source): + return testing_version_cache[source] + + q = Upload.projectB.query(""" + SELECT s.version FROM source s, suite su, src_associations sa + WHERE sa.source=s.id + AND sa.suite=su.id + AND su.suite_name='testing' + AND s.source='%s'""" + % (source)) + + if not q.getresult(): + return None + + version = q.getresult()[0][0] + testing_version_cache[source] = version + + return version + ################################################################################ def get_or_set_maintainer_id (maintainer):