# 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:
# 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:
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:
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