summaryrefslogtreecommitdiff
path: root/importpkg.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2013-02-24 01:03:30 +0100
committerHelmut Grohne <helmut@subdivi.de>2013-02-24 01:03:30 +0100
commitf09f59b271a1e23eda162fd357814ca560f72a34 (patch)
tree0185432442da1a6e866c50c73c0077c94f721c01 /importpkg.py
parent844b08c9ef4c248ff3cc454614bd16a811a3a040 (diff)
downloaddebian-dedup-f09f59b271a1e23eda162fd357814ca560f72a34.tar.gz
hash image contents
Diffstat (limited to 'importpkg.py')
-rwxr-xr-ximportpkg.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/importpkg.py b/importpkg.py
index 5901b57..d626fba 100755
--- a/importpkg.py
+++ b/importpkg.py
@@ -20,6 +20,7 @@ import lzma
from dedup.hashing import HashBlacklist, DecompressedHash, SuppressingHash, hash_file
from dedup.compression import GzipDecompressor, DecompressedStream
+from dedup.image import ImageHash
class ArReader(object):
global_magic = b"!<arch>\n"
@@ -96,11 +97,17 @@ def gziphash():
hashobj.name = "gzip_sha512"
return HashBlacklist(hashobj, boring_sha512_hashes)
+def imagehash():
+ hashobj = ImageHash(hashlib.sha512())
+ hashobj = SuppressingHash(hashobj, (ValueError,))
+ hashobj.name = "image_sha512"
+ return hashobj
+
def get_hashes(tar):
for elem in tar:
if not elem.isreg(): # excludes hard links as well
continue
- hasher = MultiHash(sha512_nontrivial(), gziphash())
+ hasher = MultiHash(sha512_nontrivial(), gziphash(), imagehash())
hasher = hash_file(hasher, tar.extractfile(elem))
for hashobj in hasher.hashes:
hashvalue = hashobj.hexdigest()