aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/util.py
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2018-06-21 16:52:33 +0200
committerSimon Sapin <simon.sapin@exyr.org>2018-07-02 13:25:44 +0200
commitb9d5f11b208e3b888433e9de3ad5eee503e82ea1 (patch)
tree9a6e878ba1f968b430a3acc4361daa01bba19d02 /python/servo/util.py
parentc71c55e542c57f6ec4e5e77be750f74f50340e56 (diff)
downloadservo-b9d5f11b208e3b888433e9de3ad5eee503e82ea1.tar.gz
servo-b9d5f11b208e3b888433e9de3ad5eee503e82ea1.zip
Add `./mach bootstrap-android`
Diffstat (limited to 'python/servo/util.py')
-rw-r--r--python/servo/util.py13
1 files changed, 13 insertions, 0 deletions
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)