@@ -144,10 +144,16 @@ def download_icu(icuroot, version, yes):
144
144
extension = "zip" if os .name == "nt" else "tgz"
145
145
146
146
archive_file = "icu4c-{0}-src.{1}" .format (version .replace ("." , "_" ), extension )
147
- md5_file = "icu4c-src-{0}.md5" .format (version .replace ("." , "_" ))
147
+ # Use this in future, currently the SHA hash file name for version 63.2 seems to not include version name.
148
+ #hash_file = "icu4c-{0}-src.{1}.asc".format(version.replace(".", "_"), extension)
149
+ hash_file = "icu4c-SHASUM512.txt.asc"
148
150
149
- archive_url = "http://download.icu-project.org/files/icu4c/{0}/{1}" .format (version , archive_file )
150
- md5_url = "https://ssl.icu-project.org/files/icu4c/{0}/{1}" .format (version , md5_file )
151
+ archive_url = "https://github.com/unicode-org/icu/releases/download/release-{0}/{1}" .format (version .replace ("." , "-" ), archive_file )
152
+ hash_url = "https://github.com/unicode-org/icu/releases/download/release-{0}/{1}" .format (version .replace ("." , "-" ), hash_file )
153
+ #print(archive_file)
154
+ #print(hash_file)
155
+ #print(archive_url)
156
+ #print(hash_url)
151
157
152
158
license_confirmation = """
153
159
{1}
@@ -173,24 +179,24 @@ def download_icu(icuroot, version, yes):
173
179
# check the hash of the download zipfile/tarball
174
180
checksum = ""
175
181
with open (archive_path , "rb" ) as download :
176
- md5 = hashlib .md5 ()
177
- md5 .update (download .read ())
178
- checksum = md5 .hexdigest ()
179
-
180
- md5_path = os .path .join (icuroot , md5_file )
181
- md5_request = urllib2 .urlopen (md5_url )
182
- md5s = md5_request .read ().decode ("ascii" ).split ("\n " )
183
- relevant_md5 = filter (lambda line : line [len (line ) - len (archive_file ):] == archive_file , md5s )
184
- if len (relevant_md5 ) != 1 :
185
- raise Exception ("Could not find md5 hash for %s in %s" % archive_file , md5_url )
186
-
187
- correct_hash = relevant_md5 [0 ]
182
+ hashAlgorithm = hashlib .sha512 ()
183
+ hashAlgorithm .update (download .read ())
184
+ checksum = hashAlgorithm .hexdigest ()
185
+
186
+ hash_path = os .path .join (icuroot , hash_file )
187
+ hash_request = urllib2 .urlopen (hash_url )
188
+ allHashes = hash_request .read ().decode ("ascii" ).split ("\n " )
189
+ relevant_hash = filter (lambda line : line [len (line ) - len (archive_file ):] == archive_file , allHashes )
190
+ if len (relevant_hash ) != 1 :
191
+ raise Exception ("Could not find hash for {0} in {1}" . format ( archive_file , hash_url ) )
192
+
193
+ correct_hash = relevant_hash [0 ]
188
194
correct_hash = correct_hash .split (" " )[0 ]
189
195
if (correct_hash == checksum ):
190
- print ("MD5 checksums match, continuing" )
196
+ print ("Hash checksums match, continuing" )
191
197
return archive_path
192
198
else :
193
- raise Exception ("MD5 checksums do not match. Expected %s , got %s" % correct_hash , checksum )
199
+ raise Exception ("Hash checksums do not match. Expected {0} , got {1}" . format ( correct_hash , checksum ) )
194
200
195
201
def extract_icu (icuroot , archive_path ):
196
202
tempdir = os .path .normpath (os .path .join (icuroot , "temp" ))
0 commit comments