Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

3.2 KB
Raw Blame
#!/usr/bin/env bash
# Install the Windows Steam client and its verified rendering components.
#
# Steam uses upstream Wine 11 plus the steamwebhelper wrapper and DXMT.
# New installs use a checksum-pinned private runtime; legacy Wine apps are kept.
set -euo pipefail

BASE="${SOJU_BASE:-$HOME/.battlenet-macos}"
export WINEPREFIX="${WINEPREFIX:-$BASE/steam-bottle}"
WORK="${WORK:-$BASE/build}"; mkdir -p "$WORK"
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
source "$REPO_ROOT/scripts/steam-runtime.sh"
# ---------- 1. Pinned upstream Wine ----------
python3 - "$REPO_ROOT/resources/steam-support.json" <<'PYVERSION'
import json, platform, sys
m=json.load(open(sys.argv[1]))
version=lambda s: tuple(map(int,s.split('.')))
if version(platform.mac_ver()[0]) < version(m['minimum_macos']):
    sys.exit('Steam game support requires macOS '+m['minimum_macos']+' or later.')
PYVERSION
unset DYLD_FALLBACK_LIBRARY_PATH WINEDLLOVERRIDES WINEMSYNC ROSETTA_ADVERTISE_AVX
unset CX_ACTIVE_GRAPHICS_BACKEND CX_GRAPHICS_BACKEND CX_APPLEGPTK_LIBD3DSHARED_PATH WINE_SIMULATE_WRITECOPY
soju_ensure_steam_runtime "$REPO_ROOT"
WINE="$STEAM_WINE_ROOT/bin/wine"
"$WINE" --version

# ---------- 2. Verified wrapper and rendering components ----------
python3 "$REPO_ROOT/scripts/fetch-steam-support.py"
python3 "$REPO_ROOT/scripts/steam-session.py" idle "$STEAM_WINE_ROOT"
if [ -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe" ]; then
  python3 "$REPO_ROOT/scripts/bootstrap-steam.py" "$WINE"
  echo "Steam already installed."
  exit 0
fi

# ---------- 3. Prefix + Steam install ----------
echo "==> Initializing the prefix: $WINEPREFIX"
"$WINE" wineboot -u >/dev/null 2>&1 || true
"$STEAM_WINE_ROOT/bin/wineserver" -w 2>/dev/null || true

SETUP="$WORK/SteamSetup.exe"
[ -f "$SETUP" ] || { curl -fL "https://cdn.cloudflare.steamstatic.com/client/installer/SteamSetup.exe" -o "$SETUP.part" && mv -f "$SETUP.part" "$SETUP"; }
echo "==> Installing Steam silently"
LOG="$BASE/logs/steam-install.log"; mkdir -p "$BASE/logs"
{ echo "== $(date) macOS $(sw_vers -productVersion 2>/dev/null) $(uname -m) Rosetta: $(/usr/bin/arch -x86_64 /usr/bin/true 2>/dev/null && echo yes || echo no)"
  echo "== installer $(shasum -a 256 "$SETUP" | cut -c1-16) $(stat -f%z "$SETUP") bytes"; } > "$LOG"
WINEDEBUG=err+all "$WINE" "$SETUP" /S >>"$LOG" 2>&1 || echo "== installer exit $?" >>"$LOG"
"$STEAM_WINE_ROOT/bin/wineserver" -w 2>/dev/null || true
if [ ! -f "$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe" ]; then
  # A cut-off download is the usual cause: fetch the installer again on the next try.
  rm -f "$SETUP"
  echo "Install failed. The installer's output is in $LOG; these are its last lines:"
  tail -n 15 "$LOG" | sed 's/^/    /'
  echo "Press Install again to retry with a fresh download. If it fails the same way, post $LOG on Discord or GitHub."
  exit 1
fi

# ---------- 4. Full client before configuring the renderer ----------
python3 "$REPO_ROOT/scripts/bootstrap-steam.py" "$WINE"

# ---------- 5. Finish ----------
cp -f /etc/ssl/cert.pem "$WINEPREFIX/drive_c/windows/cacert.pem" 2>/dev/null || true
echo "==> Done. Run: scripts/play.sh steam  (play.sh deploys the wrapper automatically)"
echo "    If typed text shows up as ??, switch the macOS input source to English (ABC)."