From b9c050bb14a6e7266717ad5f0f48cc0b543294ae Mon Sep 17 00:00:00 2001 From: mpeterv Date: Sun, 20 Mar 2016 19:37:06 +0300 Subject: [PATCH] Add an option to turn checksum mismatches into warnings Leaves an option to not break if something changes upstream. --- hererocks.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hererocks.py b/hererocks.py index df74ff1..0190cd8 100755 --- a/hererocks.py +++ b/hererocks.py @@ -272,8 +272,13 @@ class Program(object): expected_checksum = self.checksums[self.get_file_name()] observed_checksum = sha256_of_file(archive_name) if expected_checksum != observed_checksum: - sys.exit("Error: SHA256 checksum mismatch for {}\nExpected: {}\nObserved: {}".format( - archive_name, expected_checksum, observed_checksum)) + message = "SHA256 checksum mismatch for {}\nExpected: {}\nObserved: {}".format( + archive_name, expected_checksum, observed_checksum) + + if opts.ignore_checksums: + print("Warning: " + message) + else: + sys.exit("Error: " + message) if self.win32_zip: archive = zipfile.ZipFile(archive_name) @@ -873,6 +878,9 @@ def main(): parser.add_argument("--no-git-cache", help="Do not cache default git repos.", action="store_true", default=False) + parser.add_argument("--ignore-checksums", + help="Ignore checksum mismatches for downloads.", + action="store_true", default=False) parser.add_argument("--builds", # help="Cache Lua and LuaJIT builds in 'BUILDS' directory.", help=argparse.SUPPRESS, default=None)