| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #!/usr/bin/env python3
- """Package the current Windows Qt dev build, verifying original UI bytes."""
- import argparse
- import hashlib
- import json
- from pathlib import Path
- import struct
- import zipfile
- VERSION = "0.8.1.4"
- UI_HASHES = {
- "src/mainwindow.ui": "e2ed5a4aaadf0d089eab4e4b6791357423482c2adb9ef7c8c7a01f0b1caddabd",
- "src/style/app.qss": "b4774ac879b64a07fbb361c5e763e0355ed4cb0051e37c412bec38dcbcba8558",
- "src/3rdparty/qcustomplot/qcustomplot.cpp": "364c095b6c1baeda33c43c44d19d15fae011319e3990985c7ac29e26d6ac8ef8",
- "src/3rdparty/qcustomplot/qcustomplot.h": "920646e8db6406a568bed52a121db6498a2c507a687400f3a559e3d840f1888c",
- "src/3rdparty/qcustomplot/GPL.txt": "8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903",
- "src/resources.qrc": "91cd09e348aa59d0b41e2fb98be51a8fda05df311071b79d0c9ff14c7ea6abe9",
- "src/assets/logo-mark.png": "0906929e64e241e08f4de4d1726ce11ea3241dc9f5e60d41096309b817ef043f",
- }
- def digest(path):
- return hashlib.sha256(path.read_bytes()).hexdigest()
- def main():
- parser = argparse.ArgumentParser()
- parser.add_argument("--release", type=Path, required=True)
- release = parser.parse_args().release
- source = release / "_build-src" / "qt-client"
- app = release / "app"
- ui_results = {file: {"actual": digest(source / file), "expected": sha}
- for file, sha in UI_HASHES.items()}
- checks = {
- "ui_unchanged": all(row["actual"] == row["expected"] for row in ui_results.values()),
- "version_current": f'setApplicationVersion(QStringLiteral("{VERSION}"))' in
- (source / "src/main.cpp").read_text(encoding="utf-8"),
- "qt_clean_endpoint": json.loads((app / "config.json").read_text(encoding="utf-8"))
- .get("backend", {}).get("url") ==
- "ws://192.168.2.79:8080/ws?view=qt-clean",
- "runtime_dlls": all((app / dll).is_file() for dll in (
- "Qt5Core.dll", "Qt5Gui.dll", "Qt5Widgets.dll", "Qt5WebSockets.dll",
- "libgcc_s_seh-1.dll", "libstdc++-6.dll", "libwinpthread-1.dll")),
- }
- binaries = {}
- for name, expected_subsystem in (("DDR5_SLT_Monitor.exe", 2), ("QtCleanProbe.exe", 3)):
- path = app / name
- data = path.read_bytes()
- pointer = struct.unpack_from("<I", data, 0x3C)[0]
- machine = struct.unpack_from("<H", data, pointer + 4)[0]
- subsystem = struct.unpack_from("<H", data, pointer + 24 + 68)[0]
- checks[name] = machine == 0x8664 and subsystem == expected_subsystem
- binaries[name] = {"bytes": len(data), "sha256": digest(path)}
- if not all(checks.values()):
- print(json.dumps({"passed": False, "checks": checks, "ui_mismatches":
- {file: row for file, row in ui_results.items() if row["actual"] != row["expected"]}},
- ensure_ascii=False))
- raise SystemExit(1)
- archive = release / f"XJKJ-STL-Qt-Clean-Windows-x64-{VERSION}.zip"
- with zipfile.ZipFile(archive, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as target:
- for path in sorted(app.rglob("*")):
- if path.is_file():
- target.write(path, path.relative_to(release))
- print(json.dumps({"passed": True, "checks": checks, "ui_files_checked": len(UI_HASHES),
- "binaries": binaries, "archive": str(archive), "archive_bytes": archive.stat().st_size,
- "archive_sha256": digest(archive)}, ensure_ascii=False, indent=2))
- if __name__ == "__main__":
- main()
|