37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Package the offline cover zips into a single distributable bundle.
|
|
|
|
Outputs ``psppt-covers.zip`` containing ``libretro-covers.zip`` and
|
|
``openvgdb-covers.zip``. Attach it to the Gitea ``covers`` release; the app
|
|
downloads it on first run when the user opts in.
|
|
|
|
Usage: python3 scripts/make-covers-bundle.py [out-path]
|
|
"""
|
|
import sys
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
COVERS = ROOT / "data" / "covers"
|
|
INNER = ("libretro-covers.zip", "openvgdb-covers.zip")
|
|
|
|
|
|
def main(argv):
|
|
out = Path(argv[1]) if len(argv) > 1 else ROOT / "psppt-covers.zip"
|
|
missing = [n for n in INNER if not (COVERS / n).exists()]
|
|
if missing:
|
|
print(f"missing: {', '.join(missing)} in {COVERS}", file=sys.stderr)
|
|
return 2
|
|
# Inner zips are already compressed; store them to avoid recompressing.
|
|
with zipfile.ZipFile(out, "w", zipfile.ZIP_STORED) as z:
|
|
for n in INNER:
|
|
print(f"adding {n} …")
|
|
z.write(COVERS / n, arcname=n)
|
|
size = out.stat().st_size / (1 << 20)
|
|
print(f"wrote {out} ({size:.0f} MB)")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main(sys.argv))
|