Add an option to turn checksum mismatches into warnings

Leaves an option to not break if something changes upstream.
This commit is contained in:
mpeterv 2016-03-20 19:37:06 +03:00
parent ebd42a91a0
commit b9c050bb14

View File

@ -272,8 +272,13 @@ class Program(object):
expected_checksum = self.checksums[self.get_file_name()] expected_checksum = self.checksums[self.get_file_name()]
observed_checksum = sha256_of_file(archive_name) observed_checksum = sha256_of_file(archive_name)
if expected_checksum != observed_checksum: if expected_checksum != observed_checksum:
sys.exit("Error: SHA256 checksum mismatch for {}\nExpected: {}\nObserved: {}".format( message = "SHA256 checksum mismatch for {}\nExpected: {}\nObserved: {}".format(
archive_name, expected_checksum, observed_checksum)) archive_name, expected_checksum, observed_checksum)
if opts.ignore_checksums:
print("Warning: " + message)
else:
sys.exit("Error: " + message)
if self.win32_zip: if self.win32_zip:
archive = zipfile.ZipFile(archive_name) archive = zipfile.ZipFile(archive_name)
@ -873,6 +878,9 @@ def main():
parser.add_argument("--no-git-cache", parser.add_argument("--no-git-cache",
help="Do not cache default git repos.", help="Do not cache default git repos.",
action="store_true", default=False) 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", parser.add_argument("--builds",
# help="Cache Lua and LuaJIT builds in 'BUILDS' directory.", # help="Cache Lua and LuaJIT builds in 'BUILDS' directory.",
help=argparse.SUPPRESS, default=None) help=argparse.SUPPRESS, default=None)