]> git.decadent.org.uk Git - dak.git/commitdiff
daklib/archive.py, daklib/checks.py: implement transition blocks
authorAnsgar Burchardt <ansgar@debian.org>
Mon, 6 Aug 2012 09:59:34 +0000 (11:59 +0200)
committerAnsgar Burchardt <ansgar@debian.org>
Thu, 9 Aug 2012 14:43:01 +0000 (16:43 +0200)
daklib/archive.py
daklib/checks.py

index 0c5d805d10fbc4f84097f4e663b3552a6862ff36..7f6895ad760aa7e69916a701efd56f32e1b6bcc1 100644 (file)
@@ -795,6 +795,7 @@ class ArchiveUpload(object):
             for chk in (
                     checks.SignatureCheck,
                     checks.ChangesCheck,
+                    checks.TransitionCheck,
                     checks.UploadBlockCheck,
                     checks.HashesCheck,
                     checks.SourceCheck,
index d05c71fdaf66a51ac2fded6123702d7786a57724..260eb18a10a0cad687581d589441629be6190b25 100644 (file)
@@ -457,6 +457,72 @@ class UploadBlockCheck(Check):
 
         return True
 
+class TransitionCheck(Check):
+    """check for a transition"""
+    def check(self, upload):
+        if 'source' not in upload.changes.architectures:
+            return True
+
+        transitions = self.get_transitions()
+        if transitions is None:
+            return True
+
+        source = re_field_source.match(control['Source']).group('package')
+
+        for trans in transitions:
+            t = transitions[trans]
+            source = t["source"]
+            expected = t["new"]
+
+            # Will be None if nothing is in testing.
+            current = get_source_in_suite(source, "testing", session)
+            if current is not None:
+                compare = apt_pkg.version_compare(current.version, expected)
+
+            if current is None or compare < 0:
+                # This is still valid, the current version in testing is older than
+                # the new version we wait for, or there is none in testing yet
+
+                # Check if the source we look at is affected by this.
+                if source in t['packages']:
+                    # The source is affected, lets reject it.
+
+                    rejectmsg = "{0}: part of the {1} transition.\n\n".format(source, trans)
+
+                    if current is not None:
+                        currentlymsg = "at version {0}".format(current.version)
+                    else:
+                        currentlymsg = "not present in testing"
+
+                    rejectmsg += "Transition description: {0}\n\n".format(t["reason"])
+
+                    rejectmsg += "\n".join(textwrap.wrap("""Your package
+is part of a testing transition designed to get {0} migrated (it is
+currently {1}, we need version {2}).  This transition is managed by the
+Release Team, and {3} is the Release-Team member responsible for it.
+Please mail debian-release@lists.debian.org or contact {3} directly if you
+need further assistance.  You might want to upload to experimental until this
+transition is done.""".format(source, currentlymsg, expected,t["rm"])))
+
+                    raise Reject(rejectmsg)
+
+        return True
+
+    def get_transitions(self):
+        cnf = Config()
+        path = cnf.get('Dinstall::ReleaseTransitions', '')
+        if path == '' or not os.path.exists(path):
+            return None
+
+        contents = file(path, 'r').read()
+        try:
+            transitions = yaml.load(contents)
+            return transitions
+        except yaml.YAMLError as msg:
+            utils.warn('Not checking transitions, the transitions file is broken: {0}'.format(msg))
+
+        return None
+
 class NoSourceOnlyCheck(Check):
     """Check for source-only upload