summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index c540b49cf6..f75312399b 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -523,12 +523,17 @@ def md5_file(filename):
523 """ 523 """
524 Return the hex string representation of the MD5 checksum of filename. 524 Return the hex string representation of the MD5 checksum of filename.
525 """ 525 """
526 import hashlib 526 import hashlib, mmap
527 m = hashlib.md5()
528 527
529 with open(filename, "rb") as f: 528 with open(filename, "rb") as f:
530 for line in f: 529 m = hashlib.md5()
531 m.update(line) 530 try:
531 with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as mm:
532 for chunk in iter(lambda: mm.read(8192), b''):
533 m.update(chunk)
534 except ValueError:
535 # You can't mmap() an empty file so silence this exception
536 pass
532 return m.hexdigest() 537 return m.hexdigest()
533 538
534def sha256_file(filename): 539def sha256_file(filename):