Update releasetools for new init_boot.img

This new init_boot.img contains the ramdisk that used to reside in the
boot.img file.

Test: set BOARD_PREBUILT_INIT_BOOT_IMAGE to an external init_boot.img
      - Check that "m" pulls in the init_boot.img to
      out/target/product/vsoc_x86_64/
      - Check that "m dist" adds the init_boot.img to
      aosp_cf_x86_64_phone-img-eng.devinmoore.zip
Test: atest --host releasetools_test
Bug: 203698939
Change-Id: If7ef2cf093e5e525529c7c44333c0f40f6ba0764
This commit is contained in:
Devin Moore
2021-12-13 22:04:08 +00:00
parent 380d9e445c
commit afdd7c74bc
5 changed files with 35 additions and 9 deletions

View File

@@ -759,6 +759,7 @@ def AddImagesToTargetFiles(filename):
has_recovery = OPTIONS.info_dict.get("no_recovery") != "true" has_recovery = OPTIONS.info_dict.get("no_recovery") != "true"
has_boot = OPTIONS.info_dict.get("no_boot") != "true" has_boot = OPTIONS.info_dict.get("no_boot") != "true"
has_init_boot = OPTIONS.info_dict.get("init_boot") == "true"
has_vendor_boot = OPTIONS.info_dict.get("vendor_boot") == "true" has_vendor_boot = OPTIONS.info_dict.get("vendor_boot") == "true"
# {vendor,odm,product,system_ext,vendor_dlkm,odm_dlkm, system, system_other}.img # {vendor,odm,product,system_ext,vendor_dlkm,odm_dlkm, system, system_other}.img
@@ -819,6 +820,17 @@ def AddImagesToTargetFiles(filename):
if output_zip: if output_zip:
boot_image.AddToZip(output_zip) boot_image.AddToZip(output_zip)
if has_init_boot:
banner("init_boot")
init_boot_image = common.GetBootableImage(
"IMAGES/init_boot.img", "init_boot.img", OPTIONS.input_tmp, "INIT_BOOT")
if init_boot_image:
partitions['init_boot'] = os.path.join(OPTIONS.input_tmp, "IMAGES", "init_boot.img")
if not os.path.exists(partitions['init_boot']):
init_boot_image.WriteToDir(OPTIONS.input_tmp)
if output_zip:
init_boot_image.AddToZip(output_zip)
if has_vendor_boot: if has_vendor_boot:
banner("vendor_boot") banner("vendor_boot")
vendor_boot_image = common.GetVendorBootImage( vendor_boot_image = common.GetVendorBootImage(

View File

@@ -111,7 +111,7 @@ SPECIAL_CERT_STRINGS = ("PRESIGNED", "EXTERNAL")
# descriptor into vbmeta.img. When adding a new entry here, the # descriptor into vbmeta.img. When adding a new entry here, the
# AVB_FOOTER_ARGS_BY_PARTITION in sign_target_files_apks need to be updated # AVB_FOOTER_ARGS_BY_PARTITION in sign_target_files_apks need to be updated
# accordingly. # accordingly.
AVB_PARTITIONS = ('boot', 'dtbo', 'odm', 'product', 'pvmfw', 'recovery', AVB_PARTITIONS = ('boot', 'init_boot', 'dtbo', 'odm', 'product', 'pvmfw', 'recovery',
'system', 'system_ext', 'vendor', 'vendor_boot', 'system', 'system_ext', 'vendor', 'vendor_boot',
'vendor_dlkm', 'odm_dlkm') 'vendor_dlkm', 'odm_dlkm')
@@ -130,7 +130,7 @@ PARTITIONS_WITH_CARE_MAP = [
] ]
# Partitions with a build.prop file # Partitions with a build.prop file
PARTITIONS_WITH_BUILD_PROP = PARTITIONS_WITH_CARE_MAP + ['boot'] PARTITIONS_WITH_BUILD_PROP = PARTITIONS_WITH_CARE_MAP + ['boot', 'init_boot']
# See sysprop.mk. If file is moved, add new search paths here; don't remove # See sysprop.mk. If file is moved, add new search paths here; don't remove
# existing search paths. # existing search paths.
@@ -935,9 +935,9 @@ class PartitionBuildProps(object):
def FromInputFile(input_file, name, placeholder_values=None, ramdisk_format=RamdiskFormat.LZ4): def FromInputFile(input_file, name, placeholder_values=None, ramdisk_format=RamdiskFormat.LZ4):
"""Loads the build.prop file and builds the attributes.""" """Loads the build.prop file and builds the attributes."""
if name == "boot": if name in ("boot", "init_boot"):
data = PartitionBuildProps._ReadBootPropFile( data = PartitionBuildProps._ReadBootPropFile(
input_file, ramdisk_format=ramdisk_format) input_file, name, ramdisk_format=ramdisk_format)
else: else:
data = PartitionBuildProps._ReadPartitionPropFile(input_file, name) data = PartitionBuildProps._ReadPartitionPropFile(input_file, name)
@@ -946,15 +946,16 @@ class PartitionBuildProps(object):
return props return props
@staticmethod @staticmethod
def _ReadBootPropFile(input_file, ramdisk_format): def _ReadBootPropFile(input_file, partition_name, ramdisk_format):
""" """
Read build.prop for boot image from input_file. Read build.prop for boot image from input_file.
Return empty string if not found. Return empty string if not found.
""" """
image_path = 'IMAGES/' + partition_name + '.img'
try: try:
boot_img = ExtractFromInputFile(input_file, 'IMAGES/boot.img') boot_img = ExtractFromInputFile(input_file, image_path)
except KeyError: except KeyError:
logger.warning('Failed to read IMAGES/boot.img') logger.warning('Failed to read %s', image_path)
return '' return ''
prop_file = GetBootImageBuildProp(boot_img, ramdisk_format=ramdisk_format) prop_file = GetBootImageBuildProp(boot_img, ramdisk_format=ramdisk_format)
if prop_file is None: if prop_file is None:
@@ -1539,6 +1540,8 @@ def _BuildBootableImage(image_name, sourcedir, fs_config_file, info_dict=None,
logger.info("Excluded kernel binary from recovery image.") logger.info("Excluded kernel binary from recovery image.")
else: else:
kernel = "kernel" kernel = "kernel"
elif partition_name == "init_boot":
pass
else: else:
kernel = image_name.replace("boot", "kernel") kernel = image_name.replace("boot", "kernel")
kernel = kernel.replace(".img", "") kernel = kernel.replace(".img", "")
@@ -1593,6 +1596,8 @@ def _BuildBootableImage(image_name, sourcedir, fs_config_file, info_dict=None,
# Fall back to "mkbootimg_args" for recovery image # Fall back to "mkbootimg_args" for recovery image
# in case "recovery_mkbootimg_args" is not set. # in case "recovery_mkbootimg_args" is not set.
args = info_dict.get("mkbootimg_args") args = info_dict.get("mkbootimg_args")
elif partition_name == "init_boot":
args = info_dict.get("mkbootimg_init_args")
else: else:
args = info_dict.get("mkbootimg_args") args = info_dict.get("mkbootimg_args")
if args and args.strip(): if args and args.strip():
@@ -1752,9 +1757,11 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir,
logger.info("building image from target_files %s...", tree_subdir) logger.info("building image from target_files %s...", tree_subdir)
# With system_root_image == "true", we don't pack ramdisk into the boot image. # With system_root_image == "true", we don't pack ramdisk into the boot image.
# With init_boot == "true", we don't pack the ramdisk into boot.img.
# Unless "recovery_as_boot" is specified, in which case we carry the ramdisk # Unless "recovery_as_boot" is specified, in which case we carry the ramdisk
# for recovery. # for recovery.
has_ramdisk = (info_dict.get("system_root_image") != "true" or has_ramdisk = ((info_dict.get("system_root_image") != "true" and
info_dict.get("init_boot") != "true") or
prebuilt_name != "boot.img" or prebuilt_name != "boot.img" or
info_dict.get("recovery_as_boot") == "true") info_dict.get("recovery_as_boot") == "true")

View File

@@ -124,7 +124,7 @@ def EntriesForUserImages(input_file):
for image_path in [name for name in namelist if name.startswith('IMAGES/')]: for image_path in [name for name in namelist if name.startswith('IMAGES/')]:
image = os.path.basename(image_path) image = os.path.basename(image_path)
if OPTIONS.bootable_only and image not in('boot.img', 'recovery.img', 'bootloader'): if OPTIONS.bootable_only and image not in('boot.img', 'recovery.img', 'bootloader', 'init_boot.img'):
continue continue
if not image.endswith('.img') and image != 'bootloader': if not image.endswith('.img') and image != 'bootloader':
continue continue

View File

@@ -201,6 +201,7 @@ OPTIONS.allow_gsi_debug_sepolicy = False
AVB_FOOTER_ARGS_BY_PARTITION = { AVB_FOOTER_ARGS_BY_PARTITION = {
'boot': 'avb_boot_add_hash_footer_args', 'boot': 'avb_boot_add_hash_footer_args',
'init_boot': 'avb_init_boot_add_hash_footer_args',
'dtbo': 'avb_dtbo_add_hash_footer_args', 'dtbo': 'avb_dtbo_add_hash_footer_args',
'product': 'avb_product_add_hashtree_footer_args', 'product': 'avb_product_add_hashtree_footer_args',
'recovery': 'avb_recovery_add_hash_footer_args', 'recovery': 'avb_recovery_add_hash_footer_args',

View File

@@ -62,6 +62,9 @@ name="apex.apexd_test_different_app.apex" public_key="system/apex/apexd/apexd_te
'avb_boot_add_hash_footer_args': 'avb_boot_add_hash_footer_args':
('--prop com.android.build.boot.os_version:R ' ('--prop com.android.build.boot.os_version:R '
'--prop com.android.build.boot.security_patch:2019-09-05'), '--prop com.android.build.boot.security_patch:2019-09-05'),
'avb_init_boot_add_hash_footer_args':
('--prop com.android.build.boot.os_version:R '
'--prop com.android.build.boot.security_patch:2019-09-05'),
'avb_system_add_hashtree_footer_args': 'avb_system_add_hashtree_footer_args':
('--prop com.android.build.system.os_version:R ' ('--prop com.android.build.system.os_version:R '
'--prop com.android.build.system.security_patch:2019-09-05 ' '--prop com.android.build.system.security_patch:2019-09-05 '
@@ -77,6 +80,9 @@ name="apex.apexd_test_different_app.apex" public_key="system/apex/apexd/apexd_te
'avb_boot_add_hash_footer_args': 'avb_boot_add_hash_footer_args':
('--prop com.android.build.boot.os_version:R ' ('--prop com.android.build.boot.os_version:R '
'--prop com.android.build.boot.security_patch:2019-09-05'), '--prop com.android.build.boot.security_patch:2019-09-05'),
'avb_init_boot_add_hash_footer_args':
('--prop com.android.build.boot.os_version:R '
'--prop com.android.build.boot.security_patch:2019-09-05'),
'avb_system_add_hashtree_footer_args': 'avb_system_add_hashtree_footer_args':
('--prop com.android.build.system.os_version:R ' ('--prop com.android.build.system.os_version:R '
'--prop com.android.build.system.security_patch:2019-09-05 ' '--prop com.android.build.system.security_patch:2019-09-05 '