From: Mark Hymers Date: Sun, 4 Sep 2011 18:17:03 +0000 (+0100) Subject: Merge remote branch 'ftpmaster/master' into override-cs-db X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e939620de1f925def64465f20f1f2320f092d967;hp=-c;p=dak.git Merge remote branch 'ftpmaster/master' into override-cs-db Conflicts: dak/dakdb/update69.py Signed-off-by: Mark Hymers --- e939620de1f925def64465f20f1f2320f092d967 diff --combined dak/control_suite.py index 3ba5acdc,236e36aa..d18bc705 --- a/dak/control_suite.py +++ b/dak/control_suite.py @@@ -216,32 -216,31 +216,31 @@@ def set_suite(file, suite, session, bri FROM binaries b, bin_associations ba, architecture a WHERE ba.suite = :suiteid AND ba.bin = b.id AND b.architecture = a.id""", {'suiteid': suite_id}) - for i in q.fetchall(): - key = " ".join(i[:3]) + for i in q: + key = i[:3] current[key] = i[3] - q = session.execute("""SELECT s.source, s.version, sa.id + q = session.execute("""SELECT s.source, s.version, 'source', sa.id FROM source s, src_associations sa WHERE sa.suite = :suiteid AND sa.source = s.id""", {'suiteid': suite_id}) - for i in q.fetchall(): - key = " ".join(i[:2]) + " source" - current[key] = i[2] + for i in q: + key = i[:3] + current[key] = i[3] # Build up a dictionary of what should be in the suite - desired = {} + desired = set() for line in lines: split_line = line.strip().split() if len(split_line) != 3: utils.warn("'%s' does not break into 'package version architecture'." % (line[:-1])) continue - key = " ".join(split_line) - desired[key] = "" + desired.add(tuple(split_line)) # Check to see which packages need added and add them - for key in sorted(desired.keys(), cmp=cmp_package_version): - if not current.has_key(key): - (package, version, architecture) = key.split() + for key in sorted(desired, cmp=cmp_package_version): + if key not in current: + (package, version, architecture) = key version_checks(package, architecture, suite.suite_name, version, session, force) pkid = get_id (package, version, architecture, session) if not pkid: @@@ -252,18 -251,17 +251,17 @@@ else: session.execute("""INSERT INTO bin_associations (suite, bin) VALUES (:suiteid, :pkid)""", {'suiteid': suite_id, 'pkid': pkid}) - Logger.log(["added", key, pkid]) + Logger.log(["added", " ".join(key), pkid]) # Check to see which packages need removed and remove them - for key in current.keys(): - if not desired.has_key(key): - (package, version, architecture) = key.split() - pkid = current[key] + for key, pkid in current.iteritems(): + if key not in desired: + (package, version, architecture) = key if architecture == "source": session.execute("""DELETE FROM src_associations WHERE id = :pkid""", {'pkid': pkid}) else: session.execute("""DELETE FROM bin_associations WHERE id = :pkid""", {'pkid': pkid}) - Logger.log(["removed", key, pkid]) + Logger.log(["removed", " ".join(key), pkid]) session.commit() @@@ -421,17 -419,15 +419,17 @@@ def main () utils.fubar("Can only perform one action at a time.") action = i + # Safety/Sanity check + if action == "set" and (not suite.allowcsset): + if force: + utils.warn("Would not normally allow setting suite %s (allowsetcs is FALSE), but --force used" % (suite_name)) + else: + utils.fubar("Will not reset suite %s due to its database configuration (allowsetcs is FALSE)" % (suite_name)) + # Need an action... if action == None: utils.fubar("No action specified.") - # Safety/Sanity check - # XXX: This should be stored in the database - if action == "set" and suite_name not in ["testing", "squeeze-updates"]: - utils.fubar("Will not reset suite %s" % (suite_name)) - britney = False if action == "set" and cnf["Control-Suite::Options::Britney"]: britney = True diff --combined dak/dakdb/update70.py index 00000000,00000000..333c5d6b new file mode 100755 --- /dev/null +++ b/dak/dakdb/update70.py @@@ -1,0 -1,0 +1,71 @@@ ++#!/usr/bin/env python ++# coding=utf8 ++ ++""" ++Add suite options for overrides and control-suite to DB ++ ++@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 ++from daklib.config import Config ++ ++################################################################################ ++def do_update(self): ++ """ ++ Add suite options for overrides and control-suite to DB ++ """ ++ print __doc__ ++ try: ++ cnf = Config() ++ ++ c = self.db.cursor() ++ ++ c.execute("ALTER TABLE suite ADD COLUMN overrideprocess BOOLEAN NOT NULL DEFAULT FALSE") ++ c.execute("COMMENT ON COLUMN suite.overrideprocess IS %s", ['If true, check-overrides will process the suite by default']) ++ c.execute("ALTER TABLE suite ADD COLUMN overrideorigin TEXT DEFAULT NULL") ++ c.execute("COMMENT ON COLUMN suite.overrideprocess IS %s", ['If NOT NULL, check-overrides will take missing overrides from the named suite']) ++ ++ # Migrate config file values into database ++ if cnf.has_key("Check-Overrides::OverrideSuites"): ++ for suitename in cnf.SubTree("Check-Overrides::OverrideSuites").List(): ++ if cnf.get("Check-Overrides::OverrideSuites::%s::Process" % suitename, "0") == "1": ++ print "Marking %s to have overrides processed automatically" % suitename.lower() ++ c.execute("UPDATE suite SET overrideprocess = TRUE WHERE suite_name = %s", [suitename.lower()]) ++ ++ originsuite = cnf.get("Check-Overrides::OverrideSuites::%s::OriginSuite" % suitename, '') ++ if originsuite != '': ++ print "Setting %s to use %s as origin for overrides" % (suitename.lower(), originsuite.lower()) ++ c.execute("UPDATE suite SET overrideorigin = %s WHERE suite_name = %s", [originsuite.lower(), suitename.lower()]) ++ ++ c.execute("ALTER TABLE suite ADD COLUMN allowcsset BOOLEAN NOT NULL DEFAULT FALSE") ++ c.execute("COMMENT ON COLUMN suite.allowcsset IS %s", ['Allow control-suite to be used with the --set option without forcing']) ++ ++ # Import historical hard-coded values ++ c.execute("UPDATE suite SET allowcsset = TRUE WHERE suite_name IN ('testing', 'squeeze-updates')") ++ ++ c.execute("UPDATE config SET value = '70' WHERE name = 'db_revision'") ++ self.db.commit() ++ ++ except psycopg2.ProgrammingError as msg: ++ self.db.rollback() ++ raise DBUpdateError('Unable to apply sick update 70, rollback issued. Error message : %s' % (str(msg)))