- if "source" not in changes["architecture"]: continue
-
- try:
- fs = daklib.utils.build_file_list(dsc, 1, "checksums-%s" % h, h)
- check_hash(".dsc %s" % (h), fs, h, f, dsc_files)
- except daklib.utils.no_files_exc:
- reject("No Checksums-%s: field in .changes file" % (h))
-
-################################################################################
-
-def check_hash (where, files, key, testfn, basedict = None):
- if basedict:
- for file in basedict.keys():
- if file not in files:
- reject("%s: no %s checksum" % (file, key))
-
- for file in files.keys():
- if basedict and file not in basedict:
- reject("%s: extraneous entry in %s checksums" % (file, key))
-
- try:
- file_handle = daklib.utils.open_file(file)
- except daklib.utils.cant_open_exc:
- continue
-
- # Check hash
- if testfn(file_handle) != files[file][key]:
- reject("%s: %s check failed." % (file, key))
- file_handle.close()
- # Check size
- actual_size = os.stat(file)[stat.ST_SIZE]
- size = int(files[file]["size"])
- if size != actual_size:
- reject("%s: actual file size (%s) does not match size (%s) in %s"
- % (file, actual_size, size, where))
+ # This is stupid API, but it'll have to do for now until
+ # we actually have proper abstraction
+ for m in utils.ensure_hashes(changes, dsc, files, dsc_files):
+ reject(m)