From 9761fe7db6fcf0c15ff9b740d6d1ca57b46a2896 Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Mon, 19 Dec 2005 23:58:17 +0000 Subject: Make digest errors more verbose svn path=/main/trunk/; revision=2412 --- pym/portage.py | 16 +++++++++++++--- pym/portage_checksum.py | 10 ++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'pym') diff --git a/pym/portage.py b/pym/portage.py index a5295f21e..4c9a0a04e 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1920,7 +1920,11 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", # Verify checksums at each fetch for fetchonly. verified_ok,reason = portage_checksum.verify_all(mysettings["DISTDIR"]+"/"+myfile, mydigests[myfile]) if not verified_ok: - writemsg("!!! Previously fetched file: "+str(myfile)+"\n!!! Reason: "+reason+"\nRefetching...\n\n") + writemsg("!!! Previously fetched file: "+str(myfile)+"\n") + writemsg("!!! Reason: "+reason[0]+"\n") + writemsg("!!! Got: "+reason[1]+"\n") + writemsg("!!! Expected: "+reason[2]+"\n") + writemsg("Refetching...\n\n") os.unlink(mysettings["DISTDIR"]+"/"+myfile) fetched=0 else: @@ -2019,7 +2023,11 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", # from another mirror... verified_ok,reason = portage_checksum.verify_all(mysettings["DISTDIR"]+"/"+myfile, mydigests[myfile]) if not verified_ok: - writemsg("!!! Fetched file: "+str(myfile)+" VERIFY FAILED!\n!!! Reason: "+reason+"\nRemoving corrupt distfile...\n") + writemsg("!!! Fetched file: "+str(myfile)+" VERIFY FAILED!\n") + writemsg("!!! Reason: "+reason[0]+"\n") + writemsg("!!! Got: "+reason[1]+"\n") + writemsg("!!! Expected: "+reason[2]+"\n") + writemsg("Removing corrupt distfile...\n") os.unlink(mysettings["DISTDIR"]+"/"+myfile) fetched=0 else: @@ -2273,7 +2281,9 @@ def digestCheckFiles(myfiles, mydigests, basedir, note="", strict=0): print print red("!!! Digest verification Failed:") print red("!!!")+" "+str(myfile) - print red("!!! Reason: ")+reason + print red("!!! Reason: ")+reason[0] + print red("!!! Got: ")+reason[1] + print red("!!! Expected: ")+reason[2] print return 0 else: diff --git a/pym/portage_checksum.py b/pym/portage_checksum.py index 5625f2322..9f31e0f6c 100644 --- a/pym/portage_checksum.py +++ b/pym/portage_checksum.py @@ -83,20 +83,22 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0): file_is_ok = True reason = "Reason unknown" try: - if mydict["size"] != os.stat(filename)[stat.ST_SIZE]: - return False,"Filesize does not match recorded size" + mysize = os.stat(filename)[stat.ST_SIZE] + if mydict["size"] != mysize: + return False,("Filesize does not match recorded size", mysize, mydict["size"]) except OSError, e: return False, str(e) for x in mydict.keys(): if x == "size": continue elif x in hashfunc_map.keys(): - if mydict[x] != perform_checksum(filename, hashfunc_map[x], calc_prelink=calc_prelink)[0]: + myhash = perform_checksum(filename, hashfunc_map[x], calc_prelink=calc_prelink)[0] + if mydict[x] != myhash: if strict: raise portage_exception.DigestException, "Failed to verify '$(file)s' on checksum type '%(type)s'" % {"file":filename, "type":x} else: file_is_ok = False - reason = "Failed on %s verification" % (x,) + reason = (("Failed on %s verification" % x), myhash,mydict[x]) break return file_is_ok,reason -- cgit v1.2.3-1-g7c22