3737Usage: see USAGE variable in the script.
3838"""
3939import platform , os , sys , getopt , textwrap , shutil , stat , time , pwd , grp
40+ import hashlib
4041try :
4142 import urllib2 as urllib_request
4243except ImportError :
@@ -359,9 +360,9 @@ def library_recipes():
359360 ),
360361 ),
361362 dict (
362- name = "SQLite 3.49.1 " ,
363- url = "https://sqlite.org/2025/sqlite-autoconf-3490100 .tar.gz" ,
364- checksum = "106642d8ccb36c5f7323b64e4152e9b719f7c0215acf5bfeac3d5e7f97b59254 " ,
363+ name = "SQLite 3.50.3 " ,
364+ url = "https://www. sqlite.org/2025/sqlite-autoconf-3500300 .tar.gz" ,
365+ checksum = "sha3-256:c3df1542703a666d3f41bb623e9bed7d6e1dc81c57f0c45e3122403f862c520d " ,
365366 extra_cflags = ('-Os '
366367 '-DSQLITE_ENABLE_FTS5 '
367368 '-DSQLITE_ENABLE_FTS4 '
@@ -795,7 +796,7 @@ def downloadURL(url, fname):
795796def verifyThirdPartyFile (url , checksum , fname ):
796797 """
797798 Download file from url to filename fname if it does not already exist.
798- Abort if file contents does not match supplied md5 checksum.
799+ Abort if file contents does not match supplied hashlib checksum.
799800 """
800801 name = os .path .basename (fname )
801802 if os .path .exists (fname ):
@@ -805,16 +806,30 @@ def verifyThirdPartyFile(url, checksum, fname):
805806 print ("Downloading %s" % (name ,))
806807 downloadURL (url , fname )
807808 print ("Archive for %s stored as %s" % (name , fname ))
808- if len (checksum ) == 32 :
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 :
809818 algo = 'md5'
819+ print ("WARNING: insecure md5 used for {fname}" , file = sys .stderr )
810820 elif len (checksum ) == 64 :
811821 algo = 'sha256'
812822 else :
813823 raise ValueError (checksum )
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 ))
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+
818833
819834def build_universal_openssl (basedir , archList ):
820835 """
0 commit comments