Add LZ4 support to the release tools

The core android build platform has changed to add support for LZ4
compression for ramdisks, but the release tools were not. Fix this.

Bug: 156129966
Change-Id: I39680b91930d2d3cbd0cd565beb78e1ee699397e
This commit is contained in:
J. Avila 2020-06-10 20:09:10 +00:00
parent 9df45f6ec2
commit 98cd4cc7a3
3 changed files with 15 additions and 5 deletions

View File

@ -3774,6 +3774,9 @@ ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
else
echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
endif
ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
echo "lz4_ramdisks=true" >> $@
endif
ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
echo "vendor_boot=true" >> $@
echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@

View File

@ -184,6 +184,7 @@ python_library_host {
"bsdiff",
"imgdiff",
"minigzip",
"lz4",
"mkbootfs",
"signapk",
],

View File

@ -1191,7 +1191,7 @@ def BuildVBMeta(image_path, partitions, name, needed_partitions):
AddAftlInclusionProof(image_path)
def _MakeRamdisk(sourcedir, fs_config_file=None):
def _MakeRamdisk(sourcedir, fs_config_file=None, lz4_ramdisks=False):
ramdisk_img = tempfile.NamedTemporaryFile()
if fs_config_file is not None and os.access(fs_config_file, os.F_OK):
@ -1200,12 +1200,16 @@ def _MakeRamdisk(sourcedir, fs_config_file=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())
if lz4_ramdisks:
p2 = Run(["lz4", "-l", "-12" , "--favor-decSpeed"], stdin=p1.stdout,
stdout=ramdisk_img.file.fileno())
else:
p2 = Run(["minigzip"], 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, "compression of %s ramdisk failed" % (sourcedir,)
return ramdisk_img
@ -1243,7 +1247,8 @@ def _BuildBootableImage(image_name, sourcedir, fs_config_file, info_dict=None,
img = tempfile.NamedTemporaryFile()
if has_ramdisk:
ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file)
use_lz4 = info_dict.get("lz4_ramdisks") == 'true'
ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file, lz4_ramdisks=use_lz4)
# use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg"
@ -1427,7 +1432,8 @@ def _BuildVendorBootImage(sourcedir, info_dict=None):
img = tempfile.NamedTemporaryFile()
ramdisk_img = _MakeRamdisk(sourcedir)
use_lz4 = info_dict.get("lz4_ramdisks") == 'true'
ramdisk_img = _MakeRamdisk(sourcedir, lz4_ramdisks=use_lz4)
# use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg"