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

[dak/master] make sure the .changes Architecture field is correct



Some other checks use it to see which architectures are included, for
example the previous commit.
---
 daklib/checks.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/daklib/checks.py b/daklib/checks.py
index 673886a..86c463c 100644
--- a/daklib/checks.py
+++ b/daklib/checks.py
@@ -334,9 +334,17 @@ class BinaryCheck(Check):
         debug_deb_name_postfix = "-dbgsym"
         # XXX: Handle dynamic debug section name here
 
+        self._architectures = set()
+
         for binary in upload.changes.binaries:
             self.check_binary(upload, binary)
 
+        for arch in upload.changes.architectures:
+            if arch == 'source':
+                continue
+            if arch not in self._architectures:
+                raise Reject('{}: Architecture field includes {}, but no binary packages for {} are included in the upload'.format(upload.changes.filename, arch, arch))
+
         binaries = {binary.control['Package']: binary
                         for binary in upload.changes.binaries}
 
@@ -396,6 +404,7 @@ class BinaryCheck(Check):
             raise Reject('{0}: Architecture not in Architecture field in changes file'.format(fn))
         if architecture == 'source':
             raise Reject('{0}: Architecture "source" invalid for binary packages'.format(fn))
+        self._architectures.add(architecture)
 
         source = control.get('Source')
         if source is not None and not re_field_source.match(source):
@@ -506,8 +515,13 @@ class SourceCheck(Check):
 
     def check(self, upload):
         if upload.changes.source is None:
+            if "source" in upload.changes.architectures:
+                raise Reject("{}: Architecture field includes source, but no source package is included in the upload".format(upload.changes.filename))
             return True
 
+        if "source" not in upload.changes.architectures:
+            raise Reject("{}: Architecture field does not include source, but a source package is included in the upload".format(upload.changes.filename))
+
         changes = upload.changes.changes
         source = upload.changes.source
         control = source.dsc
-- 
2.1.4


Reply to: