Support a first stage ramdisk via TARGET_RAMDISK_OUT
Support a first stage ramdisk which will include the targets placed
into TARGET_RAMDISK_OUT. This replaces the existing ramdisk on
existing devices.
All system images are now built to be mounted as the root dir.
Devices with a first stage ramdisk will switch root to the system
partition.
BOARD_BUILD_SYSTEM_ROOT_IMAGE remains and is used to specify if the
system partition is going to be directly used as rootfs without the
ramdisk.
Bug: 79173823
Bug: 79758715
Test: hikey boots, sailfish boots
Test: OTA walleye from P to master
Change-Id: Idbb2dccc6340b0235a4bef03e11e420a9ed154b6
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index af64955..3e159a6 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -428,9 +428,8 @@
def SetUpInDirAndFsConfig(origin_in, prop_dict):
"""Returns the in_dir and fs_config that should be used for image building.
- If the target uses system_root_image and it's building system.img, it creates
- and returns a staged dir that combines the contents of /system (i.e. in the
- given in_dir) and root.
+ When building system.img for all targets, it creates and returns a staged dir
+ that combines the contents of /system (i.e. in the given in_dir) and root.
Args:
origin_in: Path to the input directory.
@@ -441,8 +440,12 @@
A tuple of in_dir and fs_config that should be used to build the image.
"""
fs_config = prop_dict.get("fs_config")
- if (prop_dict.get("system_root_image") != "true" or
- prop_dict["mount_point"] != "system"):
+
+ if prop_dict["mount_point"] == "system_other":
+ prop_dict["mount_point"] = "system"
+ return origin_in, fs_config
+
+ if prop_dict["mount_point"] != "system":
return origin_in, fs_config
# Construct a staging directory of the root file system.
@@ -516,9 +519,6 @@
def BuildImage(in_dir, prop_dict, out_file, target_out=None):
"""Builds an image for the files under in_dir and writes it to out_file.
- When using system_root_image, it will additionally look for the files under
- root (specified by 'root_dir') and builds an image that contains both sources.
-
Args:
in_dir: Path to input directory.
prop_dict: A property dict that contains info like partition size. Values
@@ -838,7 +838,6 @@
elif mount_point == "system_other":
# We inherit the selinux policies of /system since we contain some of its
# files.
- d["mount_point"] = "system"
copy_prop("avb_system_hashtree_enable", "avb_hashtree_enable")
copy_prop("avb_system_add_hashtree_footer_args",
"avb_add_hashtree_footer_args")
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 38c73fd..caefb79 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -181,26 +181,18 @@
if input_dir is not None:
# We carry a copy of file_contexts.bin under META/. If not available,
# search BOOT/RAMDISK/. Note that sometimes we may need a different file
- # to build images than the one running on device, such as when enabling
- # system_root_image. In that case, we must have the one for image
- # generation copied to META/.
+ # to build images than the one running on device, in that case, we must
+ # have the one for image generation copied to META/.
fc_basename = os.path.basename(d.get("selinux_fc", "file_contexts"))
fc_config = os.path.join(input_dir, "META", fc_basename)
- if d.get("system_root_image") == "true":
- assert os.path.exists(fc_config)
- if not os.path.exists(fc_config):
- fc_config = os.path.join(input_dir, "BOOT", "RAMDISK", fc_basename)
- if not os.path.exists(fc_config):
- fc_config = None
+ assert os.path.exists(fc_config)
- if fc_config:
- d["selinux_fc"] = fc_config
+ d["selinux_fc"] = fc_config
- # Similarly we need to redirect "root_dir" and "root_fs_config".
- if d.get("system_root_image") == "true":
- d["root_dir"] = os.path.join(input_dir, "ROOT")
- d["root_fs_config"] = os.path.join(
- input_dir, "META", "root_filesystem_config.txt")
+ # Similarly we need to redirect "root_dir", and "root_fs_config".
+ d["root_dir"] = os.path.join(input_dir, "ROOT")
+ d["root_fs_config"] = os.path.join(
+ input_dir, "META", "root_filesystem_config.txt")
# Redirect {system,vendor}_base_fs_file.
if "system_base_fs_file" in d:
@@ -709,15 +701,14 @@
if not entry.startswith('/'):
continue
- # "/system/framework/am.jar" => "SYSTEM/framework/am.jar". Note that when
- # using system_root_image, the filename listed in system.map may contain an
- # additional leading slash (i.e. "//system/framework/am.jar"). Using lstrip
- # to get consistent results.
+ # "/system/framework/am.jar" => "SYSTEM/framework/am.jar". Note that the
+ # filename listed in system.map may contain an additional leading slash
+ # (i.e. "//system/framework/am.jar"). Using lstrip to get consistent
+ # results.
arcname = string.replace(entry, which, which.upper(), 1).lstrip('/')
- # Special handling another case with system_root_image, where files not
- # under /system (e.g. "/sbin/charger") are packed under ROOT/ in a
- # target_files.zip.
+ # Special handling another case, where files not under /system
+ # (e.g. "/sbin/charger") are packed under ROOT/ in a target_files.zip.
if which == 'system' and not arcname.startswith('SYSTEM'):
arcname = 'ROOT/' + arcname
diff --git a/tools/releasetools/test_build_image.py b/tools/releasetools/test_build_image.py
index 19b5e08..c91d00d 100644
--- a/tools/releasetools/test_build_image.py
+++ b/tools/releasetools/test_build_image.py
@@ -96,16 +96,6 @@
}
self.assertFalse(CheckHeadroom(ext4fs_output, prop_dict))
- def test_SetUpInDirAndFsConfig_SystemRootImageFalse(self):
- prop_dict = {
- 'fs_config': 'fs-config',
- 'mount_point': 'system',
- }
- in_dir, fs_config = SetUpInDirAndFsConfig('/path/to/in_dir', prop_dict)
- self.assertEqual('/path/to/in_dir', in_dir)
- self.assertEqual('fs-config', fs_config)
- self.assertEqual('system', prop_dict['mount_point'])
-
def test_SetUpInDirAndFsConfig_SystemRootImageTrue_NonSystem(self):
prop_dict = {
'fs_config': 'fs-config',
@@ -124,7 +114,7 @@
fs_config_fp.write('fs-config-{}\n'.format(partition))
return fs_config
- def test_SetUpInDirAndFsConfig_SystemRootImageTrue(self):
+ def test_SetUpInDirAndFsConfig(self):
root_dir = common.MakeTempDir()
with open(os.path.join(root_dir, 'init'), 'w') as init_fp:
init_fp.write('init')
@@ -140,7 +130,6 @@
'fs_config': fs_config_system,
'mount_point': 'system',
'root_dir': root_dir,
- 'system_root_image': 'true',
}
in_dir, fs_config = SetUpInDirAndFsConfig(origin_in, prop_dict)
@@ -154,7 +143,7 @@
self.assertTrue(filecmp.cmp(fs_config_system, fs_config))
self.assertEqual('/', prop_dict['mount_point'])
- def test_SetUpInDirAndFsConfig_SystemRootImageTrue_WithRootFsConfig(self):
+ def test_SetUpInDirAndFsConfig_WithRootFsConfig(self):
root_dir = common.MakeTempDir()
with open(os.path.join(root_dir, 'init'), 'w') as init_fp:
init_fp.write('init')
@@ -172,7 +161,6 @@
'mount_point': 'system',
'root_dir': root_dir,
'root_fs_config': fs_config_root,
- 'system_root_image': 'true',
}
in_dir, fs_config = SetUpInDirAndFsConfig(origin_in, prop_dict)