Project Chimera
Меню

Исходники

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.
26set -uo pipefail
27
28HERE="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)"
29OUT="${1:?usage: run-dump.sh <output-file> <exe-path> [exe-args...]}"
30shift
31
32export SW_ENV_DUMP_FILE="$OUT"
33export SW_LOCALE="${SW_LOCALE:-ru_RU}"
34export PATH="$HERE/stub-bin:$PATH"
35
36FSH="$HERE/StartWine/data/scripts/sw_function.sh"
37
38echo "[run-dump] invoking: $FSH $*" >&2
39echo "[run-dump] SW_ENV_DUMP_FILE=$OUT" >&2
40
41"$FSH" "$@"
42rc=$?
43
44if [ -f "$OUT" ]; then
45 echo "[run-dump] OK: dump written ($(wc -l < "$OUT") lines)" >&2
46else
47 echo "[run-dump] FAILED: no dump file produced (exit code $rc)" >&2
48fi
49exit $rc
50