install.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/usr/bin/env bash
  2. # Installer for the Embarrassed Shina-chan Linux/Proton fix pack.
  3. #
  4. # Modifies only files inside the game folder and the game's Proton prefix; no
  5. # game binaries ship with this repo. Every modified file is backed up
  6. # (*.orig / user.reg.bak-*) so uninstall.sh can revert.
  7. #
  8. # Usage:
  9. # ./install.sh [/path/to/steamapps/common/Embarrassed Shina-chan~ .../]
  10. # If no path is given it tries common Steam library locations.
  11. set -euo pipefail
  12. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  13. APPID=2326780
  14. find_game() {
  15. local c
  16. for c in \
  17. "$HOME/.steam/steam/steamapps/common/Embarrassed Shina-chan~ the Naked Wandering College Girl" \
  18. "$HOME/.local/share/Steam/steamapps/common/Embarrassed Shina-chan~ the Naked Wandering College Girl"; do
  19. [ -f "$c/data/kmyCore.dll" ] && { echo "$c"; return 0; }
  20. done
  21. # scan libraryfolders.vdf for extra libraries
  22. local vdf="$HOME/.steam/steam/steamapps/libraryfolders.vdf"
  23. [ -f "$vdf" ] || vdf="$HOME/.local/share/Steam/steamapps/libraryfolders.vdf"
  24. if [ -f "$vdf" ]; then
  25. local lib g
  26. while IFS= read -r lib; do
  27. g="$lib/steamapps/common/Embarrassed Shina-chan~ the Naked Wandering College Girl"
  28. [ -f "$g/data/kmyCore.dll" ] && { echo "$g"; return 0; }
  29. done < <(grep -oE '"path"[[:space:]]*"[^"]+"' "$vdf" | sed -E 's/.*"([^"]+)"$/\1/')
  30. fi
  31. return 1
  32. }
  33. GAME_ROOT="${1:-$(find_game || true)}"
  34. if [ -z "${GAME_ROOT:-}" ] || [ ! -f "$GAME_ROOT/data/kmyCore.dll" ]; then
  35. echo "!! Could not locate the game. Pass its folder explicitly:"
  36. echo " ./install.sh \"/path/to/steamapps/common/Embarrassed Shina-chan~ the Naked Wandering College Girl\""
  37. exit 1
  38. fi
  39. echo "Game folder: $GAME_ROOT"
  40. echo
  41. # check every required tool up front so the install never stops halfway through.
  42. # all of these are needed for a working game: gcc builds the runtime hook, and
  43. # dotnet builds the IL patcher for the plugin-path fix, without which no asset
  44. # plugins load and the game stays a grey screen.
  45. missing=""
  46. for tool in gcc patch od dd md5sum dotnet; do
  47. command -v "$tool" >/dev/null 2>&1 || missing="$missing $tool"
  48. done
  49. if [ -n "$missing" ]; then
  50. echo "!! missing required tools:$missing"
  51. echo " gcc - builds the runtime hook (fix 4)"
  52. echo " patch/od/dd/md5sum - apply and verify the byte/shader patches (fixes 1-3)"
  53. echo " dotnet - the .NET SDK, builds the IL patcher for the plugin-path"
  54. echo " fix (fix 2); needs network access once to fetch Mono.Cecil"
  55. exit 1
  56. fi
  57. command -v python3 >/dev/null 2>&1 || \
  58. echo " note: python3 not found, only needed for the optional Wayland fix 5"
  59. # LD_PRELOAD treats colons and spaces as separators, so a repo path containing
  60. # them would silently break the runtime hook
  61. case "$HERE" in
  62. *' '*|*:*)
  63. echo "!! this repo's path contains a space or ':', which LD_PRELOAD cannot handle."
  64. echo " Move the repo, e.g.: mv \"$HERE\" ~/shina-linux-patch and re-run."
  65. exit 1;;
  66. esac
  67. echo "[1/5] kmyCore disk-FS"
  68. bash "$HERE/patches/01-kmycore-diskfs.sh" "$GAME_ROOT"
  69. echo "[2/5] bakinplayer plugin path"
  70. bash "$HERE/patches/02-pluginpath/apply.sh" "$GAME_ROOT"
  71. echo "[3/5] shader vin_* keep-alive"
  72. SH="$GAME_ROOT/data/lib/sysresource/shader/include/v2_vpcommon.cgh"
  73. SHPATCH="$HERE/patches/03-shader-vin-keepalive.patch"
  74. if grep -q "VIN_KEEPALIVE" "$SH"; then
  75. echo "== Fix 3: already applied"
  76. else
  77. # dry-run first; a partially applied patch would leave every shader
  78. # referencing an undefined VIN_KEEPALIVE
  79. if ! patch -p1 -d "$GAME_ROOT" -s -f --dry-run < "$SHPATCH" >/dev/null 2>&1; then
  80. echo "!! Fix 3: shader source does not match this patch (different game build?)."
  81. echo "!! Not touching it. v2_vpcommon.cgh left unmodified."
  82. exit 3
  83. fi
  84. [ -f "$SH.orig" ] || cp "$SH" "$SH.orig"
  85. patch -p1 -d "$GAME_ROOT" -s -f < "$SHPATCH"
  86. echo "== Fix 3: shader patched, backup at v2_vpcommon.cgh.orig"
  87. fi
  88. echo "[4/5] runtime hook (VAO fix + audio-deadlock cap + IBL LUT)"
  89. HOOKDIR="$HERE/patches/04-runtime-hook"
  90. IBL_SRC="$HOOKDIR/ibl_brdf_lut.bmp"
  91. # the game's per-launch shader/texture extraction lives in the Proton prefix:
  92. TMPBASE="$(cd "$GAME_ROOT/../.." && pwd)/compatdata/$APPID/pfx/drive_c/users/steamuser/AppData/Local/Temp/bakin_engine_tmp"
  93. # both paths end up inside C string literals, so refuse characters that break them
  94. for p in "$IBL_SRC" "$TMPBASE"; do
  95. case "$p" in
  96. *'"'*|*'\'*) echo "!! cannot embed a path containing \" or \\ into the hook: $p"; exit 1;;
  97. esac
  98. done
  99. sed_esc() { printf '%s' "$1" | sed 's/[&|]/\\&/g'; }
  100. sed -e "s|@IBL_SRC@|$(sed_esc "$IBL_SRC")|g" -e "s|@TMPBASE@|$(sed_esc "$TMPBASE")|g" \
  101. "$HOOKDIR/bakin_minimal.c" > "$HOOKDIR/bakin_minimal.installed.c"
  102. gcc -O2 -shared -fPIC -o "$HOOKDIR/bakin_minimal.so" "$HOOKDIR/bakin_minimal.installed.c" -ldl -lpthread
  103. echo "== built $HOOKDIR/bakin_minimal.so"
  104. echo "[5/5] launcher"
  105. HOOK_SO="$HOOKDIR/bakin_minimal.so"
  106. LAUNCHER="$HERE/launcher.installed.sh"
  107. sed "s|@HOOK_SO@|$(sed_esc "$HOOK_SO")|g" "$HERE/launcher.sh" > "$LAUNCHER"
  108. chmod +x "$LAUNCHER"
  109. echo
  110. echo "======================================================================"
  111. echo "Done. Two manual steps remain:"
  112. echo
  113. echo "1) Steam -> Embarrassed Shina-chan -> Properties -> Launch Options:"
  114. echo " \"$LAUNCHER\" %command%"
  115. echo
  116. echo "2) Wayland desktops only (keyboard focus). Fully close the game, then:"
  117. echo " bash \"$HERE/patches/05-wayland-keyboard.sh\" \"$GAME_ROOT\""
  118. echo " (harmless to skip on X11.)"
  119. echo
  120. echo "Then launch from Steam. To revert everything: ./uninstall.sh \"$GAME_ROOT\""
  121. echo "======================================================================"