Merge "Add option to enable zucchini" am: dcd7e283d2
am: 3468085607
am: cd9f83eeb8
Original change: https://android-review.googlesource.com/c/platform/build/+/1939053 Change-Id: Iacf90c3c455f31e6661c63095c4d3e605a1fe63c
This commit is contained in:
@@ -230,6 +230,9 @@ A/B OTA specific options
|
|||||||
|
|
||||||
--compressor_types
|
--compressor_types
|
||||||
A colon ':' separated list of compressors. Allowed values are bz2 and brotli.
|
A colon ':' separated list of compressors. Allowed values are bz2 and brotli.
|
||||||
|
|
||||||
|
--enable_zucchini
|
||||||
|
Whether to enable to zucchini feature. Will generate smaller OTA but uses more memory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
@@ -299,6 +302,7 @@ OPTIONS.vabc_downgrade = False
|
|||||||
OPTIONS.enable_vabc_xor = True
|
OPTIONS.enable_vabc_xor = True
|
||||||
OPTIONS.force_minor_version = None
|
OPTIONS.force_minor_version = None
|
||||||
OPTIONS.compressor_types = None
|
OPTIONS.compressor_types = None
|
||||||
|
OPTIONS.enable_zucchini = None
|
||||||
|
|
||||||
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
|
POSTINSTALL_CONFIG = 'META/postinstall_config.txt'
|
||||||
DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt'
|
DYNAMIC_PARTITION_INFO = 'META/dynamic_partitions_info.txt'
|
||||||
@@ -1141,6 +1145,14 @@ def GenerateAbOtaPackage(target_file, output_file, source_file=None):
|
|||||||
partition_timestamps_flags = GeneratePartitionTimestampFlags(
|
partition_timestamps_flags = GeneratePartitionTimestampFlags(
|
||||||
metadata.postcondition.partition_state)
|
metadata.postcondition.partition_state)
|
||||||
|
|
||||||
|
# Auto-check for compatibility only if --enable_zucchini omitted. Otherwise
|
||||||
|
# let user override zucchini settings. This is useful for testing.
|
||||||
|
if OPTIONS.enable_zucchini is None:
|
||||||
|
if not ota_utils.IsZucchiniCompatible(source_file, target_file):
|
||||||
|
additional_args += ["--enable_zucchini", "false"]
|
||||||
|
else:
|
||||||
|
additional_args += ["--enable_zucchini", str(OPTIONS.enable_zucchini).lower()]
|
||||||
|
|
||||||
if OPTIONS.disable_vabc:
|
if OPTIONS.disable_vabc:
|
||||||
additional_args += ["--disable_vabc", "true"]
|
additional_args += ["--disable_vabc", "true"]
|
||||||
if OPTIONS.enable_vabc_xor:
|
if OPTIONS.enable_vabc_xor:
|
||||||
@@ -1326,6 +1338,8 @@ def main(argv):
|
|||||||
OPTIONS.force_minor_version = a
|
OPTIONS.force_minor_version = a
|
||||||
elif o == "--compressor_types":
|
elif o == "--compressor_types":
|
||||||
OPTIONS.compressor_types = a
|
OPTIONS.compressor_types = a
|
||||||
|
elif o == "--enable_zucchini":
|
||||||
|
OPTIONS.enable_zucchini = a.lower() != "false"
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@@ -1373,6 +1387,7 @@ def main(argv):
|
|||||||
"enable_vabc_xor=",
|
"enable_vabc_xor=",
|
||||||
"force_minor_version=",
|
"force_minor_version=",
|
||||||
"compressor_types=",
|
"compressor_types=",
|
||||||
|
"enable_zucchin=",
|
||||||
], extra_option_handler=option_handler)
|
], extra_option_handler=option_handler)
|
||||||
|
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
|
@@ -638,3 +638,38 @@ def ConstructOtaApexInfo(target_zip, source_file=None):
|
|||||||
target_apex.source_version = source_apex_versions[name]
|
target_apex.source_version = source_apex_versions[name]
|
||||||
|
|
||||||
return target_apex_proto.SerializeToString()
|
return target_apex_proto.SerializeToString()
|
||||||
|
|
||||||
|
|
||||||
|
def IsZucchiniCompatible(source_file: str, target_file: str):
|
||||||
|
"""Check whether zucchini versions in two builds are compatible
|
||||||
|
|
||||||
|
Args:
|
||||||
|
source_file: Path to source build's target_file.zip
|
||||||
|
target_file: Path to target build's target_file.zip
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool true if and only if zucchini versions are compatible
|
||||||
|
"""
|
||||||
|
if source_file is None or target_file is None:
|
||||||
|
return False
|
||||||
|
assert os.path.exists(source_file)
|
||||||
|
assert os.path.exists(target_file)
|
||||||
|
|
||||||
|
assert zipfile.is_zipfile(source_file) or os.path.isdir(source_file)
|
||||||
|
assert zipfile.is_zipfile(target_file) or os.path.isdir(target_file)
|
||||||
|
_ZUCCHINI_CONFIG_ENTRY_NAME = "META/zucchini_config.txt"
|
||||||
|
|
||||||
|
def ReadEntry(path, entry):
|
||||||
|
# Read an entry inside a .zip file or extracted dir of .zip file
|
||||||
|
if zipfile.is_zipfile(path):
|
||||||
|
with zipfile.ZipFile(path, "r", allowZip64=True) as zfp:
|
||||||
|
if entry in zfp.namelist():
|
||||||
|
return zfp.read(entry).decode()
|
||||||
|
else:
|
||||||
|
entry_path = os.path.join(entry, path)
|
||||||
|
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)
|
||||||
|
Reference in New Issue
Block a user