-# check if section/priority values are valid
-
-def check_valid (new):
- for pkg in new.keys():
- section = new[pkg]["section"]
- priority = new[pkg]["priority"]
- type = new[pkg]["type"]
- new[pkg]["section id"] = database.get_section_id(section)
- new[pkg]["priority id"] = database.get_priority_id(new[pkg]["priority"])
- # Sanity checks
- di = section.find("debian-installer") != -1
- if (di and type != "udeb") or (not di and type == "udeb"):
- new[pkg]["section id"] = -1
- if (priority == "source" and type != "dsc") or \
- (priority != "source" and type == "dsc"):
- new[pkg]["priority id"] = -1
+def ensure_hashes(Upload):
+ rejmsg = []
+ 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))
+
+ # We have to calculate the hash if we have an earlier changes version than
+ # the hash appears in rather than require it exist in the changes file
+ # I hate backwards compatibility
+ for h,f,v in known_hashes:
+ try:
+ fs = build_file_list(Upload.changes, 0, "checksums-%s" % h, h)
+ if format < v:
+ for m in create_hash(fs, h, f, Upload.files):
+ rejmsg.append(m)
+ else:
+ for m in check_hash(".changes %s" % (h), fs, h, f, Upload.files):
+ rejmsg.append(m)
+ except NoFilesFieldError:
+ rejmsg.append("No Checksums-%s: field in .changes" % (h))
+ except UnknownFormatError, format:
+ rejmsg.append("%s: unknown format of .changes" % (format))
+ except ParseChangesError, line:
+ rejmsg.append("parse error for Checksums-%s in .changes, can't grok: %s." % (h, line))
+
+ if "source" not in Upload.changes["architecture"]: continue
+
+ try:
+ fs = build_file_list(Upload.dsc, 1, "checksums-%s" % h, h)
+ if format < v:
+ for m in create_hash(fs, h, f, Upload.dsc_files):
+ rejmsg.append(m)
+ else:
+ for m in check_hash(".dsc %s" % (h), fs, h, f, Upload.dsc_files):
+ rejmsg.append(m)
+ except UnknownFormatError, format:
+ rejmsg.append("%s: unknown format of .dsc" % (format))
+ except NoFilesFieldError:
+ rejmsg.append("No Checksums-%s: field in .dsc" % (h))
+ except ParseChangesError, line:
+ rejmsg.append("parse error for Checksums-%s in .dsc, can't grok: %s." % (h, line))
+
+ return rejmsg