Loading core/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -2735,7 +2735,8 @@ endif endif $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ ./build/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $(zip_root) ./build/tools/releasetools/add_img_to_target_files -a -v --lzma_targets $(shell echo "$(LZMA_RAMDISK_TARGETS)" | sed -e 's/ /,/g') \ -p $(HOST_OUT) $(zip_root) @# Zip everything up, preserving symlinks and placing META/ files first to @# help early validation of the .zip file while uploading it. $(hide) find $(zip_root)/META | sort >$@.list Loading tools/releasetools/add_img_to_target_files.py +20 −6 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ Usage: add_img_to_target_files [flag] target_files --is_signing Skip building & adding the images for "userdata" and "cache" if we are signing the target files. --lzma_targets Compress image targets using lzma instead of minigzip. Supports boot, recovery for now. """ from __future__ import print_function Loading Loading @@ -75,6 +79,7 @@ OPTIONS.replace_updated_files_list = [] OPTIONS.replace_verity_public_key = False OPTIONS.replace_verity_private_key = False OPTIONS.is_signing = False OPTIONS.lzma_targets = [] class OutputFile(object): Loading Loading @@ -580,16 +585,21 @@ def AddImagesToTargetFiles(filename): prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") boot_image = None # account for devices with recovery as boot boot_target = "recovery" if not has_recovery else "boot" if os.path.exists(prebuilt_path): banner("boot") print("boot.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: boot_image = common.GetBootableImage( "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT", compressor=("lzma" if boot_target in OPTIONS.lzma_targets else "minigzip")) else: banner("boot") boot_image = common.GetBootableImage( "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT", compressor=("lzma" if boot_target in OPTIONS.lzma_targets else "minigzip")) if boot_image: if output_zip: boot_image.AddToZip(output_zip) Loading @@ -604,11 +614,12 @@ def AddImagesToTargetFiles(filename): print("recovery.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: recovery_image = common.GetBootableImage( "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY") "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY", compressor=("lzma" if "recovery" in OPTIONS.lzma_targets else "minigzip")) else: recovery_image = common.GetBootableImage( "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY") "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY", compressor=("lzma" if "recovery" in OPTIONS.lzma_targets else "minigzip")) if recovery_image: if output_zip: recovery_image.AddToZip(output_zip) Loading Loading @@ -771,6 +782,8 @@ def main(argv): OPTIONS.replace_verity_public_key = (True, a) elif o == "--is_signing": OPTIONS.is_signing = True elif o == "--lzma_targets": OPTIONS.lzma_targets = a.split(',') else: return False return True Loading @@ -780,7 +793,8 @@ def main(argv): extra_long_opts=["add_missing", "rebuild_recovery", "replace_verity_public_key=", "replace_verity_private_key=", "is_signing"], "is_signing", "lzma_targets="], extra_option_handler=option_handler) Loading tools/releasetools/common.py +10 −7 Original line number Diff line number Diff line Loading @@ -361,7 +361,8 @@ def AppendAVBSigningArgs(cmd, partition): def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, has_ramdisk=False, two_step_image=False): has_ramdisk=False, two_step_image=False, compressor="minigzip"): """Build a bootable image from the specified sourcedir. Take a kernel, cmdline, and optionally a ramdisk directory from the input (in Loading @@ -373,7 +374,7 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, for building the requested image. """ def make_ramdisk(): def make_ramdisk(compressor): ramdisk_img = tempfile.NamedTemporaryFile() if os.access(fs_config_file, os.F_OK): Loading @@ -382,12 +383,12 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, else: cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")] p1 = Run(cmd, stdout=subprocess.PIPE) p2 = Run(["minigzip"], stdin=p1.stdout, stdout=ramdisk_img.file.fileno()) p2 = Run([compressor], stdin=p1.stdout, stdout=ramdisk_img.file.fileno()) p2.wait() p1.wait() assert p1.returncode == 0, "mkbootfs of %s ramdisk failed" % (sourcedir,) assert p2.returncode == 0, "minigzip of %s ramdisk failed" % (sourcedir,) assert p2.returncode == 0, compressor + " of %s ramdisk failed" % (sourcedir,) return ramdisk_img Loading @@ -403,7 +404,7 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, img = tempfile.NamedTemporaryFile() if has_ramdisk: ramdisk_img = make_ramdisk() ramdisk_img = make_ramdisk(compressor) # use MKBOOTIMG from environ, or "mkbootimg" if empty or not set mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg" Loading Loading @@ -535,7 +536,8 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, info_dict=None, two_step_image=False): info_dict=None, two_step_image=False, compressor="minigzip"): """Return a File object with the desired bootable image. Look for it in 'unpack_dir'/BOOTABLE_IMAGES under the name 'prebuilt_name', Loading Loading @@ -567,7 +569,8 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt" data = _BuildBootableImage(os.path.join(unpack_dir, tree_subdir), os.path.join(unpack_dir, fs_config), info_dict, has_ramdisk, two_step_image) info_dict, has_ramdisk, two_step_image, compressor) if data: return File(name, data) return None Loading Loading
core/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -2735,7 +2735,8 @@ endif endif $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ ./build/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $(zip_root) ./build/tools/releasetools/add_img_to_target_files -a -v --lzma_targets $(shell echo "$(LZMA_RAMDISK_TARGETS)" | sed -e 's/ /,/g') \ -p $(HOST_OUT) $(zip_root) @# Zip everything up, preserving symlinks and placing META/ files first to @# help early validation of the .zip file while uploading it. $(hide) find $(zip_root)/META | sort >$@.list Loading
tools/releasetools/add_img_to_target_files.py +20 −6 Original line number Diff line number Diff line Loading @@ -41,6 +41,10 @@ Usage: add_img_to_target_files [flag] target_files --is_signing Skip building & adding the images for "userdata" and "cache" if we are signing the target files. --lzma_targets Compress image targets using lzma instead of minigzip. Supports boot, recovery for now. """ from __future__ import print_function Loading Loading @@ -75,6 +79,7 @@ OPTIONS.replace_updated_files_list = [] OPTIONS.replace_verity_public_key = False OPTIONS.replace_verity_private_key = False OPTIONS.is_signing = False OPTIONS.lzma_targets = [] class OutputFile(object): Loading Loading @@ -580,16 +585,21 @@ def AddImagesToTargetFiles(filename): prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img") boot_image = None # account for devices with recovery as boot boot_target = "recovery" if not has_recovery else "boot" if os.path.exists(prebuilt_path): banner("boot") print("boot.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: boot_image = common.GetBootableImage( "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT", compressor=("lzma" if boot_target in OPTIONS.lzma_targets else "minigzip")) else: banner("boot") boot_image = common.GetBootableImage( "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT") "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT", compressor=("lzma" if boot_target in OPTIONS.lzma_targets else "minigzip")) if boot_image: if output_zip: boot_image.AddToZip(output_zip) Loading @@ -604,11 +614,12 @@ def AddImagesToTargetFiles(filename): print("recovery.img already exists in IMAGES/, no need to rebuild...") if OPTIONS.rebuild_recovery: recovery_image = common.GetBootableImage( "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY") "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY", compressor=("lzma" if "recovery" in OPTIONS.lzma_targets else "minigzip")) else: recovery_image = common.GetBootableImage( "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY") "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY", compressor=("lzma" if "recovery" in OPTIONS.lzma_targets else "minigzip")) if recovery_image: if output_zip: recovery_image.AddToZip(output_zip) Loading Loading @@ -771,6 +782,8 @@ def main(argv): OPTIONS.replace_verity_public_key = (True, a) elif o == "--is_signing": OPTIONS.is_signing = True elif o == "--lzma_targets": OPTIONS.lzma_targets = a.split(',') else: return False return True Loading @@ -780,7 +793,8 @@ def main(argv): extra_long_opts=["add_missing", "rebuild_recovery", "replace_verity_public_key=", "replace_verity_private_key=", "is_signing"], "is_signing", "lzma_targets="], extra_option_handler=option_handler) Loading
tools/releasetools/common.py +10 −7 Original line number Diff line number Diff line Loading @@ -361,7 +361,8 @@ def AppendAVBSigningArgs(cmd, partition): def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, has_ramdisk=False, two_step_image=False): has_ramdisk=False, two_step_image=False, compressor="minigzip"): """Build a bootable image from the specified sourcedir. Take a kernel, cmdline, and optionally a ramdisk directory from the input (in Loading @@ -373,7 +374,7 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, for building the requested image. """ def make_ramdisk(): def make_ramdisk(compressor): ramdisk_img = tempfile.NamedTemporaryFile() if os.access(fs_config_file, os.F_OK): Loading @@ -382,12 +383,12 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, else: cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")] p1 = Run(cmd, stdout=subprocess.PIPE) p2 = Run(["minigzip"], stdin=p1.stdout, stdout=ramdisk_img.file.fileno()) p2 = Run([compressor], stdin=p1.stdout, stdout=ramdisk_img.file.fileno()) p2.wait() p1.wait() assert p1.returncode == 0, "mkbootfs of %s ramdisk failed" % (sourcedir,) assert p2.returncode == 0, "minigzip of %s ramdisk failed" % (sourcedir,) assert p2.returncode == 0, compressor + " of %s ramdisk failed" % (sourcedir,) return ramdisk_img Loading @@ -403,7 +404,7 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, img = tempfile.NamedTemporaryFile() if has_ramdisk: ramdisk_img = make_ramdisk() ramdisk_img = make_ramdisk(compressor) # use MKBOOTIMG from environ, or "mkbootimg" if empty or not set mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg" Loading Loading @@ -535,7 +536,8 @@ def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None, def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, info_dict=None, two_step_image=False): info_dict=None, two_step_image=False, compressor="minigzip"): """Return a File object with the desired bootable image. Look for it in 'unpack_dir'/BOOTABLE_IMAGES under the name 'prebuilt_name', Loading Loading @@ -567,7 +569,8 @@ def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir, fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt" data = _BuildBootableImage(os.path.join(unpack_dir, tree_subdir), os.path.join(unpack_dir, fs_config), info_dict, has_ramdisk, two_step_image) info_dict, has_ramdisk, two_step_image, compressor) if data: return File(name, data) return None Loading