Merge "Adds optional --rebuild_recovery flag to merge_target_files."

am: fab3f29e5a

Change-Id: I834d2e7ed672dce20960dd5c97b57fe3dbdc3bb6
This commit is contained in:
Daniel Norman 2019-03-19 14:52:17 -07:00 committed by android-build-merger
commit 62f2c36d9a
2 changed files with 25 additions and 11 deletions

View File

@ -146,11 +146,12 @@ def AddSystem(output_zip, recovery_img=None, boot_img=None):
ofile.write(data) ofile.write(data)
ofile.close() ofile.close()
arc_name = "SYSTEM/" + fn if output_zip:
if arc_name in output_zip.namelist(): arc_name = "SYSTEM/" + fn
OPTIONS.replace_updated_files_list.append(arc_name) if arc_name in output_zip.namelist():
else: OPTIONS.replace_updated_files_list.append(arc_name)
common.ZipWrite(output_zip, ofile.name, arc_name) else:
common.ZipWrite(output_zip, ofile.name, arc_name)
if OPTIONS.rebuild_recovery: if OPTIONS.rebuild_recovery:
logger.info("Building new recovery patch") logger.info("Building new recovery patch")

View File

@ -43,6 +43,10 @@ Usage: merge_target_files.py [args]
--output-target-files output-target-files-package --output-target-files output-target-files-package
The output merged target files package. Also a zip archive. The output merged target files package. Also a zip archive.
--rebuild_recovery
Rebuild the recovery patch used by non-A/B devices and write it to the
system image.
""" """
from __future__ import print_function from __future__ import print_function
@ -65,6 +69,7 @@ OPTIONS.system_misc_info_keys = None
OPTIONS.other_target_files = None OPTIONS.other_target_files = None
OPTIONS.other_item_list = None OPTIONS.other_item_list = None
OPTIONS.output_target_files = None OPTIONS.output_target_files = None
OPTIONS.rebuild_recovery = False
OPTIONS.keep_tmp = False OPTIONS.keep_tmp = False
# default_system_item_list is a list of items to extract from the partial # default_system_item_list is a list of items to extract from the partial
@ -433,7 +438,8 @@ def merge_target_files(
system_misc_info_keys, system_misc_info_keys,
other_target_files, other_target_files,
other_item_list, other_item_list,
output_target_files): output_target_files,
rebuild_recovery):
"""Merge two target files packages together. """Merge two target files packages together.
This function takes system and other target files packages as input, performs This function takes system and other target files packages as input, performs
@ -466,6 +472,9 @@ def merge_target_files(
output_target_files: The name of the output zip archive target files output_target_files: The name of the output zip archive target files
package created by merging system and other. package created by merging system and other.
rebuild_recovery: If true, rebuild the recovery patch used by non-A/B
devices and write it to the system image.
""" """
logger.info( logger.info(
@ -531,10 +540,10 @@ def merge_target_files(
# Regenerate IMAGES in the temporary directory. # Regenerate IMAGES in the temporary directory.
add_img_args = [ add_img_args = ['--verbose']
'--verbose', if rebuild_recovery:
output_target_files_temp_dir, add_img_args.append('--rebuild_recovery')
] add_img_args.append(output_target_files_temp_dir)
add_img_to_target_files.main(add_img_args) add_img_to_target_files.main(add_img_args)
@ -630,6 +639,8 @@ def main():
OPTIONS.other_item_list = a OPTIONS.other_item_list = a
elif o == '--output-target-files': elif o == '--output-target-files':
OPTIONS.output_target_files = a OPTIONS.output_target_files = a
elif o == '--rebuild_recovery':
OPTIONS.rebuild_recovery = True
elif o == '--keep_tmp': elif o == '--keep_tmp':
OPTIONS.keep_tmp = True OPTIONS.keep_tmp = True
else: else:
@ -645,6 +656,7 @@ def main():
'other-target-files=', 'other-target-files=',
'other-item-list=', 'other-item-list=',
'output-target-files=', 'output-target-files=',
'rebuild_recovery',
"keep_tmp", "keep_tmp",
], ],
extra_option_handler=option_handler) extra_option_handler=option_handler)
@ -679,7 +691,8 @@ def main():
system_misc_info_keys=system_misc_info_keys, system_misc_info_keys=system_misc_info_keys,
other_target_files=OPTIONS.other_target_files, other_target_files=OPTIONS.other_target_files,
other_item_list=other_item_list, other_item_list=other_item_list,
output_target_files=OPTIONS.output_target_files), output_target_files=OPTIONS.output_target_files,
rebuild_recovery=OPTIONS.rebuild_recovery),
OPTIONS.keep_tmp) OPTIONS.keep_tmp)