diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index 0c39827414..f64a7d5416 100644 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -761,6 +761,7 @@ def AddImagesToTargetFiles(filename): 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_system_dlkm = OPTIONS.info_dict.get("system_dlkm") == "true" # {vendor,odm,product,system_ext,vendor_dlkm,odm_dlkm, system, system_other}.img # can be built from source, or dropped into target_files.zip as a prebuilt blob. @@ -831,6 +832,19 @@ def AddImagesToTargetFiles(filename): if output_zip: init_boot_image.AddToZip(output_zip) + if has_system_dlkm: + banner("system_dlkm") + system_dlkm_image = common.GetSystemDlkmImage( + "IMAGES/system_dlkm.img", "system_dlkm.img", OPTIONS.input_tmp, "SYSTEM_DLKM") + if system_dlkm_image: + partitions['system_dlkm'] = os.path.join(OPTIONS.input_tmp, "IMAGES", "system_dlkm.img") + if not os.path.exists(partitions['system_dlkm']): + system_dlkm_image.WriteToDir(OPTIONS.input_tmp) + if output_zip: + system_dlkm_image.AddToZip(output_zip) + else: + logger.error("Couldn't locate system_dlkm.img; skipping...") + if has_vendor_boot: banner("vendor_boot") vendor_boot_image = common.GetVendorBootImage( diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index e5c68bc0d1..22c043a052 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -1835,6 +1835,23 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, return File(name, data) return None +def GetSystemDlkmImage(name, prebuilt_name, unpack_dir, tree_subdir, + info_dict=None): + """Return a File object with the desired system dlkm image. + Look for it under 'unpack_dir'/IMAGES or 'unpack_dir'/PREBUILT_IMAGES. + """ + + prebuilt_path = os.path.join(unpack_dir, "IMAGES", prebuilt_name) + if os.path.exists(prebuilt_path): + logger.info("Using prebuilt %s from IMAGES...", prebuilt_name) + return File.FromLocalFile(name, prebuilt_path) + + prebuilt_path = os.path.join(unpack_dir, "PREBUILT_IMAGES", prebuilt_name) + if os.path.exists(prebuilt_path): + logger.info("Using prebuilt %s from PREBUILT_IMAGES...", prebuilt_name) + return File.FromLocalFile(name, prebuilt_path) + + return None def _BuildVendorBootImage(sourcedir, info_dict=None): """Build a vendor boot image from the specified sourcedir.