aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Peckham <bpeckham@google.com>2019-05-07 17:26:25 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-05-07 17:26:25 +0000
commit7dbbc3075b5f4f3bc91eeecf3d7e3df429c60e5b (patch)
tree5dcb17ed35129f375b6a6cd3f182185ec47bca3d
parentc43a3e1103b92fd8f896f36f13c168574023c273 (diff)
parent736b223d5f78f6abdf1af7aae4742900395f9ec4 (diff)
downloadbuild-oreo-mr1-iot-release.tar.gz
Merge "Use file_contexts.bin from other build to regenerate images."android-o-mr1-iot-release-1.0.12oreo-mr1-iot-release
-rwxr-xr-xtools/releasetools/merge_target_files.py84
1 files changed, 2 insertions, 82 deletions
diff --git a/tools/releasetools/merge_target_files.py b/tools/releasetools/merge_target_files.py
index 689e0951cc..f0d55d71b5 100755
--- a/tools/releasetools/merge_target_files.py
+++ b/tools/releasetools/merge_target_files.py
@@ -160,6 +160,7 @@ default_system_misc_info_keys = [
default_other_item_list = [
'META/boot_filesystem_config.txt',
+ 'META/file_contexts.bin',
'META/otakeys.txt',
'META/releasetools.py',
'META/vendor_filesystem_config.txt',
@@ -442,81 +443,7 @@ def process_misc_info_txt(system_target_files_temp_dir,
output.write('{}={}\n'.format(key, merged_info_dict[key]))
-def process_file_contexts_bin(temp_dir, output_target_files_temp_dir):
- """Perform special processing for META/file_contexts.bin.
-
- This function combines plat_file_contexts and vendor_file_contexts, which are
- expected to already be extracted in temp_dir, to produce a merged
- file_contexts.bin that will land in temp_dir at META/file_contexts.bin.
-
- Args:
- temp_dir: The name of a scratch directory that this function can use for
- intermediate files generated during processing.
- output_target_files_temp_dir: The name of the working directory that must
- already contain plat_file_contexts and vendor_file_contexts (in the
- appropriate sub directories), and to which META/file_contexts.bin will be
- written.
- """
-
- # To create a merged file_contexts.bin file, we use the system and vendor
- # file contexts files as input, the m4 tool to combine them, the sorting tool
- # to sort, and finally the sefcontext_compile tool to generate the final
- # output. We currently omit a checkfc step since the files had been checked
- # as part of the build.
-
- # The m4 step concatenates the two input files contexts files. Since m4
- # writes to stdout, we receive that into an array of bytes, and then write it
- # to a file.
-
- # Collect the file contexts that we're going to combine from SYSTEM, VENDOR,
- # PRODUCT, and ODM. We require SYSTEM and VENDOR, but others are optional.
-
- file_contexts_list = []
-
- for partition in ['SYSTEM', 'VENDOR', 'PRODUCT', 'ODM']:
- prefix = 'plat' if partition == 'SYSTEM' else partition.lower()
-
- file_contexts = os.path.join(output_target_files_temp_dir, partition, 'etc',
- 'selinux', prefix + '_file_contexts')
-
- mandatory = partition in ['SYSTEM', 'VENDOR']
-
- if mandatory or os.path.isfile(file_contexts):
- file_contexts_list.append(file_contexts)
- else:
- logger.warning('file not found: %s', file_contexts)
-
- command = ['m4', '--fatal-warnings', '-s'] + file_contexts_list
-
- merged_content = common.RunAndCheckOutput(command, verbose=False)
-
- merged_file_contexts_txt = os.path.join(temp_dir, 'merged_file_contexts.txt')
-
- with open(merged_file_contexts_txt, 'wb') as f:
- f.write(merged_content)
-
- # The sort step sorts the concatenated file.
-
- sorted_file_contexts_txt = os.path.join(temp_dir, 'sorted_file_contexts.txt')
- command = ['fc_sort', merged_file_contexts_txt, sorted_file_contexts_txt]
- common.RunAndWait(command, verbose=True)
-
- # Finally, the compile step creates the final META/file_contexts.bin.
-
- file_contexts_bin = os.path.join(output_target_files_temp_dir, 'META',
- 'file_contexts.bin')
-
- command = [
- 'sefcontext_compile',
- '-o',
- file_contexts_bin,
- sorted_file_contexts_txt,
- ]
-
- common.RunAndWait(command, verbose=True)
-
-
-def process_special_cases(temp_dir, system_target_files_temp_dir,
+def process_special_cases(system_target_files_temp_dir,
other_target_files_temp_dir,
output_target_files_temp_dir, system_misc_info_keys,
rebuild_recovery):
@@ -526,8 +453,6 @@ def process_special_cases(temp_dir, system_target_files_temp_dir,
processing. This function performs all that special-case processing.
Args:
- temp_dir: The name of a scratch directory that this function can use for
- intermediate files generated during processing.
system_target_files_temp_dir: The name of a directory containing the special
items extracted from the system target files package.
other_target_files_temp_dir: The name of a directory containing the special
@@ -557,10 +482,6 @@ def process_special_cases(temp_dir, system_target_files_temp_dir,
output_target_files_temp_dir=output_target_files_temp_dir,
system_misc_info_keys=system_misc_info_keys)
- process_file_contexts_bin(
- temp_dir=temp_dir,
- output_target_files_temp_dir=output_target_files_temp_dir)
-
def merge_target_files(temp_dir, system_target_files, system_item_list,
system_misc_info_keys, other_target_files,
@@ -655,7 +576,6 @@ def merge_target_files(temp_dir, system_target_files, system_item_list,
# files package are in place.
process_special_cases(
- temp_dir=temp_dir,
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,