3 # Check the release managers transition file for correctness and outdated transitions
4 # Copyright (C) 2008 Joerg Jaspert <joerg@debian.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ################################################################################
22 # <elmo> if klecker.d.o died, I swear to god, I'm going to migrate to gentoo.
24 ################################################################################
28 import daklib.database
38 ################################################################################
41 global Cnf, Options, projectB
45 Cnf = daklib.utils.get_conf()
47 Arguments = [('h',"help","Dinstall::Options::Help"),
48 ('n',"no-action","Dinstall::Options::No-Action")]
50 for i in ["help", "no-action"]:
51 Cnf["Dinstall::Options::%s" % (i)] = ""
53 projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
54 daklib.database.init(Cnf, projectB)
56 Options = Cnf.SubTree("Dinstall::Options")
61 ################################################################################
63 def usage (exit_code=0):
64 print """Usage: check_transitions [OPTION]...
65 Check the release managers transition file for correctness and outdated transitions
66 -h, --help show this help and exit.
67 -n, --no-action don't do anything"""
70 ################################################################################
77 # Only check if there is a file defined (and existant) with checks. It's a little bit
78 # specific to Debian, not much use for others, so return early there.
79 if not Cnf.has_key("Dinstall::Reject::ReleaseTransitions") or not os.path.exists("%s" % (Cnf["Dinstall::Reject::ReleaseTransitions"])):
80 daklib.utils.warn("Dinstall::Reject::ReleaseTransitions not defined or file %s not existant." %
81 (Cnf["Dinstall::Reject::ReleaseTransitions"]))
85 sourcefile = file(Cnf["Dinstall::Reject::ReleaseTransitions"], 'r')
86 sourcecontent = sourcefile.read()
88 transitions = load(sourcecontent)
90 # This shouldn't happen, the release team has a wrapper to check the file, but better
92 daklib.utils.warn("Not checking transitions, the transitions file is broken: %s." % (msg))
97 # Now look through all defined transitions
98 for trans in transitions:
99 t = transitions[trans]
103 # Will be None if nothing is in testing.
104 curvers = daklib.database.get_testing_version(source)
107 Looking at transition: %s
112 Blocked Packages (total: %d): %s
113 """ % (trans, source, new_vers, t["rm"], t["reason"], len(t["packages"]), ", ".join(t["packages"]))
115 if curvers and apt_pkg.VersionCompare(new_vers, curvers) == 1:
116 # This is still valid, the current version in database is older than
117 # the new version we wait for
118 print "This transition is still ongoing"
120 print "This transition is over, the target package reached testing, removing"
121 print "%s wanted version: %s, has %s" % (source, new_vers, curvers)
122 to_remove.append(trans)
124 print "-------------------------------------------------------------------------"
127 for remove in to_remove:
128 if Options["No-Action"]:
129 print "I: I would remove the %s transition" % (remove)
131 del transitions[remove]
132 if not Options["No-Action"]:
133 destfile = file(Cnf["Dinstall::Reject::ReleaseTransitions"], 'w')
134 dump(transitions, destfile)
136 ################################################################################
138 if __name__ == '__main__':