Add ./mach bootstrap-android

This commit is contained in:
Simon Sapin 2018-06-21 16:52:33 +02:00
parent c71c55e542
commit b9d5f11b20
3 changed files with 66 additions and 1 deletions

View file

@ -9,6 +9,7 @@
from __future__ import absolute_import, print_function, unicode_literals
import hashlib
import os
import os.path
import platform
@ -165,3 +166,15 @@ def extract(src, dst, movedir=None):
os.rmdir(movedir)
os.remove(src)
def check_hash(filename, expected, algorithm):
hasher = hashlib.new(algorithm)
with open(filename, "rb") as f:
while True:
block = f.read(16 * 1024)
if len(block) == 0:
break
hasher.update(block)
if hasher.hexdigest() != expected:
print("Incorrect {} hash for {}".format(algorithm, filename))
sys.exit(1)