Merge "Allow merging target files without framework ab_partitions.txt" into main
This commit is contained in:
@@ -53,23 +53,31 @@ PARTITION_TAG_PATTERN = re.compile(r'partition="(.*?)"')
|
|||||||
MODULE_KEY_PATTERN = re.compile(r'name="(.+)\.(apex|apk)"')
|
MODULE_KEY_PATTERN = re.compile(r'name="(.+)\.(apex|apk)"')
|
||||||
|
|
||||||
|
|
||||||
def MergeUpdateEngineConfig(input_metadir1, input_metadir2, merged_meta_dir):
|
def MergeUpdateEngineConfig(framework_meta_dir, vendor_meta_dir,
|
||||||
UPDATE_ENGINE_CONFIG_NAME = "update_engine_config.txt"
|
merged_meta_dir):
|
||||||
config1_path = os.path.join(
|
"""Merges META/update_engine_config.txt.
|
||||||
input_metadir1, UPDATE_ENGINE_CONFIG_NAME)
|
|
||||||
config2_path = os.path.join(
|
The output is the configuration for maximum compatibility.
|
||||||
input_metadir2, UPDATE_ENGINE_CONFIG_NAME)
|
"""
|
||||||
config1 = ParseUpdateEngineConfig(config1_path)
|
_CONFIG_NAME = 'update_engine_config.txt'
|
||||||
config2 = ParseUpdateEngineConfig(config2_path)
|
framework_config_path = os.path.join(framework_meta_dir, _CONFIG_NAME)
|
||||||
# Copy older config to merged target files for maximum compatibility
|
vendor_config_path = os.path.join(vendor_meta_dir, _CONFIG_NAME)
|
||||||
# update_engine in system partition is from system side, but
|
merged_config_path = os.path.join(merged_meta_dir, _CONFIG_NAME)
|
||||||
# update_engine_sideload in recovery is from vendor side.
|
|
||||||
if config1 < config2:
|
if os.path.exists(framework_config_path):
|
||||||
shutil.copy(config1_path, os.path.join(
|
framework_config = ParseUpdateEngineConfig(framework_config_path)
|
||||||
merged_meta_dir, UPDATE_ENGINE_CONFIG_NAME))
|
vendor_config = ParseUpdateEngineConfig(vendor_config_path)
|
||||||
|
# Copy older config to merged target files for maximum compatibility
|
||||||
|
# update_engine in system partition is from system side, but
|
||||||
|
# update_engine_sideload in recovery is from vendor side.
|
||||||
|
if framework_config < vendor_config:
|
||||||
|
shutil.copy(framework_config_path, merged_config_path)
|
||||||
|
else:
|
||||||
|
shutil.copy(vendor_config_path, merged_config_path)
|
||||||
else:
|
else:
|
||||||
shutil.copy(config2_path, os.path.join(
|
if not OPTIONS.allow_partial_ab:
|
||||||
merged_meta_dir, UPDATE_ENGINE_CONFIG_NAME))
|
raise FileNotFoundError(framework_config_path)
|
||||||
|
shutil.copy(vendor_config_path, merged_config_path)
|
||||||
|
|
||||||
|
|
||||||
def MergeMetaFiles(temp_dir, merged_dir, framework_partitions):
|
def MergeMetaFiles(temp_dir, merged_dir, framework_partitions):
|
||||||
@@ -125,8 +133,7 @@ def MergeMetaFiles(temp_dir, merged_dir, framework_partitions):
|
|||||||
|
|
||||||
if OPTIONS.merged_misc_info.get('ab_update') == 'true':
|
if OPTIONS.merged_misc_info.get('ab_update') == 'true':
|
||||||
MergeUpdateEngineConfig(
|
MergeUpdateEngineConfig(
|
||||||
framework_meta_dir,
|
framework_meta_dir, vendor_meta_dir, merged_meta_dir)
|
||||||
vendor_meta_dir, merged_meta_dir)
|
|
||||||
|
|
||||||
# Write the now-finalized OPTIONS.merged_misc_info.
|
# Write the now-finalized OPTIONS.merged_misc_info.
|
||||||
merge_utils.WriteSortedData(
|
merge_utils.WriteSortedData(
|
||||||
@@ -140,16 +147,24 @@ def MergeAbPartitions(framework_meta_dir, vendor_meta_dir, merged_meta_dir,
|
|||||||
|
|
||||||
The output contains the union of the partition names.
|
The output contains the union of the partition names.
|
||||||
"""
|
"""
|
||||||
with open(os.path.join(framework_meta_dir, 'ab_partitions.txt')) as f:
|
framework_ab_partitions = []
|
||||||
# Filter out some partitions here to support the case that the
|
framework_ab_config = os.path.join(framework_meta_dir, 'ab_partitions.txt')
|
||||||
# ab_partitions.txt of framework-target-files has non-framework partitions.
|
if os.path.exists(framework_ab_config):
|
||||||
# This case happens when we use a complete merged target files package as
|
with open(framework_ab_config) as f:
|
||||||
# the framework-target-files.
|
# Filter out some partitions here to support the case that the
|
||||||
framework_ab_partitions = [
|
# ab_partitions.txt of framework-target-files has non-framework
|
||||||
partition
|
# partitions. This case happens when we use a complete merged target
|
||||||
for partition in f.read().splitlines()
|
# files package as the framework-target-files.
|
||||||
if partition in framework_partitions
|
framework_ab_partitions.extend([
|
||||||
]
|
partition
|
||||||
|
for partition in f.read().splitlines()
|
||||||
|
if partition in framework_partitions
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
if not OPTIONS.allow_partial_ab:
|
||||||
|
raise FileNotFoundError(framework_ab_config)
|
||||||
|
logger.info('Use partial AB because framework ab_partitions.txt does not '
|
||||||
|
'exist.')
|
||||||
|
|
||||||
with open(os.path.join(vendor_meta_dir, 'ab_partitions.txt')) as f:
|
with open(os.path.join(vendor_meta_dir, 'ab_partitions.txt')) as f:
|
||||||
vendor_ab_partitions = f.read().splitlines()
|
vendor_ab_partitions = f.read().splitlines()
|
||||||
|
@@ -98,6 +98,10 @@ Usage: merge_target_files [args]
|
|||||||
If provided, resolve the conflict AVB rollback index location when
|
If provided, resolve the conflict AVB rollback index location when
|
||||||
necessary.
|
necessary.
|
||||||
|
|
||||||
|
--allow-partial-ab
|
||||||
|
If provided, allow merging non-AB framework target files with AB vendor
|
||||||
|
target files, which means that only the vendor has AB partitions.
|
||||||
|
|
||||||
The following only apply when using the VSDK to perform dexopt on vendor apps:
|
The following only apply when using the VSDK to perform dexopt on vendor apps:
|
||||||
|
|
||||||
--framework-dexpreopt-config
|
--framework-dexpreopt-config
|
||||||
@@ -154,6 +158,7 @@ OPTIONS.vendor_otatools = None
|
|||||||
OPTIONS.rebuild_sepolicy = False
|
OPTIONS.rebuild_sepolicy = False
|
||||||
OPTIONS.keep_tmp = False
|
OPTIONS.keep_tmp = False
|
||||||
OPTIONS.avb_resolve_rollback_index_location_conflict = False
|
OPTIONS.avb_resolve_rollback_index_location_conflict = False
|
||||||
|
OPTIONS.allow_partial_ab = False
|
||||||
OPTIONS.framework_dexpreopt_config = None
|
OPTIONS.framework_dexpreopt_config = None
|
||||||
OPTIONS.framework_dexpreopt_tools = None
|
OPTIONS.framework_dexpreopt_tools = None
|
||||||
OPTIONS.vendor_dexpreopt_config = None
|
OPTIONS.vendor_dexpreopt_config = None
|
||||||
@@ -576,6 +581,8 @@ def main():
|
|||||||
OPTIONS.keep_tmp = True
|
OPTIONS.keep_tmp = True
|
||||||
elif o == '--avb-resolve-rollback-index-location-conflict':
|
elif o == '--avb-resolve-rollback-index-location-conflict':
|
||||||
OPTIONS.avb_resolve_rollback_index_location_conflict = True
|
OPTIONS.avb_resolve_rollback_index_location_conflict = True
|
||||||
|
elif o == '--allow-partial-ab':
|
||||||
|
OPTIONS.allow_partial_ab = True
|
||||||
elif o == '--framework-dexpreopt-config':
|
elif o == '--framework-dexpreopt-config':
|
||||||
OPTIONS.framework_dexpreopt_config = a
|
OPTIONS.framework_dexpreopt_config = a
|
||||||
elif o == '--framework-dexpreopt-tools':
|
elif o == '--framework-dexpreopt-tools':
|
||||||
@@ -617,6 +624,7 @@ def main():
|
|||||||
'rebuild-sepolicy',
|
'rebuild-sepolicy',
|
||||||
'keep-tmp',
|
'keep-tmp',
|
||||||
'avb-resolve-rollback-index-location-conflict',
|
'avb-resolve-rollback-index-location-conflict',
|
||||||
|
'allow-partial-ab',
|
||||||
],
|
],
|
||||||
extra_option_handler=option_handler)
|
extra_option_handler=option_handler)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user