Make verify_all() return an "insufficient data" error if there is not at least one...
authorZac Medico <zmedico@gentoo.org>
Fri, 23 Feb 2007 13:23:22 +0000 (13:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 23 Feb 2007 13:23:22 +0000 (13:23 -0000)
svn path=/main/trunk/; revision=6055

pym/portage/checksum.py

index 1a96787ec194bea672dfc447e953e8b48a7b7d01..77c962526d64f23078124e8d1617915f7f2ff405 100644 (file)
@@ -3,6 +3,8 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
+if not hasattr(__builtins__, "set"):
+       from sets import Set as set
 
 from portage.const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE
 import os
@@ -113,6 +115,22 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
                if e.errno == errno.ENOENT:
                        raise portage.exception.FileNotFound(filename)
                return False, (str(e), None, None)
+
+       verifiable_hash_types = set(mydict).intersection(hashfunc_map)
+       verifiable_hash_types.discard("size")
+       if not verifiable_hash_types:
+               expected = set(hashfunc_map)
+               expected.discard("size")
+               expected = list(expected)
+               expected.sort()
+               expected = " ".join(expected)
+               got = set(mydict)
+               got.discard("size")
+               got = list(got)
+               got.sort()
+               got = " ".join(got)
+               return False, ("Insufficient data for checksum verification", got, expected)
+
        for x in mydict.keys():
                if   x == "size":
                        continue