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

Commit a6bef92a authored by Chris Soyars's avatar Chris Soyars Committed by Michael Bestas
Browse files

releasetools: squash backuptool support

this is a squash of the following commits:

commit 30e43f85
Author: Chris Soyars <ctso@ctso.me>
Date:   Thu Dec 23 00:44:33 2010 +0100

    Add otapackage support for backuptool

    Change-Id: I512554c579d444067cd3ccbb0e6946a5eb6bc964a

    Modular backuptool.sh.  Executes backup and restore methods defined in arbitrary /system/addon.d/*.sh scripts.

    * Copy backuptool.functions alongside backuptool.sh.
    * Delete both from /system/bin as they are not useful there.

    Patch Series
    ============
    http://review.cyanogenmod.com/#change,13265
    CyanogenMod/android_build
      * edify generator
    http://review.cyanogenmod.com/#change,13266
    CyanogenMod/android_system_core
      * permissions on /system/addon.d
    http://review.cyanogenmod.com/#change,13267
    CyanogenMod/android_vendor_cm
      * 50-cm.sh reference backup script
      * modular backuptool.sh
      * support backuptool.functions used by /system/addon.d/*.sh scripts

    Change-Id: I26b4907d28f49c69627699d2accd2f0fa2d1b112

    update ota_from_target_files to handle mounting/unmounting for backupscript

    backupscript should not be mounting/unmounting itself as it makes other
    scripts have unexpected results (such as modelid_cfg, which expects /system
    to be mounted)

    instead have the ota script handle the mounting/unmounting

    Change-Id: I94511f4147c624d975cb3ecbeaa8b0e98f63437c

    build: Don't run backuptool on GMS builds

    Change-Id: I5dde27f9d16b88049171db9805221d92e67f3e5d

commit 66ce73d1
Author: Tom Marshall <tdm@cyngn.com>
Date:   Wed Apr 9 16:14:07 2014 -0700

    build: edify: use set_metadata for backuptool

    Also use saner permissions on backuptool.sh

    Change-Id: I50742b51867aa358f5924b8dc208833092a35bd9

commit dac6e8fee851433ff35723f2a790e3930aaeb113
Author: Ricardo Cerqueira <ricardo@cyngn.com>
Date:   Wed Nov 5 18:16:43 2014 +0000

    ota: Include copies of the recovery scripts even if shipping in block mode

commit 5a6d5b87d44f638307531f29c89d19b41c79532b
Author: Ricardo Cerqueira <ricardo@cyngn.com>
Date:   Wed Nov 5 19:58:59 2014 +0000

    ota: Fix recovery-script cleanups in block mode

    Change-Id: Iadb480f8062cfb7a0e6c9024e32ac0d71a7481d7

Author: Arian <arian.kulmer@web.de>
Date:   Wed Jun 17 12:35:16 2020 +0200

    build: Disable backuptool on user instead of GMS builds

    * Backuptool is not exclusively used for GApps but
      also used by other things (i.e. Magisk), hence
      it shouldn't be disabled on all GMS builds.

    Change-Id: Ia95c6fed21d7bed5e2e0610aa94264edc1d02c80

Change-Id: I2401d334d8e16d18d3770b339ec2c787dd8e477c
parent a49702ec
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -4992,6 +4992,7 @@ PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
        --verbose \
        --verbose \
        --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
        --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
        --path $(HOST_OUT) \
        --path $(HOST_OUT) \
        --backup=$(backuptool) \
        $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
        $(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
        $(2) \
        $(2) \
        $(BUILT_TARGET_FILES_PACKAGE) $(1)
        $(BUILT_TARGET_FILES_PACKAGE) $(1)
@@ -5006,6 +5007,16 @@ name := $(name)-ota-$(FILE_NAME_TAG)
INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata


ifeq ($(TARGET_BUILD_VARIANT),user)
    $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
else
ifneq ($(LINEAGE_BUILD),)
    $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := true
else
    $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
endif
endif

$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES)
+9 −0
Original line number Original line Diff line number Diff line
@@ -156,6 +156,9 @@ class EdifyGenerator(object):
           ");")
           ");")
    self.script.append(self.WordWrap(cmd))
    self.script.append(self.WordWrap(cmd))


  def RunBackup(self, command):
    self.script.append(('run_program("/tmp/install/bin/backuptool.sh", "%s");' % command))

  def ShowProgress(self, frac, dur):
  def ShowProgress(self, frac, dur):
    """Update the progress bar, advancing it over 'frac' over the next
    """Update the progress bar, advancing it over 'frac' over the next
    'dur' seconds.  'dur' may be zero to advance it via SetProgress
    'dur' seconds.  'dur' may be zero to advance it via SetProgress
@@ -248,6 +251,12 @@ 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 Unmount(self, mount_point):
    """Unmount the partition with the given mount_point."""
    if mount_point in self.mounts:
      self.mounts.remove(mount_point)
      self.script.append('unmount("%s");' % (mount_point,))

  def UnpackPackageDir(self, src, dst):
  def UnpackPackageDir(self, src, dst):
    """Unpack a given directory from the OTA package into the given
    """Unpack a given directory from the OTA package into the given
    destination directory."""
    destination directory."""
+19 −0
Original line number Original line Diff line number Diff line
@@ -202,6 +202,10 @@ A/B OTA specific options
      ones. Should only be used if caller knows it's safe to do so (e.g. all the
      ones. Should only be used if caller knows it's safe to do so (e.g. all the
      postinstall work is to dexopt apps and a data wipe will happen immediately
      postinstall work is to dexopt apps and a data wipe will happen immediately
      after). Only meaningful when generating A/B OTAs.
      after). Only meaningful when generating A/B OTAs.

  --backup <boolean>
      Enable or disable the execution of backuptool.sh.
      Disabled by default.
"""
"""


from __future__ import print_function
from __future__ import print_function
@@ -266,6 +270,7 @@ OPTIONS.output_metadata_path = None
OPTIONS.disable_fec_computation = False
OPTIONS.disable_fec_computation = False
OPTIONS.force_non_ab = False
OPTIONS.force_non_ab = False
OPTIONS.boot_variable_file = None
OPTIONS.boot_variable_file = None
OPTIONS.backuptool = False




METADATA_NAME = 'META-INF/com/android/metadata'
METADATA_NAME = 'META-INF/com/android/metadata'
@@ -825,6 +830,11 @@ else if get_stage("%(bcb_dev)s") == "3/3" then
  script.SetPermissionsRecursive("/tmp/install", 0, 0, 0o755, 0o644, None, None)
  script.SetPermissionsRecursive("/tmp/install", 0, 0, 0o755, 0o644, None, None)
  script.SetPermissionsRecursive("/tmp/install/bin", 0, 0, 0o755, 0o755, None, None)
  script.SetPermissionsRecursive("/tmp/install/bin", 0, 0, 0o755, 0o755, None, None)


  if OPTIONS.backuptool:
    script.Mount("/system")
    script.RunBackup("backup")
    script.Unmount("/system")

  # 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
@@ -857,6 +867,12 @@ else if get_stage("%(bcb_dev)s") == "3/3" then


  device_specific.FullOTA_PostValidate()
  device_specific.FullOTA_PostValidate()


  if OPTIONS.backuptool:
    script.ShowProgress(0.02, 10)
    script.Mount("/system")
    script.RunBackup("restore")
    script.Unmount("/system")

  script.WriteRawImage("/boot", "boot.img")
  script.WriteRawImage("/boot", "boot.img")


  script.ShowProgress(0.1, 10)
  script.ShowProgress(0.1, 10)
@@ -2129,6 +2145,8 @@ def main(argv):
      OPTIONS.force_non_ab = True
      OPTIONS.force_non_ab = True
    elif o == "--boot_variable_file":
    elif o == "--boot_variable_file":
      OPTIONS.boot_variable_file = a
      OPTIONS.boot_variable_file = a
    elif o in ("--backup"):
      OPTIONS.backuptool = bool(a.lower() == 'true')
    else:
    else:
      return False
      return False
    return True
    return True
@@ -2167,6 +2185,7 @@ def main(argv):
                                 "disable_fec_computation",
                                 "disable_fec_computation",
                                 "force_non_ab",
                                 "force_non_ab",
                                 "boot_variable_file=",
                                 "boot_variable_file=",
                                 "backup=",
                             ], extra_option_handler=option_handler)
                             ], extra_option_handler=option_handler)


  if len(args) != 2:
  if len(args) != 2: