aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-05-13 21:25:36 -0400
committerGitHub <noreply@github.com>2020-05-13 21:25:36 -0400
commit6c506ba2608c082a6c3c908b5e72f1cb5ea8a082 (patch)
treefaf7ce699808672943676a85d1776ae13d60c3d4
parent329f081e6a8836f910d4f93bb1c01ba3e93e036a (diff)
parent6faccf6c3c56e57a0a7c7b2865229ce7a4812d1d (diff)
downloadservo-6c506ba2608c082a6c3c908b5e72f1cb5ea8a082.tar.gz
servo-6c506ba2608c082a6c3c908b5e72f1cb5ea8a082.zip
Auto merge of #26510 - camelid:checksum, r=jdm
Add integrity hash for nightly builds <!-- Please describe your changes on the following line: --> Compute a SHA-256 integrity hash for nightly builds on the download.servo.org page. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors (it does, but unrelated to the change) - [X] `./mach test-tidy` does not report any errors - [X] These changes fix servo/download.servo.org#14 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because they're in the infrastructure <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
-rw-r--r--python/servo/package_commands.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py
index 5f27a6a6391..ca245c81e2e 100644
--- a/python/servo/package_commands.py
+++ b/python/servo/package_commands.py
@@ -12,6 +12,7 @@ from __future__ import absolute_import, print_function, unicode_literals
from datetime import datetime
import base64
import hashlib
+import io
import json
import os
import os.path as path
@@ -630,12 +631,27 @@ class PackageCommands(CommandBase):
extension = path.splitext(path.basename(package))[1]
latest_upload_key = '{}/servo-latest{}'.format(nightly_dir, extension)
+ # Compute the hash
+ SHA_BUF_SIZE = 1048576 # read in 1 MiB chunks
+ sha256_digest = hashlib.sha256()
+ with open(package, 'rb') as package_file:
+ while True:
+ data = package_file.read(SHA_BUF_SIZE)
+ if not data:
+ break
+ sha256_digest.update(data)
+ package_hash = sha256_digest.hexdigest()
+ package_hash_fileobj = io.BytesIO(package_hash)
+ latest_hash_upload_key = '{}/servo-latest{}.sha256'.format(nightly_dir, extension)
+
s3.upload_file(package, BUCKET, package_upload_key)
+
copy_source = {
'Bucket': BUCKET,
'Key': package_upload_key,
}
s3.copy(copy_source, BUCKET, latest_upload_key)
+ s3.upload_fileobj(package_hash_fileobj, BUCKET, latest_hash_upload_key)
def update_maven(directory):
(aws_access_key, aws_secret_access_key) = get_s3_secret()