]> git.decadent.org.uk Git - dak.git/commitdiff
Merge remote branch 'ftpmaster/master' into override-cs-db
authorMark Hymers <mhy@debian.org>
Sun, 4 Sep 2011 18:17:03 +0000 (19:17 +0100)
committerMark Hymers <mhy@debian.org>
Sun, 4 Sep 2011 18:17:03 +0000 (19:17 +0100)
Conflicts:
dak/dakdb/update69.py

Signed-off-by: Mark Hymers <mhy@debian.org>
dak/check_overrides.py
dak/control_suite.py
dak/dakdb/update70.py [new file with mode: 0755]
dak/make_overrides.py

index 622067879f8cfa590077284062e4657aa4077df8..e833aa75ff4a479b420ac6b82e97554c12e1877c 100755 (executable)
@@ -345,26 +345,25 @@ def main ():
     else:
         Logger = daklog.Logger("check-overrides", 1)
 
-    for osuite in cnf.SubTree("Check-Overrides::OverrideSuites").List():
-        if "1" != cnf["Check-Overrides::OverrideSuites::%s::Process" % osuite]:
-            continue
-
-        osuite = osuite.lower()
-
+    for suite in session.query(Suite).filter(Suite.overrideprocess==True):
         originosuite = None
-        originremark = ""
-        try:
-            originosuite = cnf["Check-Overrides::OverrideSuites::%s::OriginSuite" % osuite]
-            originosuite = originosuite.lower()
+        originremark = ''
+
+        if suite.overrideorigin is not None:
+            originosuite = get_suite(suite.overrideorigin, session)
+            if originosuite is None:
+                utils.fubar("%s has an override origin suite of %s but it doesn't exist!" % (suite.suite_name, suite.overrideorigin))
+            originosuite = originosuite.suite_name
             originremark = " taking missing from %s" % originosuite
-        except KeyError:
-            pass
 
-        print "Processing %s%s..." % (osuite, originremark)
-        suiteobj = get_suite(osuite)
-        # Get a list of all suites that use the override file of 'osuite'
-        ocodename = suiteobj.codename
+        print "Processing %s%s..." % (suite.suite_name, originremark)
+
+        # Get a list of all suites that use the override file of 'suite.suite_name' as
+        # well as the suite
+        ocodename = suite.codename
         suiteids = [x.suite_id for x in session.query(Suite).filter(Suite.overridecodename == ocodename).all()]
+        if suite.suite_id not in suiteids:
+            suiteids.append(suite.suite_id)
 
         if len(suiteids) < 1:
             utils.fubar("Couldn't find id's of all suites: %s" % suiteids)
@@ -381,9 +380,9 @@ def main ():
 
             for otype in otypes:
                 print "Processing %s [%s - %s]" \
-                    % (osuite, component_name, otype)
+                    % (suite.suite_name, component_name, otype)
                 sys.stdout.flush()
-                process(osuite, suiteids, originosuite, component_name, otype, session)
+                process(suite.suite_name, suiteids, originosuite, component_name, otype, session)
 
     Logger.close()
 
index 236e36aa4cfbd005679f5f22f6f21a6de7d5d429..d18bc70594ac8fd8c03d60978f69953a8f3744b7 100755 (executable)
@@ -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 --git a/dak/dakdb/update70.py b/dak/dakdb/update70.py
new file mode 100755 (executable)
index 0000000..333c5d6
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Add suite options for overrides and control-suite to DB
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2011 Mark Hymers <mhy@debian.org>
+@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)))
index 716b085bdf488f975c541113c70013235b0a67b4..1d8f9c02ca7fc7a6b3fcf6636f0d72e4cffa2b94 100755 (executable)
@@ -112,11 +112,9 @@ def main ():
     d = DBConn()
     session = d.session()
 
-    for suite_name in cnf.SubTree("Check-Overrides::OverrideSuites").List():
-        suite = get_suite(suite_name.lower(), session)
-        if not suite:
-            utils.fubar('Suite %s not found' % suite_name)
+    for suite in session.query(Suite).filter(Suite.overrideprocess==True):
         if suite.untouchable:
+            print "Skipping %s as it is marked as untouchable" % suite.suite_name
             continue
 
         sys.stderr.write("Processing %s...\n" % (suite.suite_name))