mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add integrity hash for nightly builds
This commit is contained in:
parent
500a21c6c7
commit
f1e37e2dd2
1 changed files with 22 additions and 0 deletions
|
@ -12,6 +12,7 @@ from __future__ import absolute_import, print_function, unicode_literals
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import io
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import os.path as path
|
import os.path as path
|
||||||
|
@ -630,12 +631,33 @@ class PackageCommands(CommandBase):
|
||||||
extension = path.splitext(path.basename(package))[1]
|
extension = path.splitext(path.basename(package))[1]
|
||||||
latest_upload_key = '{}/servo-latest{}'.format(nightly_dir, extension)
|
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)
|
||||||
|
package_hash_upload_key = '{}/{}.sha256'.format(nightly_dir, filename)
|
||||||
|
latest_hash_upload_key = '{}/servo-latest{}.sha256'.format(nightly_dir, extension)
|
||||||
|
|
||||||
s3.upload_file(package, BUCKET, package_upload_key)
|
s3.upload_file(package, BUCKET, package_upload_key)
|
||||||
|
s3.upload_fileobj(package_hash_fileobj, BUCKET, package_hash_upload_key)
|
||||||
|
|
||||||
copy_source = {
|
copy_source = {
|
||||||
'Bucket': BUCKET,
|
'Bucket': BUCKET,
|
||||||
'Key': package_upload_key,
|
'Key': package_upload_key,
|
||||||
}
|
}
|
||||||
|
copy_source_hash = {
|
||||||
|
'Bucket': BUCKET,
|
||||||
|
'Key': package_hash_upload_key,
|
||||||
|
}
|
||||||
s3.copy(copy_source, BUCKET, latest_upload_key)
|
s3.copy(copy_source, BUCKET, latest_upload_key)
|
||||||
|
s3.copy(copy_source_hash, BUCKET, latest_hash_upload_key)
|
||||||
|
|
||||||
def update_maven(directory):
|
def update_maven(directory):
|
||||||
(aws_access_key, aws_secret_access_key) = get_s3_secret()
|
(aws_access_key, aws_secret_access_key) = get_s3_secret()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue