30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Validate and archive the two Windows CLAP deliverables; no Linux output."""
|
|
import hashlib
|
|
from pathlib import Path
|
|
import struct
|
|
import zipfile
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
folder = root / "dist/x86_64-pc-windows-gnu"
|
|
names = [
|
|
"Motif Storyboard.clap", "Resonance Compressor.clap", "LICENSE",
|
|
"motif-storyboard-setup.md", "resonance-compressor-setup.md", "Roboto-OFL.txt", "resonance-editor.png",
|
|
]
|
|
for name in names[:2]:
|
|
data = (folder / name).read_bytes()
|
|
if data[:2] != b"MZ":
|
|
raise SystemExit(f"{name}: expected Windows PE binary")
|
|
offset = struct.unpack_from("<I", data, 0x3C)[0]
|
|
if data[offset:offset + 4] != b"PE\0\0" or struct.unpack_from("<H", data, offset + 4)[0] != 0x8664:
|
|
raise SystemExit(f"{name}: expected x86-64 Windows DLL")
|
|
if b"clap_entry\0" not in data:
|
|
raise SystemExit(f"{name}: CLAP entry export missing")
|
|
checksums = "".join(f"{hashlib.sha256((folder / name).read_bytes()).hexdigest()} {name}\n" for name in names)
|
|
(folder / "SHA256SUMS").write_text(checksums, encoding="utf-8")
|
|
archive = root / "dist/fl-plugins-windows-x86_64.zip"
|
|
with zipfile.ZipFile(archive, "w", compression=zipfile.ZIP_DEFLATED) as output:
|
|
for name in names + ["SHA256SUMS"]:
|
|
output.write(folder / name, arcname=name)
|
|
print(f"Packaged {archive}")
|