X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fadmin.py;h=3fa7eefb032b209414f3907dba15af5287a8b07e;hb=077bf03c4495465e28388f52e471877b7afa821a;hp=23b4c2d8e1a05ff17e1d7f8aecb51dab9e75c24c;hpb=9a4fb568340b14698947bfa59b309ae0c67c693a;p=dak.git diff --git a/dak/admin.py b/dak/admin.py index 23b4c2d8..3fa7eefb 100755 --- a/dak/admin.py +++ b/dak/admin.py @@ -65,6 +65,8 @@ Perform administrative work on the dak database. 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 + k add-buildd NAME ARCH... add buildd keyring with upload permission + for the given architectures architecture / a: a list show a list of architectures @@ -96,6 +98,15 @@ Perform administrative work on the dak database. s-a rm SUITE ARCH remove ARCH from suite (will only work if no packages remain for the arch in the suite) + archive: + archive list list all archives + archive add NAME ROOT DESCRIPTION [primary-mirror=MIRROR] [tainted=1] + add archive NAME with path ROOT, + primary mirror MIRROR. + archive rm NAME remove archive NAME (will only work if there are + no files and no suites in the archive) + archive rename OLD NEW rename archive OLD to NEW + version-check / v-c: v-c list show version checks for all suites v-c list-suite SUITE show version checks for suite SUITE @@ -225,6 +236,11 @@ def __suite_add(d, args, addallarches=False): signingkey = get_field('signingkey') if signingkey is not None: suite.signingkeys = [signingkey.upper()] + archive_name = get_field('archive') + if archive_name is not None: + suite.archive = get_archive(archive_name, s) + else: + suite.archive = s.query(Archive).filter(~Archive.archive_name.in_(['build-queues', 'new', 'policy'])).one() suite.srcformats = s.query(SrcFormat).all() s.add(suite) s.flush() @@ -373,6 +389,77 @@ dispatch['s-a'] = suite_architecture ################################################################################ +def archive_list(): + session = DBConn().session() + for archive in session.query(Archive).order_by(Archive.archive_name): + print "{0} path={1} description={2} tainted={3}".format(archive.archive_name, archive.path, archive.description, archive.tainted) + +def archive_add(args): + (name, path, description) = args[0:3] + + attributes = dict( + archive_name=name, + path=path, + description=description, + ) + + for option in args[3:]: + (key, value) = option.split('=') + attributes[key] = value + + session = DBConn().session() + + archive = Archive() + for key, value in attributes.iteritems(): + setattr(archive, key, value) + + session.add(archive) + session.flush() + + if dryrun: + session.rollback() + else: + session.commit() + +def archive_rm(name): + session = DBConn().session() + archive = session.query(Archive).filter_by(archive_name=name).one() + session.delete(archive) + session.flush() + + if dryrun: + session.rollback() + else: + session.commit() + +def archive_rename(oldname, newname): + session = DBConn().session() + archive = get_archive(oldname, session) + archive.archive_name = newname + session.flush() + + if dryrun: + session.rollback() + else: + session.commit() + +def archive(command): + mode = command[1] + if mode == 'list': + archive_list() + elif mode == 'rename': + archive_rename(command[2], command[3]) + elif mode == 'add': + archive_add(command[2:]) + elif mode == 'rm': + archive_rm(command[2]) + else: + die("E: archive command unknown") + +dispatch['archive'] = archive + +################################################################################ + def __version_check_list(d): session = d.session() for s in session.query(Suite).order_by(Suite.suite_name): @@ -485,6 +572,8 @@ def show_config(command): print "PGPORT=%s" % cnf["DB::Port"] e.append('PGPORT') print "export " + " ".join(e) + elif mode == 'get': + print cnf.get(args[2]) else: session = DBConn().session() try: @@ -513,17 +602,49 @@ def show_keyring(command): if mode == 'list-all': pass elif mode == 'list-binary': - q = q.filter(Keyring.default_source_acl_id == None) + q = q.join(Keyring.acl).filter(ACL.allow_source == False) elif mode == 'list-source': - q = q.filter(Keyring.default_source_acl_id != None) + q = q.join(Keyring.acl).filter(ACL.allow_source == True) else: die("E: keyring command unknown") for k in q.all(): print k.keyring_name -dispatch['keyring'] = show_keyring -dispatch['k'] = show_keyring +def keyring_add_buildd(command): + name = command[2] + arch_names = command[3:] + + session = DBConn().session() + arches = session.query(Architecture).filter(Architecture.arch_string.in_(arch_names)) + + acl = ACL() + acl.name = 'buildd-{0}'.format('+'.join(arch_names)) + acl.architectures.update(arches) + acl.allow_new = True + acl.allow_binary = True + acl.allow_binary_only = True + acl.allow_hijack = True + session.add(acl) + + k = Keyring() + k.keyring_name = name + k.acl = acl + k.priority = 10 + session.add(k) + + session.commit() + +def keyring(command): + if command[1].startswith('list-'): + show_keyring(command) + elif command[1] == 'add-buildd': + keyring_add_buildd(command) + else: + die("E: keyring command unknown") + +dispatch['keyring'] = keyring +dispatch['k'] = keyring ################################################################################