From 3db1ef61de5d5c852430a81c02c47f513c78fc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kan=20Kvist?= Date: Tue, 3 May 2022 10:19:41 +0200 Subject: [PATCH] Only enable zucchini if configuration file exists Only enable zucchini if configuration file zucchini_config.txt exits in target files and version in source and target is the same. Without this patch zucchini would be enabled if configuration file was missing from both target files. Bug: 231204699 Test: Run ota package generation with zucchini_config.txt missing from both source and target zips. Confirm that zucchini is disabled. Change-Id: Ia34998fd911d5860b38fe49fa5a88056a22d661e --- tools/releasetools/ota_from_target_files.py | 2 ++ tools/releasetools/ota_utils.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py index 522d489195..66e850b482 100755 --- a/tools/releasetools/ota_from_target_files.py +++ b/tools/releasetools/ota_from_target_files.py @@ -1208,6 +1208,8 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None): metadata.postcondition.partition_state) if not ota_utils.IsZucchiniCompatible(source_file, target_file): + logger.warning( + "Builds doesn't support zucchini, or source/target don't have compatible zucchini versions. Disabling zucchini.") OPTIONS.enable_zucchini = False additional_args += ["--enable_zucchini", diff --git a/tools/releasetools/ota_utils.py b/tools/releasetools/ota_utils.py index 5d403dc9f4..926678ad92 100644 --- a/tools/releasetools/ota_utils.py +++ b/tools/releasetools/ota_utils.py @@ -693,6 +693,7 @@ def IsZucchiniCompatible(source_file: str, target_file: str): if os.path.exists(entry_path): with open(entry_path, "r") as fp: return fp.read() - else: - return "" - return ReadEntry(source_file, _ZUCCHINI_CONFIG_ENTRY_NAME) == ReadEntry(target_file, _ZUCCHINI_CONFIG_ENTRY_NAME) + return False + sourceEntry = ReadEntry(source_file, _ZUCCHINI_CONFIG_ENTRY_NAME) + targetEntry = ReadEntry(target_file, _ZUCCHINI_CONFIG_ENTRY_NAME) + return sourceEntry and targetEntry and sourceEntry == targetEntry