- for x in Upload.changes:
- if x.startswith("checksum-"):
- h = x.split("-",1)[1]
- if h not in dict(known_hashes):
- rejmsg.append("Unsupported checksum field in .changes" % (h))
-
- for x in Upload.dsc:
- if x.startswith("checksum-"):
- h = x.split("-",1)[1]
- if h not in dict(known_hashes):
- rejmsg.append("Unsupported checksum field in .dsc" % (h))
+ if not dsc.has_key('Checksums-%s' % (hashname,)):
+ return rejmsg
+ # Import hashes from the dsc
+ parse_checksums(".dsc", dsc_files, dsc, hashname)
+ # And check it...
+ rejmsg.extend(check_hash(".dsc", dsc_files, hashname, hashfunc))
+ return rejmsg
+
+################################################################################
+
+def ensure_hashes(changes, dsc, files, dsc_files):
+ rejmsg = []
+
+ # Make sure we recognise the format of the Files: field in the .changes
+ format = changes.get("format", "0.0").split(".", 1)
+ if len(format) == 2:
+ format = int(format[0]), int(format[1])
+ else:
+ format = int(float(format[0])), 0
+
+ # We need to deal with the original changes blob, as the fields we need
+ # might not be in the changes dict serialised into the .dak anymore.
+ orig_changes = parse_deb822(changes['filecontents'])
+
+ # Copy the checksums over to the current changes dict. This will keep
+ # the existing modifications to it intact.
+ for field in orig_changes:
+ if field.startswith('checksums-'):
+ changes[field] = orig_changes[field]
+
+ # Check for unsupported hashes
+ rejmsg.extend(check_hash_fields(".changes", changes))
+ rejmsg.extend(check_hash_fields(".dsc", dsc))