sb: Fix using hashlib's algorithms on python earlier than 2.7.

This commit is contained in:
Chris Johns 2014-08-04 18:09:30 +10:00
parent 7c46699472
commit 910081d515

View File

@ -58,7 +58,11 @@ def _hash_check(file_, absfile, macros, remove = True):
hash = hash.split()
if len(hash) != 2:
raise error.internal('invalid hash format: %s' % (file_))
if hash[0] not in hashlib.algorithms:
try:
hashlib_algorithms = hashlib.algorithms
except:
hashlib_algorithms = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']
if hash[0] not in hashlib_algorithms:
raise error.general('invalid hash algorithm for %s: %s' % (file_, hash[0]))
hasher = None
_in = None