зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1338232 - add sha256 hash in checksums automation. r=rail a=release DONTBUILD
MozReview-Commit-ID: C0tahX0pG55 --HG-- extra : rebase_source : 7cdb4412766021c0455ddd1379e7a70a5f0aeffd
This commit is contained in:
Родитель
eaee1dbb37
Коммит
8fd92992be
|
@ -2241,9 +2241,9 @@ class BaseScript(ScriptMixin, LogMixin, object):
|
|||
self.log("%s doesn't exist after copy!" % dest, level=error_level)
|
||||
return None
|
||||
|
||||
def file_sha512sum(self, file_path):
|
||||
def get_hash_for_file(self, file_path, hash_type="sha512"):
|
||||
bs = 65536
|
||||
hasher = hashlib.sha512()
|
||||
hasher = hashlib.new(hash_type)
|
||||
with open(file_path, 'rb') as fh:
|
||||
buf = fh.read(bs)
|
||||
while len(buf) > 0:
|
||||
|
|
|
@ -120,6 +120,8 @@ MIME_MAP = {
|
|||
'.xpi': 'application/x-xpinstall'
|
||||
}
|
||||
|
||||
HASH_FORMATS = ["sha512", "sha256"]
|
||||
|
||||
|
||||
class BeetMover(BaseScript, VirtualenvMixin, object):
|
||||
def __init__(self, aws_creds):
|
||||
|
@ -291,10 +293,13 @@ class BeetMover(BaseScript, VirtualenvMixin, object):
|
|||
prefix=self._get_template_vars()["s3_prefix"],
|
||||
f=self._strip_prefix(s3_key)
|
||||
)
|
||||
beet_contents = '{hash} sha512 {size} {name}\n'.format(
|
||||
hash=self.file_sha512sum(downloaded_file),
|
||||
size=os.path.getsize(downloaded_file),
|
||||
name=self._strip_prefix(s3_key))
|
||||
beet_contents = '\n'.join([
|
||||
'{hash} {fmt} {size} {name}'.format(
|
||||
hash=self.get_hash_for_file(downloaded_file, hash_type=algo),
|
||||
fmt=fmt,
|
||||
size=os.path.getsize(downloaded_file),
|
||||
name=self._strip_prefix(s3_key)) for fmt in HASH_FORMATS
|
||||
])
|
||||
self.write_to_file(beet_file_name, beet_contents)
|
||||
self.upload_bit(source=downloaded_file, s3_key=s3_key,
|
||||
bucket=bucket)
|
||||
|
|
|
@ -119,7 +119,7 @@ class ChecksumsGenerator(BaseScript, VirtualenvMixin, SigningMixin, VCSMixin, Bu
|
|||
# These defaults are set here rather in the config because default
|
||||
# lists cannot be completely overidden, only appended to.
|
||||
if not self.config.get("formats"):
|
||||
self.config["formats"] = ["sha512"]
|
||||
self.config["formats"] = ["sha512", "sha256"]
|
||||
|
||||
if not self.config.get("includes"):
|
||||
self.config["includes"] = [
|
||||
|
|
Загрузка…
Ссылка в новой задаче