X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fprocess_unchecked.py;h=f2efe8c0393439dbfe812bd542e30514d240845c;hb=536cb00b606a8581a76b66f55a58eabdf9f7fd3d;hp=5df4485db65b96c4e9b2348325b07d82be4ec773;hpb=6244fb61f95eae7db30ec31f74be31f6f86d31c2;p=dak.git diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index 5df4485d..f2efe8c0 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -630,11 +630,11 @@ def check_files(): # Check the md5sum & size against existing files (if any) files[f]["pool name"] = utils.poolify (changes["source"], files[f]["component"]) - files_id = database.get_files_id(files[f]["pool name"] + f, files[f]["size"], files[f]["md5sum"], files[f]["sha1sum"], files[f]["sha256sum"], files[f]["location id"]) + files_id = database.get_files_id(files[f]["pool name"] + f, files[f]["size"], files[f]["md5sum"], files[f]["location id"]) if files_id == -1: reject("INTERNAL ERROR, get_files_id() returned multiple matches for %s." % (f)) elif files_id == -2: - reject("md5sum, sha1sum, sha256sum and/or size mismatch on existing copy of %s." % (f)) + reject("md5sum and/or size mismatch on existing copy of %s." % (f)) files[f]["files id"] = files_id # Check for packages that have moved from one component to another @@ -777,8 +777,6 @@ def check_dsc(): files[orig_tar_gz] = {} files[orig_tar_gz]["size"] = os.stat(orig_tar_gz)[stat.ST_SIZE] files[orig_tar_gz]["md5sum"] = dsc_files[orig_tar_gz]["md5sum"] - files[orig_tar_gz]["sha1sum"] = dsc_files[orig_tar_gz]["sha1sum"] - files[orig_tar_gz]["sha256sum"] = dsc_files[orig_tar_gz]["sha256sum"] files[orig_tar_gz]["section"] = files[dsc_filename]["section"] files[orig_tar_gz]["priority"] = files[dsc_filename]["priority"] files[orig_tar_gz]["component"] = files[dsc_filename]["component"] @@ -929,28 +927,28 @@ def check_hashes (): check_hash(".changes", files, "md5sum", apt_pkg.md5sum) check_hash(".dsc", dsc_files, "md5sum", apt_pkg.md5sum) + if format >= (1,8): + hashes = [("sha1", apt_pkg.sha1sum), + ("sha256", apt_pkg.sha256sum)] + else: + hashes = [] + for x in changes: if x.startswith("checksum-"): h = x.split("-",1)[1] - if h not in dict(utils.known_hashes): + if h not in dict(hashes): reject("Unsupported checksum field in .changes" % (h)) for x in dsc: if x.startswith("checksum-"): h = x.split("-",1)[1] - if h not in dict(utils.known_hashes): + if h not in dict(hashes): reject("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 utils.known_hashes: + for h,f in hashes: try: fs = utils.build_file_list(changes, 0, "checksums-%s" % h, h) - if format < v: - create_hash(fs, h, f, files) - else: - check_hash(".changes %s" % (h), fs, h, f, files) + check_hash(".changes %s" % (h), fs, h, f, files) except NoFilesFieldError: reject("No Checksums-%s: field in .changes" % (h)) except UnknownFormatError, format: @@ -962,10 +960,7 @@ def check_hashes (): try: fs = utils.build_file_list(dsc, 1, "checksums-%s" % h, h) - if format < v: - create_hash(fs, h, f, dsc_files) - else: - check_hash(".dsc %s" % (h), fs, h, f, dsc_files) + check_hash(".dsc %s" % (h), fs, h, f, dsc_files) except UnknownFormatError, format: reject("%s: unknown format of .dsc" % (format)) except NoFilesFieldError: @@ -975,20 +970,6 @@ def check_hashes (): ################################################################################ -def create_hash (lfiles, key, testfn, basedict = None): - for f in lfiles.keys(): - try: - file_handle = utils.open_file(f) - except CantOpenError: - continue - - # Check hash - basedict[f]['%ssum' % key] = testfn(file_handle) - file_handle.close() - - -################################################################################ - def check_hash (where, lfiles, key, testfn, basedict = None): if basedict: for f in basedict.keys(): @@ -1008,8 +989,6 @@ def check_hash (where, lfiles, key, testfn, basedict = None): if testfn(file_handle) != lfiles[f][key]: reject("%s: %s check failed." % (f, key)) file_handle.close() - # Store the hashes for later use - basedict[f]['%ssum' % key] = lfiles[f][key] # Check size actual_size = os.stat(f)[stat.ST_SIZE] size = int(lfiles[f]["size"])