From d673dd0df79d3c1f457c0981b152748d45741141 Mon Sep 17 00:00:00 2001 From: ImpulsiveCoder007 <62168743+ImpulsiveCoder007@users.noreply.github.com> Date: Sat, 13 Jun 2020 20:50:29 +0530 Subject: [PATCH] releasetools: do not remove dynamic partitions in system-only builds * Before this commit, the generated `dynamic_partitions_op_list` in FullOTA packages always tries to remove all partitions and recreate them upon flashing. This makes it impossible to have a system-only "FullOTA" because vendor partition(s) are always removed. * This commit detects if a build is vendor-less and disables every dynamic partition operation except `resize`, in order to keep the original content around after the flash. The change should not affect non-dynamic-partition or builds with vendor image included. --- tools/releasetools/common.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index a76975f603..5d988a2e05 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -2423,13 +2423,15 @@ def __init__(self, src_size=None, tgt_size=None): class DynamicPartitionsDifference(object): def __init__(self, info_dict, block_diffs, progress_dict=None, - source_info_dict=None): + source_info_dict=None, build_without_vendor=False): if progress_dict is None: progress_dict = dict() + self._build_without_vendor = build_without_vendor self._remove_all_before_apply = False if source_info_dict is None: - self._remove_all_before_apply = True + if not build_without_vendor: + self._remove_all_before_apply = True source_info_dict = dict() block_diff_dict = {e.partition:e for e in block_diffs} @@ -2554,6 +2556,17 @@ def comment(line): 'applying full OTA') append('remove_all_groups') + if self._build_without_vendor: + comment('System-only build, keep original vendor partitions') + # When building without vendor, we do not want to override + # any partition already existing. In this case, we can only + # resize, but not remove / create / re-create any other + # partition. + for p, u in self._partition_updates.items(): + comment('Resize partition %s to %s' % (p, u.tgt_size)) + append('resize %s %s' % (p, u.tgt_size)) + return + for p, u in self._partition_updates.items(): if u.src_group and not u.tgt_group: append('remove %s' % p)