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

Commit 6f488e9e authored by TJ Rhoades's avatar TJ Rhoades
Browse files

Expose GetRamdiskFormat and use in ota_utils.py



Some OTA files may have additional OTA props; when this is being computed within
ota_utils.py -> ComputeRuntimeBuildInfos, the ramdisk type needs to be passed into
PartitionBuildProps.FromInputFile as not all ramdisk may still use gzip. This check
is already defined in common.py, so this change also exposes the function GetRamdiskFormat.

Bug: 231075507

Signed-off-by: default avatarTJ Rhoades <tjr@microsoft.com>
Change-Id: If1b93b887990f0d90df2c6003122821c1e66a1ac
parent d3eb2e30
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -725,7 +725,7 @@ class RamdiskFormat(object):
  GZ = 2


def _GetRamdiskFormat(info_dict):
def GetRamdiskFormat(info_dict):
  if info_dict.get('lz4_ramdisks') == 'true':
    ramdisk_format = RamdiskFormat.LZ4
  else:
@@ -834,7 +834,7 @@ def LoadInfoDict(input_file, repacking=False):

  # Load recovery fstab if applicable.
  d["fstab"] = _FindAndLoadRecoveryFstab(d, input_file, read_helper)
  ramdisk_format = _GetRamdiskFormat(d)
  ramdisk_format = GetRamdiskFormat(d)

  # Tries to load the build props for all partitions with care_map, including
  # system and vendor.
@@ -1575,7 +1575,7 @@ def _BuildBootableImage(image_name, sourcedir, fs_config_file, info_dict=None,
  img = tempfile.NamedTemporaryFile()

  if has_ramdisk:
    ramdisk_format = _GetRamdiskFormat(info_dict)
    ramdisk_format = GetRamdiskFormat(info_dict)
    ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file,
                               ramdisk_format=ramdisk_format)

@@ -1856,7 +1856,7 @@ def _BuildVendorBootImage(sourcedir, partition_name, info_dict=None):

  img = tempfile.NamedTemporaryFile()

  ramdisk_format = _GetRamdiskFormat(info_dict)
  ramdisk_format = GetRamdiskFormat(info_dict)
  ramdisk_img = _MakeRamdisk(sourcedir, ramdisk_format=ramdisk_format)

  # use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
+7 −3
Original line number Diff line number Diff line
@@ -22,7 +22,8 @@ import zipfile
import ota_metadata_pb2
from common import (ZipDelete, ZipClose, OPTIONS, MakeTempFile,
                    ZipWriteStr, BuildInfo, LoadDictionaryFromFile,
                    SignFile, PARTITIONS_WITH_BUILD_PROP, PartitionBuildProps)
                    SignFile, PARTITIONS_WITH_BUILD_PROP, PartitionBuildProps,
                    GetRamdiskFormat)

logger = logging.getLogger(__name__)

@@ -371,15 +372,18 @@ def ComputeRuntimeBuildInfos(default_build_info, boot_variable_values):
    for partition in PARTITIONS_WITH_BUILD_PROP:
      partition_prop_key = "{}.build.prop".format(partition)
      input_file = info_dict[partition_prop_key].input_file
      ramdisk = GetRamdiskFormat(info_dict)
      if isinstance(input_file, zipfile.ZipFile):
        with zipfile.ZipFile(input_file.filename, allowZip64=True) as input_zip:
          info_dict[partition_prop_key] = \
              PartitionBuildProps.FromInputFile(input_zip, partition,
                                                placeholder_values)
                                                placeholder_values,
                                                ramdisk)
      else:
        info_dict[partition_prop_key] = \
            PartitionBuildProps.FromInputFile(input_file, partition,
                                              placeholder_values)
                                              placeholder_values,
                                              ramdisk)
    info_dict["build.prop"] = info_dict["system.build.prop"]
    build_info_set.add(BuildInfo(info_dict, default_build_info.oem_dicts))