Fix the read on a closed zipfile
When calculating the dynamic fingerprints, we need to reopen the
input file if it's a ZipFile. Because the original object has been
closed.
Bug: 152167826
Test: generate an OTA package with zip input and overrides
Change-Id: I623da3cc5fcc91c6230fb5a6e86517ed995913b7
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index b753414..3b68439 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -2012,9 +2012,16 @@
info_dict = copy.deepcopy(build_info.info_dict)
for partition in common.PARTITIONS_WITH_CARE_MAP:
partition_prop_key = "{}.build.prop".format(partition)
- old_props = info_dict[partition_prop_key]
- info_dict[partition_prop_key] = common.PartitionBuildProps.FromInputFile(
- old_props.input_file, partition, placeholder_values)
+ input_file = info_dict[partition_prop_key].input_file
+ if isinstance(input_file, zipfile.ZipFile):
+ with zipfile.ZipFile(input_file.filename) as input_zip:
+ info_dict[partition_prop_key] = \
+ common.PartitionBuildProps.FromInputFile(input_zip, partition,
+ placeholder_values)
+ else:
+ info_dict[partition_prop_key] = \
+ common.PartitionBuildProps.FromInputFile(input_file, partition,
+ placeholder_values)
info_dict["build.prop"] = info_dict["system.build.prop"]
new_build_info = common.BuildInfo(info_dict, build_info.oem_dicts)