5 Debian Archive Kit Database Update Script
6 Copyright © 2008 Michael Casadevall <mcasadevall@debian.org>
7 Copyright © 2009 Joerg Jaspert <joerg@debian.org>
9 Debian Archive Kit Database Update Script 7
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 ################################################################################
28 # * Ganneff ponders how to best write the text to -devel. (need to tell em in
29 # case they find more bugs). "We fixed the fucking idiotic broken implementation
30 # to be less so" is probably not the nicest, even if perfect valid, way to say so
32 ################################################################################
36 from daklib.dak_exceptions import DBUpdateError
37 from daklib.utils import get_conf
39 ################################################################################
42 print "Moving some of the suite config into the DB"
48 c.execute("ALTER TABLE suite ADD COLUMN untouchable BOOLEAN NOT NULL DEFAULT FALSE;")
49 query = "UPDATE suite SET untouchable = TRUE WHERE suite_name = %s" #: Update query
50 for suite in Cnf.SubTree("Suite").List():
51 untouchable = Cnf.Find("Suite::%s::Untouchable" % (suite))
54 print "[Untouchable] Processing suite %s" % (suite)
56 c.execute(query, [suite])
59 c.execute("ALTER TABLE suite ADD COLUMN announce text NOT NULL DEFAULT 'debian-devel-changes@lists.debian.org';")
60 query = "UPDATE suite SET announce = %s WHERE suite_name = %s" #: Update query
61 for suite in Cnf.SubTree("Suite").List():
62 announce_list = Cnf.Find("Suite::%s::Announce" % (suite))
63 print "[Announce] Processing suite %s" % (suite)
65 c.execute(query, [announce_list, suite])
67 c.execute("ALTER TABLE suite ADD COLUMN codename text;")
68 query = "UPDATE suite SET codename = %s WHERE suite_name = %s" #: Update query
69 for suite in Cnf.SubTree("Suite").List():
70 codename = Cnf.Find("Suite::%s::CodeName" % (suite))
71 print "[Codename] Processing suite %s" % (suite)
73 c.execute(query, [codename, suite])
75 c.execute("ALTER TABLE suite ADD COLUMN overridecodename text;")
76 query = "UPDATE suite SET overridecodename = %s WHERE suite_name = %s" #: Update query
77 for suite in Cnf.SubTree("Suite").List():
78 codename = Cnf.Find("Suite::%s::OverrideCodeName" % (suite))
79 print "[OverrideCodeName] Processing suite %s" % (suite)
81 c.execute(query, [codename, suite])
83 c.execute("ALTER TABLE suite ADD COLUMN validtime integer NOT NULL DEFAULT 604800;")
84 query = "UPDATE suite SET validtime = %s WHERE suite_name = %s" #: Update query
85 for suite in Cnf.SubTree("Suite").List():
86 validtime = Cnf.Find("Suite::%s::ValidTime" % (suite))
87 print "[ValidTime] Processing suite %s" % (suite)
91 c.execute(query, [validtime, suite])
93 c.execute("ALTER TABLE suite ADD COLUMN priority integer NOT NULL DEFAULT 0;")
94 query = "UPDATE suite SET priority = %s WHERE suite_name = %s" #: Update query
95 for suite in Cnf.SubTree("Suite").List():
96 priority = Cnf.Find("Suite::%s::Priority" % (suite))
97 print "[Priority] Processing suite %s" % (suite)
100 suite = suite.lower()
101 c.execute(query, [priority, suite])
104 c.execute("ALTER TABLE suite ADD COLUMN notautomatic BOOLEAN NOT NULL DEFAULT FALSE;")
105 query = "UPDATE suite SET notautomatic = TRUE WHERE suite_name = %s" #: Update query
106 for suite in Cnf.SubTree("Suite").List():
107 notautomatic = Cnf.Find("Suite::%s::NotAutomatic" % (suite))
108 print "[NotAutomatic] Processing suite %s" % (suite)
111 suite = suite.lower()
112 c.execute(query, [suite])
114 c.execute("UPDATE config SET value = '7' WHERE name = 'db_revision'")
117 except psycopg2.ProgrammingError, msg:
119 raise DBUpdateError, "Unable to appy suite config updates, rollback issued. Error message : %s" % (str(msg))