Import GingerCal 1.0 source
This commit is contained in:
commit
01f49852ab
116 files changed
+5079
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Minimal zipalign: stored entries start on 4-byte boundaries. Keeps v1 (JAR) signatures valid,
|
||||
since those cover file contents, not the zip layout. usage: zipalign.py in.apk out.apk"""
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
src, dst = sys.argv[1], sys.argv[2]
|
||||
with zipfile.ZipFile(src) as zin, open(dst, "wb") as f:
|
||||
with zipfile.ZipFile(f, "w") as zout:
|
||||
for info in zin.infolist():
|
||||
data = zin.read(info.filename)
|
||||
out = zipfile.ZipInfo(info.filename, info.date_time)
|
||||
out.compress_type = info.compress_type
|
||||
out.external_attr = info.external_attr
|
||||
if info.compress_type == zipfile.ZIP_STORED:
|
||||
header_end = f.tell() + 30 + len(info.filename.encode("utf-8"))
|
||||
out.extra = b"\0" * ((4 - header_end % 4) % 4)
|
||||
zout.writestr(out, data)
|
||||
with zipfile.ZipFile(dst) as z:
|
||||
for info in z.infolist():
|
||||
if info.compress_type == zipfile.ZIP_STORED:
|
||||
start = info.header_offset + 30 + len(info.filename.encode("utf-8")) + len(info.extra)
|
||||
assert start % 4 == 0, info.filename
|
||||
print("aligned", dst)
|
||||
Reference in new issue
Block a user