Reduce OTA tools's dependency on brillo_update_payload

brillo_update_payload is thin bash wrapper for delta_generator, and
OTA tools are wrappers around brillo_update_payload. This is
inconveinent, as adding a new flag requires changing 3 places. Since
brillo_update_payload is really thin, skip it and invoke delta_generator
directly.

Test: th
Bug: 293313353
Change-Id: I2fd5af95c571ea45aea62f9eec475f0f4e864953
This commit is contained in:
Kelvin Zhang 2023-08-25 13:41:42 -07:00
parent 8c3bb5b993
commit f6fe0a9c9c
2 changed files with 12 additions and 36 deletions

View file

@ -897,30 +897,7 @@ class PayloadGenerator(object):
"""
assert isinstance(payload_signer, PayloadSigner)
# 1. Generate hashes of the payload and metadata files.
payload_sig_file = common.MakeTempFile(prefix="sig-", suffix=".bin")
metadata_sig_file = common.MakeTempFile(prefix="sig-", suffix=".bin")
cmd = ["brillo_update_payload", "hash",
"--unsigned_payload", self.payload_file,
"--signature_size", str(payload_signer.maximum_signature_size),
"--metadata_hash_file", metadata_sig_file,
"--payload_hash_file", payload_sig_file]
self._Run(cmd)
# 2. Sign the hashes.
signed_payload_sig_file = payload_signer.SignHashFile(payload_sig_file)
signed_metadata_sig_file = payload_signer.SignHashFile(metadata_sig_file)
# 3. Insert the signatures back into the payload file.
signed_payload_file = common.MakeTempFile(prefix="signed-payload-",
suffix=".bin")
cmd = ["brillo_update_payload", "sign",
"--unsigned_payload", self.payload_file,
"--payload", signed_payload_file,
"--signature_size", str(payload_signer.maximum_signature_size),
"--metadata_signature_file", signed_metadata_sig_file,
"--payload_signature_file", signed_payload_sig_file]
self._Run(cmd)
signed_payload_file = payload_signer.SignPayload(self.payload_file)
self.payload_file = signed_payload_file

View file

@ -95,11 +95,11 @@ class PayloadSigner(object):
# 1. Generate hashes of the payload and metadata files.
payload_sig_file = common.MakeTempFile(prefix="sig-", suffix=".bin")
metadata_sig_file = common.MakeTempFile(prefix="sig-", suffix=".bin")
cmd = ["brillo_update_payload", "hash",
"--unsigned_payload", unsigned_payload,
"--signature_size", str(self.maximum_signature_size),
"--metadata_hash_file", metadata_sig_file,
"--payload_hash_file", payload_sig_file]
cmd = ["delta_generator",
"--in_file=" + unsigned_payload,
"--signature_size=" + str(self.maximum_signature_size),
"--out_metadata_hash_file=" + metadata_sig_file,
"--out_hash_file=" + payload_sig_file]
self._Run(cmd)
# 2. Sign the hashes.
@ -109,16 +109,15 @@ class PayloadSigner(object):
# 3. Insert the signatures back into the payload file.
signed_payload_file = common.MakeTempFile(prefix="signed-payload-",
suffix=".bin")
cmd = ["brillo_update_payload", "sign",
"--unsigned_payload", unsigned_payload,
"--payload", signed_payload_file,
"--signature_size", str(self.maximum_signature_size),
"--metadata_signature_file", signed_metadata_sig_file,
"--payload_signature_file", signed_payload_sig_file]
cmd = ["delta_generator",
"--in_file=" + unsigned_payload,
"--out_file=" + signed_payload_file,
"--signature_size=" + str(self.maximum_signature_size),
"--metadata_signature_file=" + signed_metadata_sig_file,
"--payload_signature_file=" + signed_payload_sig_file]
self._Run(cmd)
return signed_payload_file
def SignHashFile(self, in_file):
"""Signs the given input file. Returns the output filename."""
out_file = common.MakeTempFile(prefix="signed-", suffix=".bin")