5 Moving suite config into DB
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2008 Michael Casadevall <mcasadevall@debian.org>
9 @copyright: 2009 Joerg Jaspert <joerg@debian.org>
10 @license: GNU General Public License version 2 or later
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 ################################################################################
30 # * Ganneff ponders how to best write the text to -devel. (need to tell em in
31 # case they find more bugs). "We fixed the fucking idiotic broken implementation
32 # to be less so" is probably not the nicest, even if perfect valid, way to say so
34 ################################################################################
38 from daklib.dak_exceptions import DBUpdateError
39 from daklib.utils import get_conf
41 ################################################################################
44 print "Moving some of the suite config into the DB"
50 c.execute("ALTER TABLE suite ADD COLUMN untouchable BOOLEAN NOT NULL DEFAULT FALSE;")
51 query = "UPDATE suite SET untouchable = TRUE WHERE suite_name = %s" #: Update query
52 for suite in Cnf.subtree("Suite").list():
53 untouchable = Cnf.find("Suite::%s::Untouchable" % (suite))
56 print "[Untouchable] Processing suite %s" % (suite)
58 c.execute(query, [suite])
61 c.execute("ALTER TABLE suite ADD COLUMN announce text NOT NULL DEFAULT 'debian-devel-changes@lists.debian.org';")
62 query = "UPDATE suite SET announce = %s WHERE suite_name = %s" #: Update query
63 for suite in Cnf.subtree("Suite").list():
64 announce_list = Cnf.find("Suite::%s::Announce" % (suite))
65 print "[Announce] Processing suite %s" % (suite)
67 c.execute(query, [announce_list, suite])
69 c.execute("ALTER TABLE suite ADD COLUMN codename text;")
70 query = "UPDATE suite SET codename = %s WHERE suite_name = %s" #: Update query
71 for suite in Cnf.subtree("Suite").list():
72 codename = Cnf.find("Suite::%s::CodeName" % (suite))
73 print "[Codename] Processing suite %s" % (suite)
75 c.execute(query, [codename, suite])
77 c.execute("ALTER TABLE suite ADD COLUMN overridecodename text;")
78 query = "UPDATE suite SET overridecodename = %s WHERE suite_name = %s" #: Update query
79 for suite in Cnf.subtree("Suite").list():
80 codename = Cnf.find("Suite::%s::OverrideCodeName" % (suite))
81 print "[OverrideCodeName] Processing suite %s" % (suite)
83 c.execute(query, [codename, suite])
85 c.execute("ALTER TABLE suite ADD COLUMN validtime integer NOT NULL DEFAULT 604800;")
86 query = "UPDATE suite SET validtime = %s WHERE suite_name = %s" #: Update query
87 for suite in Cnf.subtree("Suite").list():
88 validtime = Cnf.find("Suite::%s::ValidTime" % (suite))
89 print "[ValidTime] Processing suite %s" % (suite)
93 c.execute(query, [validtime, suite])
95 c.execute("ALTER TABLE suite ADD COLUMN priority integer NOT NULL DEFAULT 0;")
96 query = "UPDATE suite SET priority = %s WHERE suite_name = %s" #: Update query
97 for suite in Cnf.subtree("Suite").list():
98 priority = Cnf.find("Suite::%s::Priority" % (suite))
99 print "[Priority] Processing suite %s" % (suite)
102 suite = suite.lower()
103 c.execute(query, [priority, suite])
106 c.execute("ALTER TABLE suite ADD COLUMN notautomatic BOOLEAN NOT NULL DEFAULT FALSE;")
107 query = "UPDATE suite SET notautomatic = TRUE WHERE suite_name = %s" #: Update query
108 for suite in Cnf.subtree("Suite").list():
109 notautomatic = Cnf.find("Suite::%s::NotAutomatic" % (suite))
110 print "[NotAutomatic] Processing suite %s" % (suite)
113 suite = suite.lower()
114 c.execute(query, [suite])
116 c.execute("UPDATE config SET value = '7' WHERE name = 'db_revision'")
119 except psycopg2.ProgrammingError as msg:
121 raise DBUpdateError("Unable to appy suite config updates, rollback issued. Error message : %s" % (str(msg)))