5 Add policy queue handling support
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2009 Mark Hymers <mhy@debian.org>
9 @license: GNU General Public License version 2 or later
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 ################################################################################
29 ################################################################################
37 from daklib.dak_exceptions import DBUpdateError
38 from daklib.config import Config
40 ################################################################################
43 print "Updating use of queue table"
50 print "Adding path to queue table"
51 c.execute("ALTER TABLE queue ADD COLUMN path TEXT")
52 c.execute("SELECT * FROM queue")
56 dir = cnf["Dir::Queue::%s" % row[1]].rstrip('/')
57 seenqueues[row[1].lower()] = 1
58 print "Setting %s queue to use path %s" % (row[1], dir)
59 c.execute("UPDATE queue SET path = %s WHERE id = %s", (dir, row[0]))
61 print "Adding missing queues to the queue table"
62 for q in cnf.SubTree("Dir::Queue").keys():
64 if qname in seenqueues.keys():
66 if qname in ["done", "holding", "reject", "newstage", "btsversiontrack"]:
67 print "Skipping queue %s" % qname
69 pth = cnf["Dir::Queue::%s" % qname].rstrip('/')
70 if not os.path.exists(pth):
71 print "Skipping %s as %s does not exist" % (qname, pth)
74 print "Adding %s queue with path %s" % (qname, pth)
75 c.execute("INSERT INTO queue (queue_name, path) VALUES (%s, %s)", (qname, pth))
78 print "Adding queue and approved_for columns to known_changes"
79 c.execute("ALTER TABLE known_changes ADD COLUMN in_queue INT4 REFERENCES queue(id) DEFAULT NULL")
80 c.execute("ALTER TABLE known_changes ADD COLUMN approved_for INT4 REFERENCES queue(id) DEFAULT NULL")
82 print "Adding policy queue column to suite table"
83 c.execute("ALTER TABLE suite DROP COLUMN policy_engine")
84 c.execute("ALTER TABLE suite ADD COLUMN policy_queue_id INT4 REFERENCES queue(id) DEFAULT NULL")
85 # Handle some of our common cases automatically
86 if seenqueues.has_key('proposedupdates'):
87 c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'proposedupdates')
88 WHERE suite_name = 'proposed-updates'""")
90 if seenqueues.has_key('oldproposedupdates'):
91 c.execute("""UPDATE suite SET policy_queue_id = (SELECT id FROM queue WHERE queue_name = 'oldproposedupdates')
92 WHERE suite_name = 'oldstable-proposed-updates'""")
95 c.execute("UPDATE config SET value = '20' WHERE name = 'db_revision'")
98 except psycopg2.InternalError, msg:
100 raise DBUpdateError, "Unable to apply debversion update 20, rollback issued. Error message : %s" % (str(msg))