From b9d5f11b208e3b888433e9de3ad5eee503e82ea1 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 21 Jun 2018 16:52:33 +0200 Subject: Add `./mach bootstrap-android` --- python/servo/util.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python/servo/util.py') diff --git a/python/servo/util.py b/python/servo/util.py index 2043b0e2868..a4e126d3240 100644 --- a/python/servo/util.py +++ b/python/servo/util.py @@ -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) -- cgit v1.2.3