]> git.decadent.org.uk Git - dak.git/commitdiff
Merge remote branch 'mhy/master'
authorMark Hymers <mhy@debian.org>
Tue, 26 Jul 2011 22:24:58 +0000 (23:24 +0100)
committerMark Hymers <mhy@debian.org>
Tue, 26 Jul 2011 22:24:58 +0000 (23:24 +0100)
dak/admin.py
dak/dakdb/update62.py [new file with mode: 0755]
dak/update_db.py
setup/README

index 1dc7e7bc3a449512245db15a684287800df8e4f3..2183c2293b2ad4c039d1658362b1f72ad318c22b 100755 (executable)
@@ -83,6 +83,9 @@ Perform administrative work on the dak database.
                             add suite SUITE, version VERSION. label,
                             description, origin and codename are optional.
 
+     s add-all-arches SUITE VERSION... as "s add" but adds suite-architecture
+                            relationships for all architectures
+
   suite-architecture / s-a:
      s-a list               show the architectures for all suites
      s-a list-suite ARCH    show the suites an ARCH is in
@@ -193,7 +196,7 @@ def __suite_show(d, args):
 
     print su.details()
 
-def __suite_add(d, args):
+def __suite_add(d, args, addallarches=False):
     die_arglen(args, 4, "E: adding a suite requires at least a name and a version")
     suite_name = args[2].lower()
     version = args[3]
@@ -217,13 +220,25 @@ def __suite_add(d, args):
             suite.origin = get_field('origin')
             suite.codename = get_field('codename')
             s.add(suite)
-            s.commit()
+            s.flush()
         except IntegrityError, e:
             die("E: Integrity error adding suite %s (it probably already exists)" % suite_name)
         except SQLAlchemyError, e:
             die("E: Error adding suite %s (%s)" % (suite_name, e))
     print "Suite %s added" % (suite_name)
 
+    if addallarches:
+        arches = []
+        q = s.query(Architecture).order_by('arch_string')
+        for arch in q.all():
+            suite.architectures.append(arch)
+            arches.append(arch.arch_string)
+
+        print "Architectures %s added to %s" % (','.join(arches), suite_name)
+
+    s.commit()
+
+
 def suite(command):
     args = [str(x) for x in command]
     Cnf = utils.get_conf()
@@ -238,7 +253,9 @@ def suite(command):
     elif mode == 'show':
         __suite_show(d, args)
     elif mode == 'add':
-        __suite_add(d, args)
+        __suite_add(d, args, False)
+    elif mode == 'add-all-arches':
+        __suite_add(d, args, True)
     else:
         die("E: suite command unknown")
 
diff --git a/dak/dakdb/update62.py b/dak/dakdb/update62.py
new file mode 100755 (executable)
index 0000000..f320bbf
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Ensure that suite_name is unique!
+
+@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
+
+################################################################################
+def do_update(self):
+    """
+    Ensure that suite_name is unique
+    """
+    print __doc__
+    try:
+        c = self.db.cursor()
+
+        c.execute("ALTER TABLE suite ADD CONSTRAINT suite_name_unique UNIQUE (suite_name)")
+
+        c.execute("UPDATE config SET value = '62' WHERE name = 'db_revision'")
+        self.db.commit()
+
+    except psycopg2.ProgrammingError, msg:
+        self.db.rollback()
+        raise DBUpdateError, 'Unable to apply sick update 62, rollback issued. Error message : %s' % (str(msg))
index aff41bba527e09f86526bfdf2fd8d4652a7dbbe1..fb7f142b11f11db83379002cd3f4af02611f26db 100755 (executable)
@@ -46,7 +46,7 @@ from daklib.daklog import Logger
 ################################################################################
 
 Cnf = None
-required_database_schema = 61
+required_database_schema = 62
 
 ################################################################################
 
index 82ead70fffb57edc5138857f220a70797ed9c9e4..3b04d73077fd03d0a63287dd23d9088b1dc97fbb 100644 (file)
@@ -48,3 +48,5 @@ Add some architectures you care about:
 # dak admin architecture add i386 "Intel x86 port"
 # dak admin architecture add amd64 "AMD64 port"
 
+Add a suite (origin=, label= and codename= are optional)
+# dak admin suite add-all-arches unstable x.y.z origin=MyDistro label=Master codename=sid