3 Get suite_architectures table use sane values
5 @contact: Debian FTP Master <ftpmaster@debian.org>
6 @copyright: 2009 Joerg Jaspert <joerg@debian.org>
7 @license: GNU General Public License version 2 or later
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ################################################################################
27 from daklib.dak_exceptions import DBUpdateError
28 from daklib.utils import get_conf
30 ################################################################################
32 suites = {} #: Cache of existing suites
33 archs = {} #: Cache of existing architectures
36 """ Execute the DB update """
38 print "Lets make suite_architecture table use sane values"
41 query = "INSERT into suite_architectures (suite, architecture) VALUES (%s, %s)" #: Update query
44 c.execute("DELETE FROM suite_architectures;")
46 c.execute("SELECT id, arch_string FROM architecture;")
49 archs[arch[1]]=arch[0]
51 c.execute("SELECT id,suite_name FROM suite")
54 suites[suite[1]]=suite[0]
56 for suite in Cnf.SubTree("Suite").List():
57 print "Processing suite %s" % (suite)
58 architectures = Cnf.SubTree("Suite::" + suite).ValueList("Architectures")
60 for arch in architectures:
61 c.execute(query, [suites[suite], archs[arch]])
63 c.execute("UPDATE config SET value = '4' WHERE name = 'db_revision'")
67 except psycopg2.ProgrammingError, msg:
69 raise DBUpdateError, "Unable to apply sanity to suite_architecture table, rollback issued. Error message : %s" % (str(msg))