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

Commit cd87c62f authored by Tom Marshall's avatar Tom Marshall Committed by Michael Bestas
Browse files

build: ota: Support for install tools in /tmp/install

 * Anything in OUT/install gets packaged up into the zip and extracted
   to /tmp/install immediately after FullOTA_InstallBegin.

 * Use /tmp/install in edify scripts and remove code related to using
   and manipulating /system for install tools.

 * Modified to support signing steps being split from build steps.

   Package install files into target-files INSTALL path
   Read from target-files for OTA package creation

   From Change-Id: I64f919c2a757b5474f6cc5f82bd6c33c2a8b558a

 * This also fully reverts commit 6a324ba5 and partially reverts
   commit f388104e as the functions are still needed here.

   From Change-Ids: I4911244ec9945d197d2b56d0d11eab6d2f7b6d3e
                    I4943e2e89ee5c810a63746c570dc5e31e95b8c53

Squashed with the following:

  Author: LuK1337 <priv.luk@gmail.com>
  Date:   Wed Feb 19 02:14:59 2020 +0100

    releasetools: Use 0oXXX instead of 0XXX for octal

    * Fixes py3 syntax error.

    Change-Id: Ia9ca6e392f43694ddf4c952b07bf159e8dead36e

Change-Id: I315a3238e36c8d15e26f935e272f7e27dd59c320
parent 17eb189e
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -4326,6 +4326,7 @@ endif
	$(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
	$(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
	$(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
	$(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
	$(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
	$(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
	$(hide) echo "use_set_metadata=1" >> $@
	$(hide) echo "multistage_support=1" >> $@
	$(hide) echo "multistage_support=1" >> $@
	$(hide) echo "blockimgdiff_versions=3,4" >> $@
	$(hide) echo "blockimgdiff_versions=3,4" >> $@
ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
@@ -4655,6 +4656,9 @@ ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_
	$(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
	$(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
	$(hide) $(call package_files-copy-root, \
	$(hide) $(call package_files-copy-root, \
	    $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
	    $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
	@# OTA install helpers
	$(hide) $(call package_files-copy-root, \
	    $(PRODUCT_OUT)/install,$(zip_root)/INSTALL)
ifdef INSTALLED_KERNEL_TARGET
ifdef INSTALLED_KERNEL_TARGET
	cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
	cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
endif
endif
+24 −0
Original line number Original line Diff line number Diff line
@@ -245,6 +245,11 @@ class EdifyGenerator(object):
          p.mount_point, mount_flags))
          p.mount_point, mount_flags))
      self.mounts.add(p.mount_point)
      self.mounts.add(p.mount_point)


  def UnpackPackageDir(self, src, dst):
    """Unpack a given directory from the OTA package into the given
    destination directory."""
    self.script.append('package_extract_dir("%s", "%s");' % (src, dst))

  def Comment(self, comment):
  def Comment(self, comment):
    """Write a comment into the update script."""
    """Write a comment into the update script."""
    self.script.append("")
    self.script.append("")
@@ -383,6 +388,25 @@ class EdifyGenerator(object):
        assert not entry.slotselect, \
        assert not entry.slotselect, \
          "Use %s because %s is slot suffixed" % (fn, lst[1])
          "Use %s because %s is slot suffixed" % (fn, lst[1])


  def SetPermissionsRecursive(self, fn, uid, gid, dmode, fmode, selabel,
                              capabilities):
    """Recursively set path ownership and permissions."""
    if not self.info.get("use_set_metadata", False):
      self.script.append('set_perm_recursive(%d, %d, 0%o, 0%o, "%s");'
                         % (uid, gid, dmode, fmode, fn))
    else:
      if capabilities is None:
        capabilities = "0x0"
      cmd = 'set_metadata_recursive("%s", "uid", %d, "gid", %d, ' \
          '"dmode", 0%o, "fmode", 0%o' \
          % (fn, uid, gid, dmode, fmode)
      if not fn.startswith("/tmp"):
        cmd += ', "capabilities", "%s"' % capabilities
      if selabel is not None:
        cmd += ', "selabel", "%s"' % selabel
      cmd += ');'
      self.script.append(cmd)

  def WriteRawImage(self, mount_point, fn, mapfn=None):
  def WriteRawImage(self, mount_point, fn, mapfn=None):
    """Write the given package file into the partition for the given
    """Write the given package file into the partition for the given
    mount point."""
    mount point."""
+15 −1
Original line number Original line Diff line number Diff line
@@ -272,7 +272,7 @@ METADATA_NAME = 'META-INF/com/android/metadata'
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt'
DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt'
AB_PARTITIONS = 'META/ab_partitions.txt'
AB_PARTITIONS = 'META/ab_partitions.txt'
UNZIP_PATTERN = ['IMAGES/*', 'META/*', 'OTA/*', 'RADIO/*']
UNZIP_PATTERN = ['IMAGES/*', 'INSTALL/*', 'META/*', 'OTA/*', 'RADIO/*']
# Files to be unzipped for target diffing purpose.
# Files to be unzipped for target diffing purpose.
TARGET_DIFFING_UNZIP_PATTERN = ['BOOT', 'RECOVERY', 'SYSTEM/*', 'VENDOR/*',
TARGET_DIFFING_UNZIP_PATTERN = ['BOOT', 'RECOVERY', 'SYSTEM/*', 'VENDOR/*',
                                'PRODUCT/*', 'SYSTEM_EXT/*', 'ODM/*']
                                'PRODUCT/*', 'SYSTEM_EXT/*', 'ODM/*']
@@ -713,6 +713,15 @@ def GetBlockDifferences(target_zip, source_zip, target_info, source_info,
  return block_diff_dict
  return block_diff_dict




def CopyInstallTools(output_zip):
  install_path = os.path.join(OPTIONS.input_tmp, "INSTALL")
  for root, subdirs, files in os.walk(install_path):
     for f in files:
      install_source = os.path.join(root, f)
      install_target = os.path.join("install", os.path.relpath(root, install_path), f)
      output_zip.write(install_source, install_target)


def WriteFullOTAPackage(input_zip, output_file):
def WriteFullOTAPackage(input_zip, output_file):
  target_info = common.BuildInfo(OPTIONS.info_dict, OPTIONS.oem_dicts)
  target_info = common.BuildInfo(OPTIONS.info_dict, OPTIONS.oem_dicts)


@@ -811,6 +820,11 @@ else if get_stage("%(bcb_dev)s") == "3/3" then
  script.AppendExtra("ifelse(is_mounted(\"/system\"), unmount(\"/system\"));")
  script.AppendExtra("ifelse(is_mounted(\"/system\"), unmount(\"/system\"));")
  device_specific.FullOTA_InstallBegin()
  device_specific.FullOTA_InstallBegin()


  CopyInstallTools(output_zip)
  script.UnpackPackageDir("install", "/tmp/install")
  script.SetPermissionsRecursive("/tmp/install", 0, 0, 0o755, 0o644, None, None)
  script.SetPermissionsRecursive("/tmp/install/bin", 0, 0, 0o755, 0o755, None, None)

  # All other partitions as well as the data wipe use 10% of the progress, and
  # All other partitions as well as the data wipe use 10% of the progress, and
  # the update of the system partition takes the remaining progress.
  # the update of the system partition takes the remaining progress.
  system_progress = 0.9 - (len(block_diff_dict) - 1) * 0.1
  system_progress = 0.9 - (len(block_diff_dict) - 1) * 0.1