Skip to content

Commit f936156

Browse files
committed
Generate sha256 hashes when packaging
(cherry picked from commit 0b6db90)
1 parent 444f1ba commit f936156

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

scripts/build.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,12 @@ def build(version=None,
499499
logging.info("Time taken: {}s".format((end_time - start_time).total_seconds()))
500500
return True
501501

502-
def generate_md5_from_file(path):
503-
"""Generate MD5 signature based on the contents of the file at path.
502+
def generate_sha256_from_file(path):
503+
"""Generate SHA256 hash signature based on the contents of the file at path.
504504
"""
505-
m = hashlib.md5()
505+
m = hashlib.sha256()
506506
with open(path, 'rb') as f:
507-
for chunk in iter(lambda: f.read(4096), b""):
508-
m.update(chunk)
507+
m.update(f.read())
509508
return m.hexdigest()
510509

511510
def generate_sig_from_file(path):
@@ -790,9 +789,10 @@ def main(args):
790789
if not upload_packages(packages, bucket_name=args.bucket, overwrite=args.upload_overwrite):
791790
return 1
792791
logging.info("Packages created:")
793-
for p in packages:
794-
logging.info("{} (MD5={})".format(p.split('/')[-1:][0],
795-
generate_md5_from_file(p)))
792+
for filename in packages:
793+
logging.info("%s (SHA256=%s)",
794+
os.path.basename(filename),
795+
generate_sha256_from_file(filename))
796796
if orig_branch != get_current_branch():
797797
logging.info("Moving back to original git branch: {}".format(args.branch))
798798
run("git checkout {}".format(orig_branch))

0 commit comments

Comments
 (0)