From: Mark Hymers Date: Tue, 26 Jul 2011 22:24:58 +0000 (+0100) Subject: Merge remote branch 'mhy/master' X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=21407ef8d3338a7e8eff6e4e3b4780481e46e644;hp=116d60e8e849644ace31f5d5c05465e4f2d83494;p=dak.git Merge remote branch 'mhy/master' --- diff --git a/dak/admin.py b/dak/admin.py index 1dc7e7bc..2183c229 100755 --- a/dak/admin.py +++ b/dak/admin.py @@ -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 index 00000000..f320bbf0 --- /dev/null +++ b/dak/dakdb/update62.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# coding=utf8 + +""" +Ensure that suite_name is unique! + +@contact: Debian FTP Master +@copyright: 2011 Mark Hymers +@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)) diff --git a/dak/update_db.py b/dak/update_db.py index aff41bba..fb7f142b 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -46,7 +46,7 @@ from daklib.daklog import Logger ################################################################################ Cnf = None -required_database_schema = 61 +required_database_schema = 62 ################################################################################ diff --git a/setup/README b/setup/README index 82ead70f..3b04d730 100644 --- a/setup/README +++ b/setup/README @@ -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