releasetools: Prefer the avbtool specified in target_files.
This allows a consistent logic in using the avbtool which could be board-specific. Test: `atest releasetools_test` Test: Run sign_target_files_apks.py on a target_files.zip. Change-Id: I8cd93b8e71146985734f85c31f4662f5e2e9534c
This commit is contained in:
@@ -19,6 +19,9 @@ Signs a standalone APEX file.
|
||||
|
||||
Usage: sign_apex [flags] input_apex_file output_apex_file
|
||||
|
||||
--avbtool <avbtool>
|
||||
Optional flag that specifies the AVB tool to use. Defaults to `avbtool`.
|
||||
|
||||
--container_key <key>
|
||||
Mandatory flag that specifies the container signing key.
|
||||
|
||||
@@ -40,12 +43,14 @@ import common
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def SignApexFile(apex_file, payload_key, container_key, signing_args=None):
|
||||
def SignApexFile(avbtool, apex_file, payload_key, container_key,
|
||||
signing_args=None):
|
||||
"""Signs the given apex file."""
|
||||
with open(apex_file, 'rb') as input_fp:
|
||||
apex_data = input_fp.read()
|
||||
|
||||
return apex_utils.SignApex(
|
||||
avbtool,
|
||||
apex_data,
|
||||
payload_key=payload_key,
|
||||
container_key=container_key,
|
||||
@@ -59,7 +64,9 @@ def main(argv):
|
||||
options = {}
|
||||
|
||||
def option_handler(o, a):
|
||||
if o == '--container_key':
|
||||
if o == '--avbtool':
|
||||
options['avbtool'] = a
|
||||
elif o == '--container_key':
|
||||
# Strip the suffix if any, as common.SignFile expects no suffix.
|
||||
DEFAULT_CONTAINER_KEY_SUFFIX = '.x509.pem'
|
||||
if a.endswith(DEFAULT_CONTAINER_KEY_SUFFIX):
|
||||
@@ -77,6 +84,7 @@ def main(argv):
|
||||
argv, __doc__,
|
||||
extra_opts='',
|
||||
extra_long_opts=[
|
||||
'avbtool=',
|
||||
'container_key=',
|
||||
'payload_extra_args=',
|
||||
'payload_key=',
|
||||
@@ -91,6 +99,7 @@ def main(argv):
|
||||
common.InitLogging()
|
||||
|
||||
signed_apex = SignApexFile(
|
||||
options.get('avbtool', 'avbtool'),
|
||||
args[0],
|
||||
options['payload_key'],
|
||||
options['container_key'],
|
||||
|
Reference in New Issue
Block a user