]> git.donarmstrong.com Git - dak.git/commitdiff
Merge remote branch 'ftpmaster/master'
authorMark Hymers <mhy@debian.org>
Wed, 10 Aug 2011 19:59:27 +0000 (20:59 +0100)
committerMark Hymers <mhy@debian.org>
Wed, 10 Aug 2011 19:59:27 +0000 (20:59 +0100)
dak/admin.py
dak/dakdb/update65.py [new file with mode: 0755]
dak/update_db.py
daklib/dbconn.py
daklib/queue.py

index 60c4bc6d4556e216c8da45fdec4f549cfcba3546..c6128b9befb0fc3c86792e41c9472538b1809bfa 100755 (executable)
@@ -216,6 +216,7 @@ def __suite_add(d, args, addallarches=False):
             s = d.session()
             suite = Suite()
             suite.suite_name = suite_name
+            suite.overridecodename = suite_name
             suite.version = version
             suite.label = get_field('label')
             suite.description = get_field('description')
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 f2dca8fa693ed58089d2e9d0a454732d05e70e17..a6a9e02219c749fabd3a7ac364a6faa0d757e273 100755 (executable)
@@ -3667,15 +3667,21 @@ class DBConn(object):
 
         sqlalchemy.dialects.postgresql.base.dialect = PGDialect_psycopg2_dak
 
-        self.db_pg   = create_engine(connstr, **engine_args)
-        self.db_meta = MetaData()
-        self.db_meta.bind = self.db_pg
-        self.db_smaker = sessionmaker(bind=self.db_pg,
-                                      autoflush=True,
-                                      autocommit=False)
-
-        self.__setuptables()
-        self.__setupmappers()
+        try:
+            self.db_pg   = create_engine(connstr, **engine_args)
+            self.db_meta = MetaData()
+            self.db_meta.bind = self.db_pg
+            self.db_smaker = sessionmaker(bind=self.db_pg,
+                                          autoflush=True,
+                                          autocommit=False)
+
+            self.__setuptables()
+            self.__setupmappers()
+
+        except OperationalError, e:
+            import utils
+            utils.fubar("Cannot connect to database (%s)" % str(e))
+
         self.pid = os.getpid()
 
     def session(self, work_mem = 0):
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: