Make digest errors more verbose
authorMarius Mauch <genone@gentoo.org>
Mon, 19 Dec 2005 23:58:17 +0000 (23:58 -0000)
committerMarius Mauch <genone@gentoo.org>
Mon, 19 Dec 2005 23:58:17 +0000 (23:58 -0000)
svn path=/main/trunk/; revision=2412

pym/portage.py
pym/portage_checksum.py

index a5295f21e41488cd80a8cc07698d4bcefa768eb5..4c9a0a04e91237fa30de44b4d6971b82276c240f 100644 (file)
@@ -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:
index 5625f2322559255c6d2e58061323e45591d613ae..9f31e0f6c0ff7912ee79cd5b1e44e81fe618cb7f 100644 (file)
@@ -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