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

Commit 44ce7800 authored by Kelvin Zhang's avatar Kelvin Zhang
Browse files

Fix broken enable_lz4diff flag

When enable_lz4diff=true, we need to inject lz4.so from target_files to
delta_generator, this is done by setting LD_PRELOAD.
We used to rely on brillo_update_payload for setting LD_PRELOAD,
since brillo_update_payload is removed, in aosp/2726801, we
need to do this in python

Test: th
Bug: 382199131
Change-Id: I3696363408cf990d816011c0b034c3fc94f14943
parent 57bbaf99
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -1121,17 +1121,18 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None):
  additional_args += ["--enable_lz4diff=" +
                      str(OPTIONS.enable_lz4diff).lower()]

  env_override = {}
  if source_file and OPTIONS.enable_lz4diff:
    input_tmp = common.UnzipTemp(source_file, ["META/liblz4.so"])
    liblz4_path = os.path.join(input_tmp, "META", "liblz4.so")
    liblz4_path = os.path.join(source_file, "META", "liblz4.so")
    assert os.path.exists(
        liblz4_path), "liblz4.so not found in META/ dir of target file {}".format(liblz4_path)
    logger.info("Enabling lz4diff %s", liblz4_path)
    additional_args += ["--liblz4_path", liblz4_path]
    erofs_compression_param = OPTIONS.target_info_dict.get(
        "erofs_default_compressor")
    assert erofs_compression_param is not None, "'erofs_default_compressor' not found in META/misc_info.txt of target build. This is required to enable lz4diff."
    additional_args += ["--erofs_compression_param", erofs_compression_param]
    env_override["LD_PRELOAD"] = liblz4_path + \
        ":" + os.environ.get("LD_PRELOAD", "")

  if OPTIONS.disable_vabc:
    additional_args += ["--disable_vabc=true"]
@@ -1141,10 +1142,15 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None):
    additional_args += ["--compressor_types", OPTIONS.compressor_types]
  additional_args += ["--max_timestamp", max_timestamp]

  env = dict(os.environ)
  if env_override:
    logger.info("Using environment variables %s", env_override)
    env.update(env_override)
  payload.Generate(
      target_file,
      source_file,
      additional_args + partition_timestamps_flags
      additional_args + partition_timestamps_flags,
      env=env
  )

  # Sign the payload.
+6 −5
Original line number Diff line number Diff line
@@ -845,16 +845,16 @@ class PayloadGenerator(object):
    self.is_partial_update = is_partial_update
    self.spl_downgrade = spl_downgrade

  def _Run(self, cmd):  # pylint: disable=no-self-use
  def _Run(self, cmd, **kwargs):  # pylint: disable=no-self-use
    # Don't pipe (buffer) the output if verbose is set. Let
    # brillo_update_payload write to stdout/stderr directly, so its progress can
    # be monitored.
    if OPTIONS.verbose:
      common.RunAndCheckOutput(cmd, stdout=None, stderr=None)
      common.RunAndCheckOutput(cmd, stdout=None, stderr=None, **kwargs)
    else:
      common.RunAndCheckOutput(cmd)
      common.RunAndCheckOutput(cmd, **kwargs)

  def Generate(self, target_file, source_file=None, additional_args=None):
  def Generate(self, target_file, source_file=None, additional_args=None, **kwargs):
    """Generates a payload from the given target-files zip(s).

    Args:
@@ -863,6 +863,7 @@ class PayloadGenerator(object):
          generating a full OTA.
      additional_args: A list of additional args that should be passed to
          delta_generator binary; or None.
      kwargs: Any additional args to pass to subprocess.Popen
    """
    if additional_args is None:
      additional_args = []
@@ -918,7 +919,7 @@ class PayloadGenerator(object):
    if self.is_partial_update:
      cmd.extend(["--is_partial_update=true"])
    cmd.extend(additional_args)
    self._Run(cmd)
    self._Run(cmd, **kwargs)

    self.payload_file = payload_file
    self.payload_properties = None