Move signing related options to a shared place
Move OTA signing flags to payload_signer.py so that we can re-use these flags in multiple binaries. Test: th Bug: 293313353 Change-Id: I44f9910cee37c449397e174a5784f747ec9fb0d6
This commit is contained in:
@@ -265,7 +265,6 @@ import multiprocessing
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import shlex
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@@ -274,6 +273,7 @@ import zipfile
|
|||||||
import care_map_pb2
|
import care_map_pb2
|
||||||
import common
|
import common
|
||||||
import ota_utils
|
import ota_utils
|
||||||
|
import payload_signer
|
||||||
from ota_utils import (VABC_COMPRESSION_PARAM_SUPPORT, FinalizeMetadata, GetPackageMetadata,
|
from ota_utils import (VABC_COMPRESSION_PARAM_SUPPORT, FinalizeMetadata, GetPackageMetadata,
|
||||||
PayloadGenerator, SECURITY_PATCH_LEVEL_PROP_NAME, ExtractTargetFiles, CopyTargetFilesDir)
|
PayloadGenerator, SECURITY_PATCH_LEVEL_PROP_NAME, ExtractTargetFiles, CopyTargetFilesDir)
|
||||||
from common import DoesInputFileContain, IsSparseImage
|
from common import DoesInputFileContain, IsSparseImage
|
||||||
@@ -308,9 +308,6 @@ OPTIONS.full_bootloader = False
|
|||||||
OPTIONS.cache_size = None
|
OPTIONS.cache_size = None
|
||||||
OPTIONS.stash_threshold = 0.8
|
OPTIONS.stash_threshold = 0.8
|
||||||
OPTIONS.log_diff = None
|
OPTIONS.log_diff = None
|
||||||
OPTIONS.payload_signer = None
|
|
||||||
OPTIONS.payload_signer_args = []
|
|
||||||
OPTIONS.payload_signer_maximum_signature_size = None
|
|
||||||
OPTIONS.extracted_input = None
|
OPTIONS.extracted_input = None
|
||||||
OPTIONS.skip_postinstall = False
|
OPTIONS.skip_postinstall = False
|
||||||
OPTIONS.skip_compatibility_check = False
|
OPTIONS.skip_compatibility_check = False
|
||||||
@@ -1125,9 +1122,7 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None):
|
|||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
||||||
def option_handler(o, a):
|
def option_handler(o, a):
|
||||||
if o in ("-k", "--package_key"):
|
if o in ("-i", "--incremental_from"):
|
||||||
OPTIONS.package_key = a
|
|
||||||
elif o in ("-i", "--incremental_from"):
|
|
||||||
OPTIONS.incremental_source = a
|
OPTIONS.incremental_source = a
|
||||||
elif o == "--full_radio":
|
elif o == "--full_radio":
|
||||||
OPTIONS.full_radio = True
|
OPTIONS.full_radio = True
|
||||||
@@ -1172,17 +1167,6 @@ def main(argv):
|
|||||||
"a float" % (a, o))
|
"a float" % (a, o))
|
||||||
elif o == "--log_diff":
|
elif o == "--log_diff":
|
||||||
OPTIONS.log_diff = a
|
OPTIONS.log_diff = a
|
||||||
elif o == "--payload_signer":
|
|
||||||
OPTIONS.payload_signer = a
|
|
||||||
elif o == "--payload_signer_args":
|
|
||||||
OPTIONS.payload_signer_args = shlex.split(a)
|
|
||||||
elif o == "--payload_signer_maximum_signature_size":
|
|
||||||
OPTIONS.payload_signer_maximum_signature_size = a
|
|
||||||
elif o == "--payload_signer_key_size":
|
|
||||||
# TODO(Xunchang) remove this option after cleaning up the callers.
|
|
||||||
logger.warning("The option '--payload_signer_key_size' is deprecated."
|
|
||||||
" Use '--payload_signer_maximum_signature_size' instead.")
|
|
||||||
OPTIONS.payload_signer_maximum_signature_size = a
|
|
||||||
elif o == "--extracted_input_target_files":
|
elif o == "--extracted_input_target_files":
|
||||||
OPTIONS.extracted_input = a
|
OPTIONS.extracted_input = a
|
||||||
elif o == "--skip_postinstall":
|
elif o == "--skip_postinstall":
|
||||||
@@ -1258,7 +1242,6 @@ def main(argv):
|
|||||||
args = common.ParseOptions(argv, __doc__,
|
args = common.ParseOptions(argv, __doc__,
|
||||||
extra_opts="b:k:i:d:e:t:2o:",
|
extra_opts="b:k:i:d:e:t:2o:",
|
||||||
extra_long_opts=[
|
extra_long_opts=[
|
||||||
"package_key=",
|
|
||||||
"incremental_from=",
|
"incremental_from=",
|
||||||
"full_radio",
|
"full_radio",
|
||||||
"full_bootloader",
|
"full_bootloader",
|
||||||
@@ -1277,10 +1260,6 @@ def main(argv):
|
|||||||
"verify",
|
"verify",
|
||||||
"stash_threshold=",
|
"stash_threshold=",
|
||||||
"log_diff=",
|
"log_diff=",
|
||||||
"payload_signer=",
|
|
||||||
"payload_signer_args=",
|
|
||||||
"payload_signer_maximum_signature_size=",
|
|
||||||
"payload_signer_key_size=",
|
|
||||||
"extracted_input_target_files=",
|
"extracted_input_target_files=",
|
||||||
"skip_postinstall",
|
"skip_postinstall",
|
||||||
"retrofit_dynamic_partitions",
|
"retrofit_dynamic_partitions",
|
||||||
@@ -1304,7 +1283,7 @@ def main(argv):
|
|||||||
"vabc_compression_param=",
|
"vabc_compression_param=",
|
||||||
"security_patch_level=",
|
"security_patch_level=",
|
||||||
"max_threads=",
|
"max_threads=",
|
||||||
], extra_option_handler=option_handler)
|
], extra_option_handler=[option_handler, payload_signer.signer_options])
|
||||||
common.InitLogging()
|
common.InitLogging()
|
||||||
|
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
|
@@ -37,7 +37,6 @@ OPTIONS.force_non_ab = False
|
|||||||
OPTIONS.wipe_user_data = False
|
OPTIONS.wipe_user_data = False
|
||||||
OPTIONS.downgrade = False
|
OPTIONS.downgrade = False
|
||||||
OPTIONS.key_passwords = {}
|
OPTIONS.key_passwords = {}
|
||||||
OPTIONS.package_key = None
|
|
||||||
OPTIONS.incremental_source = None
|
OPTIONS.incremental_source = None
|
||||||
OPTIONS.retrofit_dynamic_partitions = False
|
OPTIONS.retrofit_dynamic_partitions = False
|
||||||
OPTIONS.output_metadata_path = None
|
OPTIONS.output_metadata_path = None
|
||||||
|
@@ -16,10 +16,51 @@
|
|||||||
|
|
||||||
import common
|
import common
|
||||||
import logging
|
import logging
|
||||||
from common import OPTIONS
|
import shlex
|
||||||
|
from common import OPTIONS, OptionHandler
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
OPTIONS.payload_signer = None
|
||||||
|
OPTIONS.payload_signer_args = []
|
||||||
|
OPTIONS.payload_signer_maximum_signature_size = None
|
||||||
|
OPTIONS.package_key = None
|
||||||
|
|
||||||
|
|
||||||
|
class SignerOptions(OptionHandler):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def ParseOptions(o, a):
|
||||||
|
if o in ("-k", "--package_key"):
|
||||||
|
OPTIONS.package_key = a
|
||||||
|
elif o == "--payload_signer":
|
||||||
|
OPTIONS.payload_signer = a
|
||||||
|
elif o == "--payload_signer_args":
|
||||||
|
OPTIONS.payload_signer_args = shlex.split(a)
|
||||||
|
elif o == "--payload_signer_maximum_signature_size":
|
||||||
|
OPTIONS.payload_signer_maximum_signature_size = a
|
||||||
|
elif o == "--payload_signer_key_size":
|
||||||
|
# TODO(xunchang) remove this option after cleaning up the callers.
|
||||||
|
logger.warning("The option '--payload_signer_key_size' is deprecated."
|
||||||
|
" Use '--payload_signer_maximum_signature_size' instead.")
|
||||||
|
OPTIONS.payload_signer_maximum_signature_size = a
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(
|
||||||
|
["payload_signer=",
|
||||||
|
"package_key=",
|
||||||
|
"payload_signer_args=",
|
||||||
|
"payload_signer_maximum_signature_size=",
|
||||||
|
"payload_signer_key_size="],
|
||||||
|
SignerOptions.ParseOptions
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
signer_options = SignerOptions()
|
||||||
|
|
||||||
|
|
||||||
class PayloadSigner(object):
|
class PayloadSigner(object):
|
||||||
"""A class that wraps the payload signing works.
|
"""A class that wraps the payload signing works.
|
||||||
|
Reference in New Issue
Block a user