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

Commit a1a27344 authored by Chris Soyars's avatar Chris Soyars Committed by Bruno Martins
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

Change-Id: I2401d334d8e16d18d3770b339ec2c787dd8e477c
parent c62b3d5d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -4239,6 +4239,7 @@ PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MK
   --block \
   --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
   -p $(HOST_OUT) \
   --backup=$(backuptool) \
   $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
   $(2) \
   $(BUILT_TARGET_FILES_PACKAGE) $(1)
@@ -4268,6 +4269,16 @@ else
    OTA_SCRIPT_OVERRIDE_DEVICE := $(TARGET_OTA_ASSERT_DEVICE)
endif

ifeq ($(WITH_GMS),true)
    $(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): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)

$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) \
+3 −0
Original line number Diff line number Diff line
@@ -156,6 +156,9 @@ class EdifyGenerator(object):
           ");")
    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):
    """Update the progress bar, advancing it over 'frac' over the next
    'dur' seconds.  'dur' may be zero to advance it via SetProgress
+19 −0
Original line number Diff line number Diff line
@@ -180,6 +180,10 @@ A/B OTA specific options

  --override_device <device>
      Override device-specific asserts. Can be a comma-separated list.

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

from __future__ import print_function
@@ -238,6 +242,7 @@ OPTIONS.retrofit_dynamic_partitions = False
OPTIONS.skip_compatibility_check = False
OPTIONS.output_metadata_path = None
OPTIONS.override_device = 'auto'
OPTIONS.backuptool = False


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

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

  system_progress = 0.75

  if OPTIONS.wipe_user_data:
@@ -1027,6 +1037,12 @@ else if get_stage("%(bcb_dev)s") == "3/3" then

  device_specific.FullOTA_PostValidate()

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

  script.ShowProgress(0.05, 5)
  script.WriteRawImage("/boot", "boot.img")

@@ -2252,6 +2268,8 @@ def main(argv):
      OPTIONS.output_metadata_path = a
    elif o in ("--override_device"):
      OPTIONS.override_device = a
    elif o in ("--backup"):
      OPTIONS.backuptool = bool(a.lower() == 'true')
    else:
      return False
    return True
@@ -2287,6 +2305,7 @@ def main(argv):
                                 "skip_compatibility_check",
                                 "output_metadata_path=",
                                 "override_device=",
                                 "backup=",
                             ], extra_option_handler=option_handler)

  if len(args) != 2: