50 строк · 2 КиБ
tools/env-dump-harness/run-dump.sh
| 1 | #!/usr/bin/env bash |
| 2 | # Chimera-Launcher Phase 0 harness: capture the environment sw_runlib's |
| 3 | # RUN_VULKAN would launch a game with, WITHOUT ever exec'ing wine. |
| 4 | # |
| 5 | # Usage: run-dump.sh <output-file> <exe-path> [exe-args...] |
| 6 | # |
| 7 | # This script is meant to be copied next to a patched StartWine/ tree by |
| 8 | # setup.sh in this directory -- it looks for ./StartWine/data/scripts/ |
| 9 | # relative to its own location. |
| 10 | # |
| 11 | # Safety: |
| 12 | # - Operates on the scratch copy of sw_runlib/sw_function.sh next to this |
| 13 | # script, never on the real ~/Games/StartWine. |
| 14 | # - All other data/ subdirectories (app_config, wine, pfx, pfx_backup, |
| 15 | # tools, app_saves, tmp, runtime, img, Games, Shortcuts) are symlinked |
| 16 | # straight to the real StartWine install (see setup.sh), so app_config |
| 17 | # sourcing, the wine build used, and the prefix touched are all the |
| 18 | # real, currently-in-use ones -- exactly matching a live launch's |
| 19 | # preparation phase (DLL copies etc. do land in the real prefix, same |
| 20 | # as any real launch would do). |
| 21 | # - The patched sw_runlib copy (patch-sw-runlib.py) replaces every |
| 22 | # "${WINELOADER}" ... exec line with an `env | sort` dump + `exit 0`, |
| 23 | # and neutralizes the two other spots that could exec a real wine |
| 24 | # process (sw_win_ver's `winecfg -v`, try_fix_pfx's `wineboot` on an |
| 25 | # uninitialized prefix) into safe no-ops. |
| 26 | set -uo pipefail |
| 27 | |
| 28 | HERE="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)" |
| 29 | OUT="${1:?usage: run-dump.sh <output-file> <exe-path> [exe-args...]}" |
| 30 | shift |
| 31 | |
| 32 | export SW_ENV_DUMP_FILE="$OUT" |
| 33 | export SW_LOCALE="${SW_LOCALE:-ru_RU}" |
| 34 | export PATH="$HERE/stub-bin:$PATH" |
| 35 | |
| 36 | FSH="$HERE/StartWine/data/scripts/sw_function.sh" |
| 37 | |
| 38 | echo "[run-dump] invoking: $FSH $*" >&2 |
| 39 | echo "[run-dump] SW_ENV_DUMP_FILE=$OUT" >&2 |
| 40 | |
| 41 | "$FSH" "$@" |
| 42 | rc=$? |
| 43 | |
| 44 | if [ -f "$OUT" ]; then |
| 45 | echo "[run-dump] OK: dump written ($(wc -l < "$OUT") lines)" >&2 |
| 46 | else |
| 47 | echo "[run-dump] FAILED: no dump file produced (exit code $rc)" >&2 |
| 48 | fi |
| 49 | exit $rc |
| 50 |