]> git.decadent.org.uk Git - dak.git/commitdiff
Allow adding a suite with all architectures
authorMark Hymers <mhy@debian.org>
Tue, 26 Jul 2011 22:06:15 +0000 (23:06 +0100)
committerMark Hymers <mhy@debian.org>
Tue, 26 Jul 2011 22:06:15 +0000 (23:06 +0100)
Signed-off-by: Mark Hymers <mhy@debian.org>
dak/admin.py

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.
 
                             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
   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()
 
 
     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]
     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)
             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)
 
         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()
 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':
     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")
 
     else:
         die("E: suite command unknown")