[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] reject uploads that might cause conflicts with buildd uploads



For policy queues dak keeps the .buildinfo and .changes around until
the upload is processed.  As the uploads might already be sent to
buildds while waiting in the policy queue, the buildd upload might use
the same filename and end up getting rejected.  With this change, the
upload getting rejected should be the maintainer's upload.
---
 daklib/archive.py |  1 +
 daklib/checks.py  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/daklib/archive.py b/daklib/archive.py
index 8be748b..5d362a1 100644
--- a/daklib/archive.py
+++ b/daklib/archive.py
@@ -963,6 +963,7 @@ class ArchiveUpload(object):
                     checks.WeakSignatureCheck,
                     checks.SignatureTimestampCheck,
                     checks.ChangesCheck,
+                    checks.SuffixCheck,
                     checks.ExternalHashesCheck,
                     checks.SourceCheck,
                     checks.BinaryCheck,
diff --git a/daklib/checks.py b/daklib/checks.py
index 72d13e2..673886a 100644
--- a/daklib/checks.py
+++ b/daklib/checks.py
@@ -260,6 +260,37 @@ class ChangesCheck(Check):
 
         return True
 
+class SuffixCheck(Check):
+    """Checks suffix of .changes and .buildinfo files.
+
+    buildd uploads will include _${arch}.changes and _${arch}.buildinfo, so such endings
+    should be reserved for uploads including binaries for ${arch} to avoid conflicts
+    (for example in policy queues where dak stores the .changes and .buildinfo for later
+    processing)
+    """
+    def check(self, upload):
+        session = upload.session
+        changes = upload.changes
+
+        suffixes = []
+
+        changes_match = re_file_changes.match(changes.filename)
+        assert(changes_match)
+        suffixes.append((changes.filename, changes_match.group('suffix')))
+
+        for bi in changes.buildinfo_files:
+            bi_match = re_file_buildinfo.match(bi.filename)
+            assert(bi_match)
+            suffixes.append((bi.filename, bi_match.group('suffix')))
+
+        for fn, suffix in suffixes:
+            if suffix in changes.architectures:
+                continue
+            if session.query(Architecture).filter_by(arch_string=suffix).first():
+                raise Reject("The upload includes '{}' whose filename includes the architecture name {}, but does not include binaries for {}. It is rejected to avoid filename conflicts with later buildd uploads.".format(fn, suffix, suffix))
+
+        return True
+
 class ExternalHashesCheck(Check):
     """Checks hashes in .changes and .dsc against an external database."""
     def check_single(self, session, f):
-- 
2.1.4


Reply to: