Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d30b7518 authored by J. Avila's avatar J. Avila
Browse files

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
Merged-In: I39680b91930d2d3cbd0cd565beb78e1ee699397e
Change-Id: I39680b91930d2d3cbd0cd565beb78e1ee699397e
parent f6ce461f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4241,6 +4241,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)" >> $@
+1 −0
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ python_library_host {
        "bsdiff",
        "imgdiff",
        "minigzip",
        "lz4",
        "mkbootfs",
        "signapk",
    ],
+11 −5
Original line number Diff line number Diff line
@@ -1152,7 +1152,7 @@ def BuildVBMeta(image_path, partitions, name, needed_partitions):
    assert OPTIONS.aftl_signer_helper is not None, 'No AFTL signer helper provided.'
    # AFTL inclusion proof generation code will go here.

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):
@@ -1161,12 +1161,16 @@ def _MakeRamdisk(sourcedir, fs_config_file=None):
  else:
    cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")]
  p1 = Run(cmd, stdout=subprocess.PIPE)
  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

@@ -1204,7 +1208,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"
@@ -1388,7 +1393,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"