Skip to content

Commit 3e54cf5

Browse files
committed
Postpone to a separate PR the build-installer changes to support additional hash types
1 parent 8aa4e57 commit 3e54cf5

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

Mac/BuildScript/build-installer.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
Usage: see USAGE variable in the script.
3838
"""
3939
import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd, grp
40-
import hashlib
4140
try:
4241
import urllib2 as urllib_request
4342
except ImportError:
@@ -362,7 +361,7 @@ def library_recipes():
362361
dict(
363362
name="SQLite 3.50.4",
364363
url="https://www.sqlite.org/2025/sqlite-autoconf-3500400.tar.gz",
365-
checksum="sha3-256:330bb88febc08814d49406391891eddac59e5f812e87b83c27ab172687554375",
364+
checksum="a3db587a1b92ee5ddac2f66b3edb41b26f9c867275782d46c3a088977d6a5b18",
366365
extra_cflags=('-Os '
367366
'-DSQLITE_ENABLE_FTS5 '
368367
'-DSQLITE_ENABLE_FTS4 '
@@ -796,7 +795,7 @@ def downloadURL(url, fname):
796795
def verifyThirdPartyFile(url, checksum, fname):
797796
"""
798797
Download file from url to filename fname if it does not already exist.
799-
Abort if file contents does not match supplied hashlib checksum.
798+
Abort if file contents does not match supplied md5 checksum.
800799
"""
801800
name = os.path.basename(fname)
802801
if os.path.exists(fname):
@@ -806,30 +805,16 @@ def verifyThirdPartyFile(url, checksum, fname):
806805
print("Downloading %s"%(name,))
807806
downloadURL(url, fname)
808807
print("Archive for %s stored as %s"%(name, fname))
809-
if ':' in checksum:
810-
algo, _, checksum = checksum.partition(':')
811-
assert algo in hashlib.algorithms_guaranteed, f"Unsupported {algo}, try sha3-256 or sha256 instead."
812-
if algo in ("md5", "sha1"):
813-
raise ValueError(f"Known insecure checksum algorithm {algo} for {fname}.")
814-
if algo.startswith(("shake", "blake")):
815-
raise ValueError(f"Please stick to sha2 or sha3 standard checksum algorithms, not {algo}")
816-
# TODO remove length based logic AND legacy md5s after updating the ones we already list.
817-
elif len(checksum) == 32:
808+
if len(checksum) == 32:
818809
algo = 'md5'
819-
print("WARNING: insecure md5 used for {fname}", file=sys.stderr)
820810
elif len(checksum) == 64:
821811
algo = 'sha256'
822812
else:
823813
raise ValueError(checksum)
824-
with open(fname, 'rb') as downloaded_file:
825-
if hasattr(hashlib, 'file_digest'):
826-
hasher = hashlib.file_digest(downloaded_file, algo) # 3.11+
827-
else:
828-
hasher = hashlib.new(algo, downloaded_file.read())
829-
computed_checksum = hasher.hexdigest()
830-
if computed_checksum != checksum:
831-
fatal(f"{algo} hashlib checksum mismatch for file {fname}")
832-
814+
if os.system(
815+
'CHECKSUM=$(openssl %s %s) ; test "${CHECKSUM##*= }" = "%s"'
816+
% (algo, shellQuote(fname), checksum) ):
817+
fatal('%s checksum mismatch for file %s' % (algo, fname))
833818

834819
def build_universal_openssl(basedir, archList):
835820
"""

0 commit comments

Comments
 (0)