import contextlib import hashlib import io import json import multiprocessing import os from pathlib import Path import runpy import shutil import stat import struct import subprocess import sys import tempfile import time import unittest from unittest import mock BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" SYNC = runpy.run_path(str(BIN / "droiddeck-esync")) COMPAT = runpy.run_path(str(BIN / "steam-compatibility")) GLOBALS = SYNC["select"].__globals__ NTDLL = SYNC["NTDLL"] WINESERVER = SYNC["WINESERVER"] COPY = list(SYNC["DEFAULT_COPY"]) REAL_DIRS = SYNC["REAL_DIRS"] RECORD = SYNC["RECORD"] VALVE_LINE = "1789159687 experimental-11.0-20260910b-arm64" GE_LINE = "1789520806 GE-Proton11-7" EXPORTS = ("NtClose", "NtCreateEvent", "wine_server_call") WATCHED = ("WINESERVER", "BL_SYNC_PACK", "WINEESYNC", "PROTON_NO_ESYNC", "BL_SYNC", "CUSTOM") PROTON = ("#!/usr/bin/python3\nimport json, os, sys\n" "print(json.dumps([sys.argv[0], sys.argv[1:], {k: os.environ.get(k) for k in %r}]))\n" % (WATCHED,)) MANIFEST = '"manifest" { "commandline" "/proton %verb%" }' def sha(path): return hashlib.sha256(Path(path).read_bytes()).hexdigest() def elf(exported=(), weak=(), local=(), undefined=(), salt=b""): strings = b"\0" offsets = {} for name in list(exported) + list(weak) + list(local) + list(undefined): if name not in offsets: offsets[name] = len(strings) strings += name.encode() + b"\0" symbols = [bytes(24)] for group, binding, shndx in ((exported, 1, 7), (weak, 2, 7), (local, 0, 7), (undefined, 1, 0)): symbols += [struct.pack("