releasetools: squash backuptool support
This is a squash of the following commits: 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 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 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 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 Author: Davide Garberi <dade.garberi@gmail.com> Date: Tue Sep 24 18:45:17 2019 +0200 releasetools: Move system mount handling to backuptool * This allows the ROM to be flashed on any recovery, whether it mounts system to /system, /system_root or /mnt/system like Q recovery * Remove any type of system mount with static paths from updater-script to figure out the path dinamically through backuptool Change-Id: I7b33726305cb6f3eec146d26135f0081002a25dc Author: Jesse Chan <jc@lineageos.org> Date: Fri Jun 12 21:53:18 2020 +0800 releasetools: support dynamic partitions for backuptool Change-Id: I4a04e52f64e307a9852d786aabf17975a020b4b8 Signed-off-by: Jesse Chan <jc@lineageos.org> Author: Jesse Chan <jc@lineageos.org> Date: Tue Jul 7 23:50:10 2020 +0800 backuptool: do not unmap dynamic partition after finished Keep partitions mapped so users can install addons. Change-Id: Ic70621986bf136775e686dc8cc690ce076485907 Signed-off-by: Jesse Chan <jc@lineageos.org> Author: Alessandro Astone <ales.astone@gmail.com> Date: Mon Apr 12 18:40:10 2021 +0200 backuptool: Map extra dynamic partitions for Addon.d V3 Change-Id: Ia8fa1963c722c5aa2987b947e4e919e19909a9a8 Change-Id: I2401d334d8e16d18d3770b339ec2c787dd8e477c
This commit is contained in:
@@ -7138,6 +7138,7 @@ PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
|
|||||||
$(OTA_FROM_TARGET_FILES) \
|
$(OTA_FROM_TARGET_FILES) \
|
||||||
--verbose \
|
--verbose \
|
||||||
--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)) \
|
||||||
$(if $(BOOT_VAR_OTA_CONFIG), --boot_variable_file $(BOOT_VAR_OTA_CONFIG)) \
|
$(if $(BOOT_VAR_OTA_CONFIG), --boot_variable_file $(BOOT_VAR_OTA_CONFIG)) \
|
||||||
$(2) \
|
$(2) \
|
||||||
@@ -7155,6 +7156,16 @@ INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
|
|||||||
|
|
||||||
$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
|
$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
|
||||||
|
|
||||||
|
ifeq ($(TARGET_BUILD_VARIANT),user)
|
||||||
|
$(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
|
||||||
|
else
|
||||||
|
ifneq ($(CUSTOM_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_DIR) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
|
$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_DIR) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
|
||||||
|
@@ -156,6 +156,20 @@ class EdifyGenerator(object):
|
|||||||
");")
|
");")
|
||||||
self.script.append(self.WordWrap(cmd))
|
self.script.append(self.WordWrap(cmd))
|
||||||
|
|
||||||
|
def RunBackup(self, command, mount_point, dynamic=False):
|
||||||
|
systemEntry = self.fstab[mount_point]
|
||||||
|
if dynamic:
|
||||||
|
for p in ["vendor", "product", "system_ext"]:
|
||||||
|
fstabEntry = self.fstab.get("/"+p, None)
|
||||||
|
if fstabEntry:
|
||||||
|
self.script.append('map_partition("%s");' % (fstabEntry.device,))
|
||||||
|
|
||||||
|
self.script.append(('run_program("/tmp/install/bin/backuptool.sh", "%s", map_partition("%s"), "%s");' % (
|
||||||
|
command, systemEntry.device, systemEntry.fs_type)))
|
||||||
|
else:
|
||||||
|
self.script.append(('run_program("/tmp/install/bin/backuptool.sh", "%s", "%s", "%s");' % (
|
||||||
|
command, systemEntry.device, systemEntry.fs_type)))
|
||||||
|
|
||||||
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 +262,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."""
|
||||||
|
@@ -221,6 +221,14 @@ 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 target_info.get("system_root_image") == "true":
|
||||||
|
sysmount = "/"
|
||||||
|
else:
|
||||||
|
sysmount = "/system"
|
||||||
|
|
||||||
|
if OPTIONS.backuptool:
|
||||||
|
script.RunBackup("backup", sysmount, target_info.get('use_dynamic_partitions') == "true")
|
||||||
|
|
||||||
# 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
|
||||||
@@ -254,6 +262,10 @@ 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.RunBackup("restore", sysmount, target_info.get('use_dynamic_partitions') == "true")
|
||||||
|
|
||||||
script.WriteRawImage("/boot", "boot.img")
|
script.WriteRawImage("/boot", "boot.img")
|
||||||
|
|
||||||
script.ShowProgress(0.1, 10)
|
script.ShowProgress(0.1, 10)
|
||||||
|
@@ -268,6 +268,9 @@ A/B OTA specific options
|
|||||||
--full_ota_partitions
|
--full_ota_partitions
|
||||||
Specify list of partitions should be updated in full OTA fashion, even if
|
Specify list of partitions should be updated in full OTA fashion, even if
|
||||||
an incremental OTA is about to be generated
|
an incremental OTA is about to be generated
|
||||||
|
--backup <boolean>
|
||||||
|
Enable or disable the execution of backuptool.sh.
|
||||||
|
Disabled by default.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
@@ -342,6 +345,7 @@ OPTIONS.max_threads = None
|
|||||||
OPTIONS.vabc_cow_version = None
|
OPTIONS.vabc_cow_version = None
|
||||||
OPTIONS.compression_factor = None
|
OPTIONS.compression_factor = None
|
||||||
OPTIONS.full_ota_partitions = None
|
OPTIONS.full_ota_partitions = None
|
||||||
|
OPTIONS.backuptool = False
|
||||||
|
|
||||||
|
|
||||||
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
|
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
|
||||||
@@ -1336,6 +1340,8 @@ def main(argv):
|
|||||||
elif o == "--full_ota_partitions":
|
elif o == "--full_ota_partitions":
|
||||||
OPTIONS.full_ota_partitions = set(
|
OPTIONS.full_ota_partitions = set(
|
||||||
a.strip().strip("\"").strip("'").split(","))
|
a.strip().strip("\"").strip("'").split(","))
|
||||||
|
elif o == "--backup":
|
||||||
|
OPTIONS.backuptool = True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@@ -1387,6 +1393,7 @@ def main(argv):
|
|||||||
"vabc_cow_version=",
|
"vabc_cow_version=",
|
||||||
"compression_factor=",
|
"compression_factor=",
|
||||||
"full_ota_partitions=",
|
"full_ota_partitions=",
|
||||||
|
"backup=",
|
||||||
], extra_option_handler=[option_handler, payload_signer.signer_options])
|
], extra_option_handler=[option_handler, payload_signer.signer_options])
|
||||||
common.InitLogging()
|
common.InitLogging()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user