#!/usr/bin/env bash set -euo pipefail # Bannerlord Runtime Setup — Apple Silicon # Issue #720: Stand up a local Windows game runtime for Bannerlord on Apple Silicon # # Chosen runtime: Whisky (Apple Game Porting Toolkit wrapper) # # Usage: ./scripts/bannerlord_runtime_setup.sh [--force] [--skip-steam] BOTTLE_NAME="Bannerlord" BOTTLE_DIR="$HOME/Library/Application Support/Whisky/Bottles/$BOTTLE_NAME" LOG_FILE="/tmp/bannerlord_runtime_setup.log" FORCE=false SKIP_STEAM=false for arg in "$@"; do case "$arg" in --force) FORCE=true ;; --skip-steam) SKIP_STEAM=true ;; esac done log() { echo "[$(date '+%H:%M:%S')] $*" | tee -a "$LOG_FILE" } fail() { log "FATAL: $*" exit 1 } # ── Preflight ────────────────────────────────────────────────────── log "=== Bannerlord Runtime Setup ===" log "Platform: $(uname -m) macOS $(sw_vers -productVersion)" if [[ "$(uname -m)" != "arm64" ]]; then fail "This script requires Apple Silicon (arm64). Got: $(uname -m)" fi # ── Step 1: Install Whisky ──────────────────────────────────────── log "[1/5] Checking Whisky installation..." if [[ -d "/Applications/Whisky.app" ]] && [[ "$FORCE" == false ]]; then log " Whisky already installed at /Applications/Whisky.app" else log " Installing Whisky via Homebrew cask..." if ! command -v brew &>/dev/null; then fail "Homebrew not found. Install from https://brew.sh" fi brew install --cask whisky 2>&1 | tee -a "$LOG_FILE" log " Whisky installed." fi # ── Step 2: Create Bottle ───────────────────────────────────────── log "[2/5] Checking Bannerlord bottle..." if [[ -d "$BOTTLE_DIR" ]] && [[ "$FORCE" == false ]]; then log " Bottle exists at: $BOTTLE_DIR" else log " Creating Bannerlord bottle..." # Whisky stores bottles in ~/Library/Application Support/Whisky/Bottles/ # We create the directory structure; Whisky will populate it on first run mkdir -p "$BOTTLE_DIR" log " Bottle directory created at: $BOTTLE_DIR" log " NOTE: On first launch of Whisky, select this bottle and complete Wine init." log " Open Whisky.app, create bottle named '$BOTTLE_NAME', Windows 10." fi # ── Step 3: Verify Whisky CLI ───────────────────────────────────── log "[3/5] Verifying Whisky CLI access..." WHISKY_APP="/Applications/Whisky.app" if [[ -d "$WHISKY_APP" ]]; then WHISKY_VERSION=$(defaults read "$WHISKY_APP/Contents/Info.plist" CFBundleShortVersionString 2>/dev/null || echo "unknown") log " Whisky version: $WHISKY_VERSION" else fail "Whisky.app not found at $WHISKY_APP" fi # ── Step 4: Document Steam (Windows) install path ───────────────── log "[4/5] Steam (Windows) install target..." STEAM_WIN_PATH="$BOTTLE_DIR/drive_c/Program Files (x86)/Steam/Steam.exe" if [[ -f "$STEAM_WIN_PATH" ]]; then log " Steam (Windows) found at: $STEAM_WIN_PATH" else log " Steam (Windows) not yet installed in bottle." log " After opening Whisky:" log " 1. Select the '$BOTTLE_NAME' bottle" log " 2. Run the Steam Windows installer (download from store.steampowered.com)" log " 3. Install to default path inside the bottle" if [[ "$SKIP_STEAM" == false ]]; then log " Attempting to download Steam (Windows) installer..." STEAM_INSTALLER="/tmp/SteamSetup.exe" if [[ ! -f "$STEAM_INSTALLER" ]]; then curl -L -o "$STEAM_INSTALLER" "https://cdn.akamai.steamstatic.com/client/installer/SteamSetup.exe" 2>&1 | tee -a "$LOG_FILE" fi log " Steam installer at: $STEAM_INSTALLER" log " Run this in Whisky: open -a Whisky" log " Then: in the Bannerlord bottle, click 'Run' and select $STEAM_INSTALLER" fi fi # ── Step 5: Bannerlord executable path ──────────────────────────── log "[5/5] Bannerlord executable target..." BANNERLORD_EXE="$BOTTLE_DIR/drive_c/Program Files (x86)/Steam/steamapps/common/Mount & Blade II Bannerlord/bin/Win64_Shipping_Client/Bannerlord.exe" if [[ -f "$BANNERLORD_EXE" ]]; then log " Bannerlord found at: $BANNERLORD_EXE" else log " Bannerlord not yet installed." log " Install via Steam (Windows) inside the Whisky bottle." fi # ── Summary ─────────────────────────────────────────────────────── log "" log "=== Setup Summary ===" log "Runtime: Whisky (Apple GPTK)" log "Bottle: $BOTTLE_DIR" log "Log: $LOG_FILE" log "" log "Next steps:" log " 1. Open Whisky: open -a Whisky" log " 2. Create/select '$BOTTLE_NAME' bottle (Windows 10)" log " 3. Install Steam (Windows) in the bottle" log " 4. Install Bannerlord via Steam" log " 5. Enable D3DMetal in bottle settings" log " 6. Run verification: ./scripts/bannerlord_verify_runtime.sh" log "" log "=== Done ==="