Files
praxisandClaude Fable 5.2 cf9ad2ff3c Client interface: addons, login-screen adapters and launcher
66 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

82 lines
4.3 KiB
Python

#!/usr/bin/env python3
"""Stage launcher shortcuts/profiles; never copy clients, secrets or account stores.
Run on each target OS. Windows packaging via PyInstaller is a separate build of
the same UI; only a verified native backend may be marked available in a profile.
"""
import argparse
import hashlib
import json
from pathlib import Path
import shutil
import stat
import sys
def stage(output, runtime, python, character_guid=None, frontend=None):
output, runtime = Path(output).resolve(), Path(runtime).resolve()
if output.exists():
raise ValueError("Choose a new output folder; existing package preserved")
backend = runtime / "ops/forever_launcher_backend.py"
if not backend.is_file():
raise ValueError("Missing installed Linux startup adapter")
if character_guid is not None and (type(character_guid) is not int or not 0 < character_guid < 2**32):
raise ValueError("Invalid local character save guard")
# Resolve the interpreter now. A frozen UI executable cannot run Python
# source by invoking itself; keep this development dependency explicit.
interpreter = shutil.which(python)
if not interpreter:
raise ValueError("Development runtime Python interpreter not found")
binary = Path(frontend).resolve() if frontend else None
if binary and not binary.is_file():
raise ValueError("Packaged GUI executable not found")
output.mkdir(parents=True, mode=0o700)
source = Path(__file__).resolve().parent
if not binary:
shutil.copy2(source / "launcher.py", output / "launcher.py")
if binary:
shutil.copy2(binary, output / binary.name)
profile = dict(schema=1, runtime_root=str(runtime), platforms={
"linux": dict(status="available", backend="ops/forever_launcher_backend.py",
sha256=hashlib.sha256(backend.read_bytes()).hexdigest(), python=interpreter),
"windows": dict(status="blocked-native-runtime-port", backend="bin/ForeverBootstrap.exe")})
if character_guid is not None:
profile["character_guid"] = character_guid
(output / "compat").mkdir()
(output / "compat/launcher.json").write_text(json.dumps(profile, indent=2) + "\n", encoding="utf-8")
# Desktop Exec has its own quoting rules. Avoid a shell and reject control
# characters; escape percent field codes even inside quoted arguments.
def desktop_quote(text):
if any(ord(c) < 32 for c in text):
raise ValueError("Control character in shortcut path")
text = text.replace("%", "%%")
return '"' + text.replace('\\', '\\\\\\\\').replace('"', '\\\\"').replace('`', '\\\\`').replace('$', '\\\\$') + '"'
entry = (str(output / binary.name),) if binary else (interpreter, str(output / "launcher.py"))
desktop = "[Desktop Entry]\nType=Application\nName=WoW-Hybrid Forever\nComment=Start the native Forever compatibility client\nTerminal=false\nExec=" + " ".join(desktop_quote(s) for s in entry) + "\n"
shortcut = output / "WoW-Hybrid Forever.desktop"
shortcut.write_text(desktop, encoding="utf-8")
shortcut.chmod(shortcut.stat().st_mode | stat.S_IXUSR)
# No legacy Octo launcher files/accounts are bundled or modified.
files = [p for p in output.rglob("*") if p.is_file()]
manifest = dict(schema=1, kind="launcher-only-development-package", windows_runtime_available=False,
linux_runtime_dependency=str(runtime), game_files_included=False, credentials_included=False,
fixed_endpoint="play.octowow.st", launcher_interface=False,
files={str(p.relative_to(output)): hashlib.sha256(p.read_bytes()).hexdigest() for p in sorted(files)})
(output / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
return manifest
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--output", required=True, type=Path)
parser.add_argument("--runtime", required=True, type=Path)
parser.add_argument("--python", default=sys.executable)
parser.add_argument("--character-guid", type=int)
parser.add_argument("--frontend", type=Path, help="Prebuilt GUI executable, with its GUI libraries bundled")
args = parser.parse_args()
print(json.dumps(stage(args.output, args.runtime, args.python, args.character_guid, args.frontend), indent=2))
if __name__ == "__main__":
main()