Ziran 0.3.1 writes portable bundles as .zx with a ZX header and rejects .zib. Pin Ziran 620c407, Kryon 935d5fc1, Apps 12e52c0 and Entity 86e72720, and build, embed, download, verify and store every bundle as .zx: the root and cell bundles, node apps (the node is asked for format=zx releases), practice packs and the shared Apps controller, now the only trusted one. Practice packs stored by older versions count as installed and update themselves to ZX; a node app's unusable .zib payload is removed so its ZX release installs. Bundle staging starts empty, so no stale bundle is embedded, and Android reads asset names by their length. The generated app codec matches the pinned generator again.
67 lines
2.7 KiB
Python
67 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Enforce shipped size budgets and one shared, architecture-independent package."""
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
import zipfile
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def within(name, size, maximum):
|
|
if size > maximum:
|
|
raise ValueError(f"{name}: {size:,} bytes exceeds {maximum:,}-byte budget")
|
|
|
|
|
|
def check(path, budgets):
|
|
if path.suffix not in (".apk", ".aab"):
|
|
within("Linux binary", path.stat().st_size, budgets["linux_binary_bytes"])
|
|
return f"Linux binary: {path.stat().st_size / 1e6:.2f} MB"
|
|
bundle = path.suffix == ".aab"
|
|
prefix = "base/" if bundle else ""
|
|
with zipfile.ZipFile(path) as archive:
|
|
files = archive.infolist()
|
|
package_path = prefix + "assets/inbe.zx"
|
|
packages = [entry for entry in files if entry.filename.endswith("/inbe.zx")]
|
|
if len(packages) != 1 or packages[0].filename != package_path:
|
|
raise ValueError("Expected exactly one shared assets/inbe.zx")
|
|
package = packages[0]
|
|
within("Portable app package", package.file_size, budgets["app_package_bytes"])
|
|
controllers = [entry for entry in files if entry.filename.endswith("/apps.zx")]
|
|
if len(controllers) != 1 or controllers[0].filename != prefix + "assets/apps.zx":
|
|
raise ValueError("Expected exactly one shared assets/apps.zx controller")
|
|
libraries = [entry for entry in files
|
|
if entry.filename.startswith(prefix + "lib/")
|
|
and entry.filename.endswith("/libmain.so")]
|
|
if not libraries:
|
|
raise ValueError("Missing native application libraries")
|
|
if bundle:
|
|
size = sum(entry.compress_size for entry in files
|
|
if entry.filename.startswith("base/"))
|
|
within("Delivered bundle payload", size, budgets["bundle_payload_bytes"])
|
|
else:
|
|
size = path.stat().st_size
|
|
key = "apk_universal_bytes" if len(libraries) > 1 else "apk_single_abi_bytes"
|
|
within("APK", size, budgets[key])
|
|
return (f"{path.name}: {size / 1e6:.2f} MB; {len(libraries)} ABI(s); "
|
|
f"one shared package ({package.file_size / 1e6:.2f} MB unpacked)")
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("artifacts", type=Path, nargs="+")
|
|
args = parser.parse_args()
|
|
budgets = json.loads((ROOT / "packaging/size-budgets.json").read_text())
|
|
try:
|
|
for path in args.artifacts:
|
|
print("PASS " + check(path, budgets))
|
|
except (OSError, ValueError, zipfile.BadZipFile) as error:
|
|
print(f"FAIL package size: {error}", file=sys.stderr)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|