diff --git a/build.py b/build.py index b3b0252dfa..0eb7877342 100755 --- a/build.py +++ b/build.py @@ -62,6 +62,7 @@ SRC = [path if path.endswith('.js')] PLOVR_JAR = 'bin/plovr-eba786b34df9.jar' +PLOVR_JAR_MD5 = '20eac8ccc4578676511cf7ccbfc65100' def report_sizes(t): @@ -205,7 +206,7 @@ pake.virtual('plovr', PLOVR_JAR) @pake.target(PLOVR_JAR, clean=False) def plovr_jar(t): - t.download('https://plovr.googlecode.com/files/' + os.path.basename(PLOVR_JAR)) + t.download('https://plovr.googlecode.com/files/' + os.path.basename(PLOVR_JAR), md5=PLOVR_JAR_MD5) @pake.target('gh-pages', 'hostexamples', 'doc', phony=True) diff --git a/pake.py b/pake.py index a812c4ebfa..509d5e8658 100644 --- a/pake.py +++ b/pake.py @@ -2,6 +2,7 @@ import collections import contextlib +import hashlib import logging import optparse import os @@ -126,8 +127,12 @@ class Target(object): def debug(self, *args, **kwargs): self.logger.debug(*args, **kwargs) - def download(self, url): + def download(self, url, md5=None): content = urllib2.urlopen(url).read() + if md5 and hashlib.md5(content).hexdigest() != md5: + raise pake.BuildError(t, 'corrupt download') + # FIXME Python on Windoze corrupts the content when writing it + # FIXME probably something to do with encodings with open(self.name, 'w') as f: f.write(content)