Allow system images larger than 2GiB.
Python 2.7's zipfile implementation wrongly thinks that zip64 is
required for files larger than 2GiB. We can work around this by
adjusting their limit. Note that `zipfile.writestr()` will not work
for strings larger than 2GiB. The Python interpreter sometimes rejects
strings that large (though it isn't clear to me exactly what
circumstances cause this). `zipfile.write()` must be used directly to
work around this.
This mess can be avoided if we port to python3.
The bug (b/19364241) in original commit has been fixed.
Bug: 18015246
Bug: 19364241
Bug: 19839468
(cherry picked from commit cd082d4bfe917b2e6b97436839cbbbc67c733c83)
Change-Id: I7b5cc310e0a9ba894533b53cb998afd5ce96d8c6
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 4b88e73..a9d4cbe 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -88,11 +88,13 @@
# and all we have to do is copy them to the output zip.
images = os.listdir(images_path)
if images:
- for i in images:
- if bootable_only and i not in ("boot.img", "recovery.img"): continue
- if not i.endswith(".img"): continue
- with open(os.path.join(images_path, i), "r") as f:
- common.ZipWriteStr(output_zip, i, f.read())
+ for image in images:
+ if bootable_only and image not in ("boot.img", "recovery.img"):
+ continue
+ if not image.endswith(".img"):
+ continue
+ common.ZipWrite(
+ output_zip, os.path.join(images_path, image), image)
done = True
if not done: