X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fadmin.py;h=e109877faf0d5606fd5fb1ebe4049f973a821da5;hb=27e00376e81d1c37ff327ee0d39670b266418869;hp=1dc7e7bc3a449512245db15a684287800df8e4f3;hpb=e1156b3b857f5496a299e621d291cff0ba957d23;p=dak.git diff --git a/dak/admin.py b/dak/admin.py index 1dc7e7bc..e109877f 100755 --- a/dak/admin.py +++ b/dak/admin.py @@ -80,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 @@ -95,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 @@ -132,9 +137,9 @@ def __architecture_add(d, args): else: warn("W: Cannot find suite %s" % su) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Integrity error adding architecture %s (it probably already exists)" % args[2]) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Error adding architecture %s (%s)" % (args[2], e)) print "Architecture %s added" % (args[2]) @@ -149,9 +154,9 @@ def __architecture_rm(d, args): die("E: Cannot find architecture %s" % args[2]) s.delete(a) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Integrity error removing architecture %s (suite-arch entries probably still exist)" % args[2]) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Error removing architecture %s (%s)" % (args[2], e)) print "Architecture %s removed" % args[2] @@ -193,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] @@ -211,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() - except IntegrityError, e: + s.flush() + except IntegrityError as e: die("E: Integrity error adding suite %s (it probably already exists)" % suite_name) - except SQLAlchemyError, e: + except SQLAlchemyError as 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 +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") @@ -289,9 +313,9 @@ def __suite_architecture_add(d, args): try: suite.architectures.append(arch) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Can't add suite-architecture entry (%s, %s) - probably already exists" % (args[2].lower(), args[3].lower())) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Can't add suite-architecture entry (%s, %s) - %s" % (args[2].lower(), args[3].lower(), e)) print "Added suite-architecture entry for %s, %s" % (args[2].lower(), args[3].lower()) @@ -314,9 +338,9 @@ def __suite_architecture_rm(d, args): die("E: architecture %s not found in suite %s" % (arch_string, suite_name)) suite.architectures.remove(architecture) s.commit() - except IntegrityError, e: + except IntegrityError as e: die("E: Can't remove suite-architecture entry (%s, %s) - it's probably referenced" % (args[2].lower(), args[3].lower())) - except SQLAlchemyError, e: + except SQLAlchemyError as e: die("E: Can't remove suite-architecture entry (%s, %s) - %s" % (args[2].lower(), args[3].lower(), e)) print "Removed suite-architecture entry for %s, %s" % (args[2].lower(), args[3].lower())