android 5.x system.img 大于2G导致编译otapackage时报错怎样处理

当system分区预制过多apk时假设img size超过2G 在make otapackage时会报例如以下错误
 zipfile.LargeZipFile: Zipfile size would require ZIP64 extensions
in writestr zinfo.CRC = crc32(bytes) & 0xffffffff # CRC-32 checksum OverflowError: size does not fit in an int

//http://blog.csdn.net/sergeycao

这是因为python 2.7 脚本限制
參考/prebuilts/python/linux-x86/2.7.5/lib/python2.7/
ZIP64_LIMIT = (1 << 31) - 1       (31bits相当于2G)
 
python 3.0+ 已提供solution,  但眼下Android 编译环境使用2.x 语法与 3.0不兼容
对此google提供一个workaround solution
參考下面网址有提供具体patch内容
https://android-review.googlesource.com/#/c/142984 
(但此方法占时提高write size 到32bits相当于4G, 假设超过4G仍会出现故障)
 
另外还需改动一下脚本  build/tool/releasetools/
1、sign_target_files_apks
2、replace_img_from_target_files.py 
3、ota_from_target_files
4、img_from_target_files.py 
5 、img_from_target_files
6、common.py 
7、add_img_to_target_files
针对全部zipfile.ZipFile  加入最后 allowZip64=True 參数值
ex:
原始文件:
output_zip = zipfile.ZipFile(filename, "a", compression=zipfile.ZIP_DEFLATED) 
改动为:
output_zip = zipfile.ZipFile(filename, "a", compression=zipfile.ZIP_DEFLATED, allowZip64=True)