Allow zip64 support when opening zip files
When opening an zip file through zipfile.ZipFile(), python2 by default
disables zip64 support. To support update files >4GB, we manually add
allowZip64 to override the setting.
Test: generate && serve an OTA
Change-Id: I9645e963ced830cc2d3a4b72bc63b9369a1cefe8
diff --git a/tools/releasetools/ota_utils.py b/tools/releasetools/ota_utils.py
index d444d41..f0e4fcf 100644
--- a/tools/releasetools/ota_utils.py
+++ b/tools/releasetools/ota_utils.py
@@ -62,7 +62,7 @@
def ComputeAllPropertyFiles(input_file, needed_property_files):
# Write the current metadata entry with placeholders.
- with zipfile.ZipFile(input_file) as input_zip:
+ with zipfile.ZipFile(input_file, allowZip64=True) as input_zip:
for property_files in needed_property_files:
metadata.property_files[property_files.name] = property_files.Compute(
input_zip)
@@ -70,7 +70,7 @@
if METADATA_NAME in namelist or METADATA_PROTO_NAME in namelist:
ZipDelete(input_file, [METADATA_NAME, METADATA_PROTO_NAME])
- output_zip = zipfile.ZipFile(input_file, 'a')
+ output_zip = zipfile.ZipFile(input_file, 'a', allowZip64=True)
WriteMetadata(metadata, output_zip)
ZipClose(output_zip)
@@ -82,7 +82,7 @@
return prelim_signing
def FinalizeAllPropertyFiles(prelim_signing, needed_property_files):
- with zipfile.ZipFile(prelim_signing) as prelim_signing_zip:
+ with zipfile.ZipFile(prelim_signing, allowZip64=True) as prelim_signing_zip:
for property_files in needed_property_files:
metadata.property_files[property_files.name] = property_files.Finalize(
prelim_signing_zip,
@@ -108,7 +108,7 @@
# Replace the METADATA entry.
ZipDelete(prelim_signing, [METADATA_NAME, METADATA_PROTO_NAME])
- output_zip = zipfile.ZipFile(prelim_signing, 'a')
+ output_zip = zipfile.ZipFile(prelim_signing, 'a', allowZip64=True)
WriteMetadata(metadata, output_zip)
ZipClose(output_zip)
@@ -119,7 +119,7 @@
SignOutput(prelim_signing, output_file)
# Reopen the final signed zip to double check the streaming metadata.
- with zipfile.ZipFile(output_file) as output_zip:
+ with zipfile.ZipFile(output_file, allowZip64=True) as output_zip:
for property_files in needed_property_files:
property_files.Verify(
output_zip, metadata.property_files[property_files.name].strip())
@@ -363,7 +363,7 @@
partition_prop_key = "{}.build.prop".format(partition)
input_file = info_dict[partition_prop_key].input_file
if isinstance(input_file, zipfile.ZipFile):
- with zipfile.ZipFile(input_file.filename) as input_zip:
+ with zipfile.ZipFile(input_file.filename, allowZip64=True) as input_zip:
info_dict[partition_prop_key] = \
PartitionBuildProps.FromInputFile(input_zip, partition,
placeholder_values)