#!/usr/bin/env bash # The release's install and uninstall, under Wine's Service Control Manager: copied into # Program Files, registered, started, reachable over its pipe, removed. # # nix shell nixpkgs#wineWow64Packages.stable -c tools/wine-install-test.sh dist/ProxySuite--windows-x64 set -euo pipefail REL=$(realpath "${1:?the unpacked release directory}") WORK=$(mktemp -d) export WINEPREFIX=${WINEPREFIX:-$WORK/prefix} WINEDEBUG=-all trap 'wineserver -k 2>/dev/null || true; rm -rf "$WORK"' EXIT wineboot -i >/dev/null 2>&1 || true for key in Tcpip Tcpip6; do wine reg add "HKLM\\SYSTEM\\CurrentControlSet\\Services\\$key\\Parameters\\Interfaces" /f >/dev/null 2>&1 done cd "$REL" echo "== install" wine ./proxy-suite-service.exe install PF="$WINEPREFIX/drive_c/Program Files/ProxySuite" ls "$PF" | sed 's/^/ /' # Wine's manager often fails the first start right after a create (real Windows does not), # holding the service in a start that times out after ~50 s: install says so; once that is # over, a second start works. for _ in $(seq 40); do st=$(wine sc query ProxySuite 2>/dev/null || true) st=${st//$'\r'/} echo " $(grep STATE <<<"$st" | grep -o '[A-Z_]*$' || true)" grep -q RUNNING <<<"$st" && break grep -q STOPPED <<<"$st" && { wine sc start ProxySuite >/dev/null 2>&1 || true; } sleep 3 done echo "== status over the pipe" for _ in $(seq 30); do wine "$PF/proxy-ctl.exe" status 2>/dev/null && break; sleep 1; done wine "$PF/proxy-ctl.exe" components || { echo "== service log"; tail -30 "$WINEPREFIX/drive_c/ProgramData/ProxySuite/logs/service.log"; exit 1; } echo "== uninstall" wine "$PF/proxy-suite-service.exe" uninstall sleep 5 [ ! -e "$PF/proxy-suite-service.exe" ] && echo "program files removed" || echo "program files still there"