]> git.decadent.org.uk Git - dak.git/commitdiff
Make suite.announce an ARRAY
authorMark Hymers <mhy@debian.org>
Wed, 10 Aug 2011 19:59:23 +0000 (20:59 +0100)
committerMark Hymers <mhy@debian.org>
Wed, 10 Aug 2011 19:59:23 +0000 (20:59 +0100)
Signed-off-by: Mark Hymers <mhy@debian.org>
dak/dakdb/update65.py [new file with mode: 0755]
dak/update_db.py
daklib/queue.py

diff --git a/dak/dakdb/update65.py b/dak/dakdb/update65.py
new file mode 100755 (executable)
index 0000000..8dd83a1
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Make announce field an array
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2011 Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+################################################################################
+
+import psycopg2
+from daklib.dak_exceptions import DBUpdateError
+from daklib.config import Config
+
+################################################################################
+def do_update(self):
+    """
+    Make announce field an array
+    """
+    print __doc__
+    try:
+        c = self.db.cursor()
+
+        c.execute("ALTER TABLE suite RENAME COLUMN announce TO announce_temp")
+        c.execute("ALTER TABLE suite ADD COLUMN announce TEXT[]")
+        c.execute("UPDATE suite SET announce = ARRAY[announce_temp] WHERE announce_temp IS NOT NULL")
+        c.execute("ALTER TABLE suite DROP COLUMN announce_temp")
+
+        c.execute("UPDATE config SET value = '65' WHERE name = 'db_revision'")
+        self.db.commit()
+
+    except psycopg2.ProgrammingError, msg:
+        self.db.rollback()
+        raise DBUpdateError, 'Unable to apply sick update 65, rollback issued. Error message : %s' % (str(msg))
index 62f0889b8abe93713851731ff0051e1f742c3161..0245b957e67c99c398bf588d291605219899e151 100755 (executable)
@@ -46,7 +46,7 @@ from daklib.daklog import Logger
 ################################################################################
 
 Cnf = None
-required_database_schema = 64
+required_database_schema = 65
 
 ################################################################################
 
index 20e04bd6fa969fd65d6a76a29e9b23a5229d4ac5..a44ad6d2793246364d4e90b5d867b78cccd36e18 100755 (executable)
@@ -2019,19 +2019,19 @@ distribution."""
 
         announcetemplate = os.path.join(cnf["Dir::Templates"], 'process-unchecked.announce')
 
-        lists_done = {}
+        lists_todo = {}
         summary = ""
 
-        self.Subst["__SHORT_SUMMARY__"] = short_summary
-
+        # Get a unique list of target lists
         for dist in self.pkg.changes["distribution"].keys():
             suite = get_suite(dist)
             if suite is None: continue
-            announce_list = suite.announce
-            if announce_list == "" or lists_done.has_key(announce_list):
-                continue
+            for tgt in suite.announce:
+                lists_todo[tgt] = 1
+
+        self.Subst["__SHORT_SUMMARY__"] = short_summary
 
-            lists_done[announce_list] = 1
+        for announce_list in lists_todo.keys():
             summary += "Announcing to %s\n" % (announce_list)
 
             if action: