]> git.decadent.org.uk Git - dak.git/blobdiff - dak/admin.py
admin: fix a typo
[dak.git] / dak / admin.py
index 808fb88785edb626b99d46881da114a58f276ee5..fe369b51a753ca08add8ad22657e94f4644a4c9e 100755 (executable)
@@ -59,6 +59,12 @@ Perform administrative work on the dak database.
   config / c:
      c db                   show db config
      c db-shell             show db config in a usable form for psql
+     c NAME                 show option NAME as set in configuration table
+
+  keyring / k:
+     k list-all             list all keyrings
+     k list-binary          list all keyrings with a NULL source acl
+     k list-source          list all keyrings with a non NULL source acl
 
   architecture / a:
      a list                 show a list of architectures
@@ -74,8 +80,13 @@ Perform administrative work on the dak database.
      s show SUITE           show config details for a suite
      s add SUITE VERSION [ label=LABEL ] [ description=DESCRIPTION ]
                          [ origin=ORIGIN ] [ codename=CODENAME ]
-                            add suite SUITE, version VERSION. label,
-                            description, origin and codename are optional.
+                         [ signingkey=SIGNINGKEY ]
+                            add suite SUITE, version VERSION.
+                            label, description, origin, codename
+                            and signingkey 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
@@ -89,7 +100,7 @@ Perform administrative work on the dak database.
      v-c list                        show version checks for all suites
      v-c list-suite SUITE            show version checks for suite SUITE
      v-c add SUITE CHECK REFERENCE   add a version check for suite SUITE
-     v-c rm SUITE CHECK REFERENCE    rmove a version check
+     v-c rm SUITE CHECK REFERENCE    remove a version check
        where
          CHECK     is one of Enhances, MustBeNewerThan, MustBeOlderThan
         REFERENCE is another suite name
@@ -187,7 +198,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]
@@ -205,19 +216,36 @@ def __suite_add(d, args):
             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')
             suite.origin = get_field('origin')
             suite.codename = get_field('codename')
+            signingkey = get_field('signingkey')
+            if signingkey is not None:
+                suite.signingkeys = [signingkey.upper()]
+            suite.srcformats = s.query(SrcFormat).all()
             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()
@@ -232,7 +260,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")
 
@@ -456,13 +486,47 @@ def show_config(command):
             e.append('PGPORT')
         print "export " + " ".join(e)
     else:
-        die("E: config command unknown")
+        session = DBConn().session()
+        try:
+            o = session.query(DBConfig).filter_by(name = mode).one()
+            print o.value
+        except NoResultFound:
+            print "W: option '%s' not set" % mode
 
 dispatch['config'] = show_config
 dispatch['c'] = show_config
 
 ################################################################################
 
+def show_keyring(command):
+    args = [str(x) for x in command]
+    cnf = utils.get_conf()
+
+    die_arglen(args, 2, "E: keyring needs at least a command")
+
+    mode = args[1].lower()
+
+    d = DBConn()
+
+    q = d.session().query(Keyring).filter(Keyring.active == True)
+
+    if mode == 'list-all':
+        pass
+    elif mode == 'list-binary':
+        q = q.filter(Keyring.default_source_acl_id == None)
+    elif mode == 'list-source':
+        q = q.filter(Keyring.default_source_acl_id != None)
+    else:
+        die("E: keyring command unknown")
+
+    for k in q.all():
+        print k.keyring_name
+
+dispatch['keyring'] = show_keyring
+dispatch['k'] = show_keyring
+
+################################################################################
+
 def main():
     """Perform administrative work on the dak database"""
     global dryrun