Merge "Runs python formatter and linter over merge_target_files."
This commit is contained in:
commit
8551d21cef
|
@ -13,11 +13,11 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations under
|
# License for the specific language governing permissions and limitations under
|
||||||
# the License.
|
# the License.
|
||||||
|
"""This script merges two partial target files packages.
|
||||||
|
|
||||||
"""
|
One package contains system files, and the other contains non-system files.
|
||||||
This script merges two partial target files packages (one of which contains
|
It produces a complete target files package that can be used to generate an
|
||||||
system files, and the other contains non-system files) together, producing a
|
OTA package.
|
||||||
complete target files package that can be used to generate an OTA package.
|
|
||||||
|
|
||||||
Usage: merge_target_files.py [args]
|
Usage: merge_target_files.py [args]
|
||||||
|
|
||||||
|
@ -126,8 +126,8 @@ system_extract_special_item_list = [
|
||||||
'META/*',
|
'META/*',
|
||||||
]
|
]
|
||||||
|
|
||||||
# default_system_misc_info_keys is a list of keys to obtain from the system instance of
|
# default_system_misc_info_keys is a list of keys to obtain from the system
|
||||||
# META/misc_info.txt. The remaining keys from the other instance.
|
# instance of META/misc_info.txt. The remaining keys from the other instance.
|
||||||
|
|
||||||
default_system_misc_info_keys = [
|
default_system_misc_info_keys = [
|
||||||
'avb_system_hashtree_enable',
|
'avb_system_hashtree_enable',
|
||||||
|
@ -185,10 +185,8 @@ def extract_items(target_files, target_files_temp_dir, extract_item_list):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
target_files: The target files zip archive from which to extract items.
|
target_files: The target files zip archive from which to extract items.
|
||||||
|
|
||||||
target_files_temp_dir: The temporary directory where the extracted items
|
target_files_temp_dir: The temporary directory where the extracted items
|
||||||
will land.
|
will land.
|
||||||
|
|
||||||
extract_item_list: A list of items to extract.
|
extract_item_list: A list of items to extract.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -198,9 +196,7 @@ def extract_items(target_files, target_files_temp_dir, extract_item_list):
|
||||||
# zip file. Otherwise, the extraction step will fail.
|
# zip file. Otherwise, the extraction step will fail.
|
||||||
|
|
||||||
with zipfile.ZipFile(
|
with zipfile.ZipFile(
|
||||||
target_files,
|
target_files, 'r', allowZip64=True) as target_files_zipfile:
|
||||||
'r',
|
|
||||||
allowZip64=True) as target_files_zipfile:
|
|
||||||
target_files_namelist = target_files_zipfile.namelist()
|
target_files_namelist = target_files_zipfile.namelist()
|
||||||
|
|
||||||
filtered_extract_item_list = []
|
filtered_extract_item_list = []
|
||||||
|
@ -214,18 +210,17 @@ def extract_items(target_files, target_files_temp_dir, extract_item_list):
|
||||||
# Extract from target_files into target_files_temp_dir the
|
# Extract from target_files into target_files_temp_dir the
|
||||||
# filtered_extract_item_list.
|
# filtered_extract_item_list.
|
||||||
|
|
||||||
common.UnzipToDir(
|
common.UnzipToDir(target_files, target_files_temp_dir,
|
||||||
target_files,
|
filtered_extract_item_list)
|
||||||
target_files_temp_dir,
|
|
||||||
filtered_extract_item_list)
|
|
||||||
|
|
||||||
|
|
||||||
def copy_items(from_dir, to_dir, patterns):
|
def copy_items(from_dir, to_dir, patterns):
|
||||||
"""Similar to extract_items() except uses an input dir instead of zip."""
|
"""Similar to extract_items() except uses an input dir instead of zip."""
|
||||||
file_paths = []
|
file_paths = []
|
||||||
for dirpath, _, filenames in os.walk(from_dir):
|
for dirpath, _, filenames in os.walk(from_dir):
|
||||||
file_paths.extend(os.path.relpath(path=os.path.join(dirpath, filename),
|
file_paths.extend(
|
||||||
start=from_dir) for filename in filenames)
|
os.path.relpath(path=os.path.join(dirpath, filename), start=from_dir)
|
||||||
|
for filename in filenames)
|
||||||
|
|
||||||
filtered_file_paths = set()
|
filtered_file_paths = set()
|
||||||
for pattern in patterns:
|
for pattern in patterns:
|
||||||
|
@ -250,26 +245,25 @@ def read_config_list(config_file_path):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
config_file_path: The path to the config file to open and read.
|
config_file_path: The path to the config file to open and read.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The list of strings in the config file.
|
||||||
"""
|
"""
|
||||||
with open(config_file_path) as config_file:
|
with open(config_file_path) as config_file:
|
||||||
return config_file.read().splitlines()
|
return config_file.read().splitlines()
|
||||||
|
|
||||||
|
|
||||||
def validate_config_lists(
|
def validate_config_lists(system_item_list, system_misc_info_keys,
|
||||||
system_item_list,
|
other_item_list):
|
||||||
system_misc_info_keys,
|
|
||||||
other_item_list):
|
|
||||||
"""Performs validations on the merge config lists.
|
"""Performs validations on the merge config lists.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
system_item_list: The list of items to extract from the partial
|
system_item_list: The list of items to extract from the partial system
|
||||||
system target files package as is.
|
target files package as is.
|
||||||
|
system_misc_info_keys: A list of keys to obtain from the system instance of
|
||||||
system_misc_info_keys: A list of keys to obtain from the system instance
|
META/misc_info.txt. The remaining keys from the other instance.
|
||||||
of META/misc_info.txt. The remaining keys from the other instance.
|
other_item_list: The list of items to extract from the partial other target
|
||||||
|
files package as is.
|
||||||
other_item_list: The list of items to extract from the partial
|
|
||||||
other target files package as is.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
False if a validation fails, otherwise true.
|
False if a validation fails, otherwise true.
|
||||||
|
@ -284,7 +278,7 @@ def validate_config_lists(
|
||||||
# by the default config lists.
|
# by the default config lists.
|
||||||
difference = default_combined_item_set.difference(combined_item_set)
|
difference = default_combined_item_set.difference(combined_item_set)
|
||||||
if difference:
|
if difference:
|
||||||
logger.error('Missing merge config items: %s' % list(difference))
|
logger.error('Missing merge config items: %s', list(difference))
|
||||||
logger.error('Please ensure missing items are in either the '
|
logger.error('Please ensure missing items are in either the '
|
||||||
'system-item-list or other-item-list files provided to '
|
'system-item-list or other-item-list files provided to '
|
||||||
'this script.')
|
'this script.')
|
||||||
|
@ -299,11 +293,10 @@ def validate_config_lists(
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def process_ab_partitions_txt(
|
def process_ab_partitions_txt(system_target_files_temp_dir,
|
||||||
system_target_files_temp_dir,
|
other_target_files_temp_dir,
|
||||||
other_target_files_temp_dir,
|
output_target_files_temp_dir):
|
||||||
output_target_files_temp_dir):
|
"""Perform special processing for META/ab_partitions.txt.
|
||||||
"""Perform special processing for META/ab_partitions.txt
|
|
||||||
|
|
||||||
This function merges the contents of the META/ab_partitions.txt files from
|
This function merges the contents of the META/ab_partitions.txt files from
|
||||||
the system directory and the other directory, placing the merged result in
|
the system directory and the other directory, placing the merged result in
|
||||||
|
@ -314,22 +307,20 @@ def process_ab_partitions_txt(
|
||||||
names.
|
names.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
system_target_files_temp_dir: The name of a directory containing the
|
system_target_files_temp_dir: The name of a directory containing the special
|
||||||
special items extracted from the system target files package.
|
items extracted from the system target files package.
|
||||||
|
other_target_files_temp_dir: The name of a directory containing the special
|
||||||
other_target_files_temp_dir: The name of a directory containing the
|
items extracted from the other target files package.
|
||||||
special items extracted from the other target files package.
|
output_target_files_temp_dir: The name of a directory that will be used to
|
||||||
|
create the output target files package after all the special cases are
|
||||||
output_target_files_temp_dir: The name of a directory that will be used
|
processed.
|
||||||
to create the output target files package after all the special cases
|
|
||||||
are processed.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
system_ab_partitions_txt = os.path.join(
|
system_ab_partitions_txt = os.path.join(system_target_files_temp_dir, 'META',
|
||||||
system_target_files_temp_dir, 'META', 'ab_partitions.txt')
|
'ab_partitions.txt')
|
||||||
|
|
||||||
other_ab_partitions_txt = os.path.join(
|
other_ab_partitions_txt = os.path.join(other_target_files_temp_dir, 'META',
|
||||||
other_target_files_temp_dir, 'META', 'ab_partitions.txt')
|
'ab_partitions.txt')
|
||||||
|
|
||||||
with open(system_ab_partitions_txt) as f:
|
with open(system_ab_partitions_txt) as f:
|
||||||
system_ab_partitions = f.read().splitlines()
|
system_ab_partitions = f.read().splitlines()
|
||||||
|
@ -339,8 +330,8 @@ def process_ab_partitions_txt(
|
||||||
|
|
||||||
output_ab_partitions = set(system_ab_partitions + other_ab_partitions)
|
output_ab_partitions = set(system_ab_partitions + other_ab_partitions)
|
||||||
|
|
||||||
output_ab_partitions_txt = os.path.join(
|
output_ab_partitions_txt = os.path.join(output_target_files_temp_dir, 'META',
|
||||||
output_target_files_temp_dir, 'META', 'ab_partitions.txt')
|
'ab_partitions.txt')
|
||||||
|
|
||||||
with open(output_ab_partitions_txt, 'w') as output:
|
with open(output_ab_partitions_txt, 'w') as output:
|
||||||
for partition in sorted(output_ab_partitions):
|
for partition in sorted(output_ab_partitions):
|
||||||
|
@ -348,42 +339,35 @@ def process_ab_partitions_txt(
|
||||||
|
|
||||||
|
|
||||||
def append_recovery_to_filesystem_config(output_target_files_temp_dir):
|
def append_recovery_to_filesystem_config(output_target_files_temp_dir):
|
||||||
"""Perform special processing for META/filesystem_config.txt
|
"""Perform special processing for META/filesystem_config.txt.
|
||||||
|
|
||||||
This function appends recovery information to META/filesystem_config.txt
|
This function appends recovery information to META/filesystem_config.txt
|
||||||
so that recovery patch regeneration will succeed.
|
so that recovery patch regeneration will succeed.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
output_target_files_temp_dir: The name of a directory that will be used
|
output_target_files_temp_dir: The name of a directory that will be used to
|
||||||
to create the output target files package after all the special cases
|
create the output target files package after all the special cases are
|
||||||
are processed. We find filesystem_config.txt here.
|
processed. We find filesystem_config.txt here.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filesystem_config_txt = os.path.join(
|
filesystem_config_txt = os.path.join(output_target_files_temp_dir, 'META',
|
||||||
output_target_files_temp_dir,
|
'filesystem_config.txt')
|
||||||
'META',
|
|
||||||
'filesystem_config.txt')
|
|
||||||
|
|
||||||
with open(filesystem_config_txt, 'a') as f:
|
with open(filesystem_config_txt, 'a') as f:
|
||||||
# TODO(bpeckham) this data is hard coded. It should be generated
|
# TODO(bpeckham) this data is hard coded. It should be generated
|
||||||
# programmatically.
|
# programmatically.
|
||||||
f.write(
|
f.write('system/bin/install-recovery.sh 0 0 750 '
|
||||||
'system/bin/install-recovery.sh 0 0 750 '
|
'selabel=u:object_r:install_recovery_exec:s0 capabilities=0x0\n')
|
||||||
'selabel=u:object_r:install_recovery_exec:s0 capabilities=0x0\n')
|
f.write('system/recovery-from-boot.p 0 0 644 '
|
||||||
f.write(
|
'selabel=u:object_r:system_file:s0 capabilities=0x0\n')
|
||||||
'system/recovery-from-boot.p 0 0 644 '
|
f.write('system/etc/recovery.img 0 0 440 '
|
||||||
'selabel=u:object_r:system_file:s0 capabilities=0x0\n')
|
'selabel=u:object_r:install_recovery_exec:s0 capabilities=0x0\n')
|
||||||
f.write(
|
|
||||||
'system/etc/recovery.img 0 0 440 '
|
|
||||||
'selabel=u:object_r:install_recovery_exec:s0 capabilities=0x0\n')
|
|
||||||
|
|
||||||
|
|
||||||
def process_misc_info_txt(
|
def process_misc_info_txt(system_target_files_temp_dir,
|
||||||
system_target_files_temp_dir,
|
other_target_files_temp_dir,
|
||||||
other_target_files_temp_dir,
|
output_target_files_temp_dir, system_misc_info_keys):
|
||||||
output_target_files_temp_dir,
|
"""Perform special processing for META/misc_info.txt.
|
||||||
system_misc_info_keys):
|
|
||||||
"""Perform special processing for META/misc_info.txt
|
|
||||||
|
|
||||||
This function merges the contents of the META/misc_info.txt files from the
|
This function merges the contents of the META/misc_info.txt files from the
|
||||||
system directory and the other directory, placing the merged result in the
|
system directory and the other directory, placing the merged result in the
|
||||||
|
@ -392,18 +376,15 @@ def process_misc_info_txt(
|
||||||
content.
|
content.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
system_target_files_temp_dir: The name of a directory containing the
|
system_target_files_temp_dir: The name of a directory containing the special
|
||||||
special items extracted from the system target files package.
|
items extracted from the system target files package.
|
||||||
|
other_target_files_temp_dir: The name of a directory containing the special
|
||||||
other_target_files_temp_dir: The name of a directory containing the
|
items extracted from the other target files package.
|
||||||
special items extracted from the other target files package.
|
output_target_files_temp_dir: The name of a directory that will be used to
|
||||||
|
create the output target files package after all the special cases are
|
||||||
output_target_files_temp_dir: The name of a directory that will be used
|
processed.
|
||||||
to create the output target files package after all the special cases
|
system_misc_info_keys: A list of keys to obtain from the system instance of
|
||||||
are processed.
|
META/misc_info.txt. The remaining keys from the other instance.
|
||||||
|
|
||||||
system_misc_info_keys: A list of keys to obtain from the system instance
|
|
||||||
of META/misc_info.txt. The remaining keys from the other instance.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def read_helper(d):
|
def read_helper(d):
|
||||||
|
@ -434,19 +415,18 @@ def process_misc_info_txt(
|
||||||
# Partition groups and group sizes are defined by the other (non-system)
|
# Partition groups and group sizes are defined by the other (non-system)
|
||||||
# misc info file because these values may vary for each board that uses
|
# misc info file because these values may vary for each board that uses
|
||||||
# a shared system image.
|
# a shared system image.
|
||||||
for partition_group in merged_info_dict['super_partition_groups'].split(' '):
|
for partition_group in merged_info_dict['super_partition_groups'].split(
|
||||||
|
' '):
|
||||||
if ('super_%s_group_size' % partition_group) not in merged_info_dict:
|
if ('super_%s_group_size' % partition_group) not in merged_info_dict:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'Other META/misc_info.txt does not contain required key '
|
'Other META/misc_info.txt does not contain required key '
|
||||||
'super_%s_group_size.' % partition_group)
|
'super_%s_group_size.' % partition_group)
|
||||||
key = 'super_%s_partition_list' % partition_group
|
key = 'super_%s_partition_list' % partition_group
|
||||||
merged_info_dict[key] = '%s %s' % (
|
merged_info_dict[key] = '%s %s' % (system_info_dict.get(
|
||||||
system_info_dict.get(key, ''),
|
key, ''), merged_info_dict.get(key, ''))
|
||||||
merged_info_dict.get(key, ''))
|
|
||||||
|
|
||||||
output_misc_info_txt = os.path.join(
|
output_misc_info_txt = os.path.join(output_target_files_temp_dir, 'META',
|
||||||
output_target_files_temp_dir,
|
'misc_info.txt')
|
||||||
'META', 'misc_info.txt')
|
|
||||||
|
|
||||||
sorted_keys = sorted(merged_info_dict.keys())
|
sorted_keys = sorted(merged_info_dict.keys())
|
||||||
|
|
||||||
|
@ -464,12 +444,11 @@ def process_file_contexts_bin(temp_dir, output_target_files_temp_dir):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
temp_dir: The name of a scratch directory that this function can use for
|
temp_dir: The name of a scratch directory that this function can use for
|
||||||
intermediate files generated during processing.
|
intermediate files generated during processing.
|
||||||
|
|
||||||
output_target_files_temp_dir: The name of the working directory that must
|
output_target_files_temp_dir: The name of the working directory that must
|
||||||
already contain plat_file_contexts and vendor_file_contexts (in the
|
already contain plat_file_contexts and vendor_file_contexts (in the
|
||||||
appropriate sub directories), and to which META/file_contexts.bin will be
|
appropriate sub directories), and to which META/file_contexts.bin will be
|
||||||
written.
|
written.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# To create a merged file_contexts.bin file, we use the system and vendor
|
# To create a merged file_contexts.bin file, we use the system and vendor
|
||||||
|
@ -490,9 +469,8 @@ def process_file_contexts_bin(temp_dir, output_target_files_temp_dir):
|
||||||
for partition in ['SYSTEM', 'VENDOR', 'PRODUCT', 'ODM']:
|
for partition in ['SYSTEM', 'VENDOR', 'PRODUCT', 'ODM']:
|
||||||
prefix = 'plat' if partition == 'SYSTEM' else partition.lower()
|
prefix = 'plat' if partition == 'SYSTEM' else partition.lower()
|
||||||
|
|
||||||
file_contexts = os.path.join(
|
file_contexts = os.path.join(output_target_files_temp_dir, partition, 'etc',
|
||||||
output_target_files_temp_dir,
|
'selinux', prefix + '_file_contexts')
|
||||||
partition, 'etc', 'selinux', prefix + '_file_contexts')
|
|
||||||
|
|
||||||
mandatory = partition in ['SYSTEM', 'VENDOR']
|
mandatory = partition in ['SYSTEM', 'VENDOR']
|
||||||
|
|
||||||
|
@ -518,27 +496,23 @@ def process_file_contexts_bin(temp_dir, output_target_files_temp_dir):
|
||||||
|
|
||||||
# Finally, the compile step creates the final META/file_contexts.bin.
|
# Finally, the compile step creates the final META/file_contexts.bin.
|
||||||
|
|
||||||
file_contexts_bin = os.path.join(
|
file_contexts_bin = os.path.join(output_target_files_temp_dir, 'META',
|
||||||
output_target_files_temp_dir,
|
'file_contexts.bin')
|
||||||
'META', 'file_contexts.bin')
|
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
'sefcontext_compile',
|
'sefcontext_compile',
|
||||||
'-o', file_contexts_bin,
|
'-o',
|
||||||
|
file_contexts_bin,
|
||||||
sorted_file_contexts_txt,
|
sorted_file_contexts_txt,
|
||||||
]
|
]
|
||||||
|
|
||||||
common.RunAndWait(command, verbose=True)
|
common.RunAndWait(command, verbose=True)
|
||||||
|
|
||||||
|
|
||||||
def process_special_cases(
|
def process_special_cases(temp_dir, system_target_files_temp_dir,
|
||||||
temp_dir,
|
other_target_files_temp_dir,
|
||||||
system_target_files_temp_dir,
|
output_target_files_temp_dir, system_misc_info_keys,
|
||||||
other_target_files_temp_dir,
|
rebuild_recovery):
|
||||||
output_target_files_temp_dir,
|
|
||||||
system_misc_info_keys,
|
|
||||||
rebuild_recovery
|
|
||||||
):
|
|
||||||
"""Perform special-case processing for certain target files items.
|
"""Perform special-case processing for certain target files items.
|
||||||
|
|
||||||
Certain files in the output target files package require special-case
|
Certain files in the output target files package require special-case
|
||||||
|
@ -546,23 +520,18 @@ def process_special_cases(
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
temp_dir: The name of a scratch directory that this function can use for
|
temp_dir: The name of a scratch directory that this function can use for
|
||||||
intermediate files generated during processing.
|
intermediate files generated during processing.
|
||||||
|
system_target_files_temp_dir: The name of a directory containing the special
|
||||||
system_target_files_temp_dir: The name of a directory containing the
|
items extracted from the system target files package.
|
||||||
special items extracted from the system target files package.
|
other_target_files_temp_dir: The name of a directory containing the special
|
||||||
|
items extracted from the other target files package.
|
||||||
other_target_files_temp_dir: The name of a directory containing the
|
output_target_files_temp_dir: The name of a directory that will be used to
|
||||||
special items extracted from the other target files package.
|
create the output target files package after all the special cases are
|
||||||
|
processed.
|
||||||
output_target_files_temp_dir: The name of a directory that will be used
|
system_misc_info_keys: A list of keys to obtain from the system instance of
|
||||||
to create the output target files package after all the special cases
|
META/misc_info.txt. The remaining keys from the other instance.
|
||||||
are processed.
|
|
||||||
|
|
||||||
system_misc_info_keys: A list of keys to obtain from the system instance
|
|
||||||
of META/misc_info.txt. The remaining keys from the other instance.
|
|
||||||
|
|
||||||
rebuild_recovery: If true, rebuild the recovery patch used by non-A/B
|
rebuild_recovery: If true, rebuild the recovery patch used by non-A/B
|
||||||
devices and write it to the system image.
|
devices and write it to the system image.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if 'ab_update' in system_misc_info_keys:
|
if 'ab_update' in system_misc_info_keys:
|
||||||
|
@ -586,19 +555,11 @@ def process_special_cases(
|
||||||
output_target_files_temp_dir=output_target_files_temp_dir)
|
output_target_files_temp_dir=output_target_files_temp_dir)
|
||||||
|
|
||||||
|
|
||||||
def merge_target_files(
|
def merge_target_files(temp_dir, system_target_files, system_item_list,
|
||||||
temp_dir,
|
system_misc_info_keys, other_target_files,
|
||||||
system_target_files,
|
other_item_list, output_target_files, output_dir,
|
||||||
system_item_list,
|
output_item_list, output_ota, output_super_empty,
|
||||||
system_misc_info_keys,
|
rebuild_recovery):
|
||||||
other_target_files,
|
|
||||||
other_item_list,
|
|
||||||
output_target_files,
|
|
||||||
output_dir,
|
|
||||||
output_item_list,
|
|
||||||
output_ota,
|
|
||||||
output_super_empty,
|
|
||||||
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
|
||||||
|
@ -607,45 +568,35 @@ def merge_target_files(
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
temp_dir: The name of a directory we use when we extract items from the
|
temp_dir: The name of a directory we use when we extract items from the
|
||||||
input target files packages, and also a scratch directory that we use for
|
input target files packages, and also a scratch directory that we use for
|
||||||
temporary files.
|
temporary files.
|
||||||
|
|
||||||
system_target_files: The name of the zip archive containing the system
|
system_target_files: The name of the zip archive containing the system
|
||||||
partial target files package.
|
partial target files package.
|
||||||
|
|
||||||
system_item_list: The list of items to extract from the partial system
|
system_item_list: The list of items to extract from the partial system
|
||||||
target files package as is, meaning these items will land in the output
|
target files package as is, meaning these items will land in the output
|
||||||
target files package exactly as they appear in the input partial system
|
target files package exactly as they appear in the input partial system
|
||||||
target files package.
|
target files package.
|
||||||
|
|
||||||
system_misc_info_keys: The list of keys to obtain from the system instance
|
system_misc_info_keys: The list of keys to obtain from the system instance
|
||||||
of META/misc_info.txt. The remaining keys from the other instance.
|
of META/misc_info.txt. The remaining keys from the other instance.
|
||||||
|
other_target_files: The name of the zip archive containing the other partial
|
||||||
other_target_files: The name of the zip archive containing the other
|
target files package.
|
||||||
partial target files package.
|
other_item_list: The list of items to extract from the partial other target
|
||||||
|
files package as is, meaning these items will land in the output target
|
||||||
other_item_list: The list of items to extract from the partial other
|
files package exactly as they appear in the input partial other target
|
||||||
target files package as is, meaning these items will land in the output
|
files package.
|
||||||
target files package exactly as they appear in the input partial other
|
output_target_files: The name of the output zip archive target files package
|
||||||
target files package.
|
created by merging system and other.
|
||||||
|
output_dir: The destination directory for saving merged files.
|
||||||
output_target_files: The name of the output zip archive target files
|
output_item_list: The list of items to copy into the output_dir.
|
||||||
package created by merging system and other.
|
|
||||||
|
|
||||||
output_ota: The name of the output zip archive ota package.
|
output_ota: The name of the output zip archive ota package.
|
||||||
|
|
||||||
output_super_empty: If provided, creates a super_empty.img file from the
|
output_super_empty: If provided, creates a super_empty.img file from the
|
||||||
merged target files package and saves it at this path.
|
merged target files package and saves it at this path.
|
||||||
|
|
||||||
rebuild_recovery: If true, rebuild the recovery patch used by non-A/B
|
rebuild_recovery: If true, rebuild the recovery patch used by non-A/B
|
||||||
devices and write it to the system image.
|
devices and write it to the system image.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.info(
|
logger.info('starting: merge system %s and other %s into output %s',
|
||||||
'starting: merge system %s and other %s into output %s',
|
system_target_files, other_target_files, output_target_files)
|
||||||
system_target_files,
|
|
||||||
other_target_files,
|
|
||||||
output_target_files)
|
|
||||||
|
|
||||||
# Create directory names that we'll use when we extract files from system,
|
# Create directory names that we'll use when we extract files from system,
|
||||||
# and other, and for zipping the final output.
|
# and other, and for zipping the final output.
|
||||||
|
@ -706,8 +657,9 @@ def merge_target_files(
|
||||||
# Create super_empty.img using the merged misc_info.txt.
|
# Create super_empty.img using the merged misc_info.txt.
|
||||||
|
|
||||||
if output_super_empty:
|
if output_super_empty:
|
||||||
misc_info_txt = os.path.join(output_target_files_temp_dir,
|
misc_info_txt = os.path.join(output_target_files_temp_dir, 'META',
|
||||||
'META', 'misc_info.txt')
|
'misc_info.txt')
|
||||||
|
|
||||||
def read_helper():
|
def read_helper():
|
||||||
with open(misc_info_txt) as f:
|
with open(misc_info_txt) as f:
|
||||||
return list(f.read().splitlines())
|
return list(f.read().splitlines())
|
||||||
|
@ -718,9 +670,9 @@ def merge_target_files(
|
||||||
'Building super_empty.img requires use_dynamic_partitions=true.')
|
'Building super_empty.img requires use_dynamic_partitions=true.')
|
||||||
|
|
||||||
build_super_image_args = [
|
build_super_image_args = [
|
||||||
'--verbose',
|
'--verbose',
|
||||||
misc_info_txt,
|
misc_info_txt,
|
||||||
output_super_empty,
|
output_super_empty,
|
||||||
]
|
]
|
||||||
build_super_image.main(build_super_image_args)
|
build_super_image.main(build_super_image_args)
|
||||||
|
|
||||||
|
@ -744,8 +696,8 @@ def merge_target_files(
|
||||||
|
|
||||||
output_zip = os.path.abspath(output_target_files)
|
output_zip = os.path.abspath(output_target_files)
|
||||||
output_target_files_list = os.path.join(temp_dir, 'output.list')
|
output_target_files_list = os.path.join(temp_dir, 'output.list')
|
||||||
output_target_files_meta_dir = os.path.join(
|
output_target_files_meta_dir = os.path.join(output_target_files_temp_dir,
|
||||||
output_target_files_temp_dir, 'META')
|
'META')
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
'find',
|
'find',
|
||||||
|
@ -754,13 +706,8 @@ def merge_target_files(
|
||||||
# TODO(bpeckham): sort this to be more like build.
|
# TODO(bpeckham): sort this to be more like build.
|
||||||
meta_content = common.RunAndCheckOutput(command, verbose=False)
|
meta_content = common.RunAndCheckOutput(command, verbose=False)
|
||||||
command = [
|
command = [
|
||||||
'find',
|
'find', output_target_files_temp_dir, '-path',
|
||||||
output_target_files_temp_dir,
|
output_target_files_meta_dir, '-prune', '-o', '-print'
|
||||||
'-path',
|
|
||||||
output_target_files_meta_dir,
|
|
||||||
'-prune',
|
|
||||||
'-o',
|
|
||||||
'-print'
|
|
||||||
]
|
]
|
||||||
# TODO(bpeckham): sort this to be more like build.
|
# TODO(bpeckham): sort this to be more like build.
|
||||||
other_content = common.RunAndCheckOutput(command, verbose=False)
|
other_content = common.RunAndCheckOutput(command, verbose=False)
|
||||||
|
@ -772,9 +719,12 @@ def merge_target_files(
|
||||||
command = [
|
command = [
|
||||||
'soong_zip',
|
'soong_zip',
|
||||||
'-d',
|
'-d',
|
||||||
'-o', output_zip,
|
'-o',
|
||||||
'-C', output_target_files_temp_dir,
|
output_zip,
|
||||||
'-l', output_target_files_list,
|
'-C',
|
||||||
|
output_target_files_temp_dir,
|
||||||
|
'-l',
|
||||||
|
output_target_files_list,
|
||||||
]
|
]
|
||||||
logger.info('creating %s', output_target_files)
|
logger.info('creating %s', output_target_files)
|
||||||
common.RunAndWait(command, verbose=True)
|
common.RunAndWait(command, verbose=True)
|
||||||
|
@ -796,9 +746,8 @@ def call_func_with_temp_dir(func, keep_tmp):
|
||||||
directory. It also cleans up the temporary directory.
|
directory. It also cleans up the temporary directory.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
func: The function to call. Should accept one parameter, the path to
|
func: The function to call. Should accept one parameter, the path to the
|
||||||
the temporary directory.
|
temporary directory.
|
||||||
|
|
||||||
keep_tmp: Keep the temporary directory after processing is complete.
|
keep_tmp: Keep the temporary directory after processing is complete.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -858,7 +807,8 @@ def main():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
args = common.ParseOptions(
|
args = common.ParseOptions(
|
||||||
sys.argv[1:], __doc__,
|
sys.argv[1:],
|
||||||
|
__doc__,
|
||||||
extra_long_opts=[
|
extra_long_opts=[
|
||||||
'system-target-files=',
|
'system-target-files=',
|
||||||
'system-item-list=',
|
'system-item-list=',
|
||||||
|
@ -875,13 +825,10 @@ def main():
|
||||||
],
|
],
|
||||||
extra_option_handler=option_handler)
|
extra_option_handler=option_handler)
|
||||||
|
|
||||||
if (len(args) != 0 or
|
if (args or OPTIONS.system_target_files is None or
|
||||||
OPTIONS.system_target_files is None or
|
OPTIONS.other_target_files is None or
|
||||||
OPTIONS.other_target_files is None or (
|
(OPTIONS.output_target_files is None and OPTIONS.output_dir is None) or
|
||||||
OPTIONS.output_target_files is None and
|
(OPTIONS.output_dir is not None and OPTIONS.output_item_list is None)):
|
||||||
OPTIONS.output_dir is None) or (
|
|
||||||
OPTIONS.output_dir is not None and
|
|
||||||
OPTIONS.output_item_list is None)):
|
|
||||||
common.Usage(__doc__)
|
common.Usage(__doc__)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -924,8 +871,7 @@ def main():
|
||||||
output_item_list=output_item_list,
|
output_item_list=output_item_list,
|
||||||
output_ota=OPTIONS.output_ota,
|
output_ota=OPTIONS.output_ota,
|
||||||
output_super_empty=OPTIONS.output_super_empty,
|
output_super_empty=OPTIONS.output_super_empty,
|
||||||
rebuild_recovery=OPTIONS.rebuild_recovery),
|
rebuild_recovery=OPTIONS.rebuild_recovery), OPTIONS.keep_tmp)
|
||||||
OPTIONS.keep_tmp)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue