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.

Bug: 18015246
Change-Id: I8a476d99c5efdef6ea408373b706e9fbd3a798be
This commit is contained in:
Dan Albert
2015-01-27 15:53:15 -08:00
parent 7245b4e2be
commit cd082d4bfe
5 changed files with 173 additions and 33 deletions

View File

@@ -88,11 +88,13 @@ def main(argv):
# 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: