Adds image-specific selinux_fc props to allow different file_contexts.
This enables mixed builds to use the file_contexts.bin from the system
build when regenerating images that come from system target files, and
similarly for file_contexts.bin from the other build when regenerating
images from other target files.
In monolithic (non-mixed) builds all image-specific selinux_fc props
point to the same file_contexts.
Bug: 132108151
Test: Built and booted mixed build devices.
Change-Id: Id51ed6d96ea6337879f1ab21d47c93c67bc25312
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index e642297..5bdb2a7 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -332,13 +332,15 @@
raise ValueError("Failed to find 'fstab_version'")
if repacking:
- # "selinux_fc" should point to the file_contexts file (file_contexts.bin)
- # under META/.
- fc_basename = os.path.basename(d.get("selinux_fc", "file_contexts"))
- fc_config = os.path.join(input_file, "META", fc_basename)
- assert os.path.exists(fc_config)
+ # "selinux_fc" properties should point to the file_contexts files
+ # (file_contexts.bin) under META/.
+ for key in d:
+ if key.endswith("selinux_fc"):
+ fc_basename = os.path.basename(d[key])
+ fc_config = os.path.join(input_file, "META", fc_basename)
+ assert os.path.exists(fc_config)
- d["selinux_fc"] = fc_config
+ d[key] = fc_config
# Similarly we need to redirect "root_dir", and "root_fs_config".
d["root_dir"] = os.path.join(input_file, "ROOT")