Last active
August 28, 2025 19:26
-
-
Save tvidal-net/f2cbabfc903193af502b8e1df3299620 to your computer and use it in GitHub Desktop.
Installation Script for Gentlemen of the Row
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zsh | |
| autoload -U colors | |
| colors | |
| RED=${fg_bold[red]} RST=$reset_color | |
| # argument parse | |
| set -eo pipefail -o extendedglob | |
| zparseopts -D -K -a ARGS -- v n || exit $? | |
| [ "${ARGS[(r)-v]}" ] && set -x | |
| function die () { | |
| print -u2 "${RED}ERROR$RST:" | |
| print -u2 - $* | |
| exit 1 | |
| } | |
| # find Proton - Experimental | |
| for STEAMDIR in /run/media/*(/N) ~/.local/share | |
| do | |
| STEAMAPPS=( $STEAMDIR/Steam/steamapps(/N) ) | |
| [ "$STEAMAPPS" ] || continue | |
| WINESERVER=( $STEAMAPPS/common/Proton\ -\ Ex*/**/bin/wineserver(*om[1]N) ) | |
| [ "$WINESERVER" ] && break | |
| done | |
| # fine wine resources under proton | |
| WINELOADER=( ${WINESERVER:h}/wine(*) ) | |
| WINEVERFILE=( ${WINELOADER:h:h:h}/version(.) ) | |
| WINEVERPATH=( ${WINEVERFILE:h}(/) ) | |
| KERNEL32=( $WINEVERPATH/**/(i386-windows)#/kernel32.dll(.[1]) ) | |
| WINEDLLPATH=( ${KERNEL32:h}(/) ) | |
| PROTONLIB=( $WINEVERPATH/**/lib(/[1]) ) | |
| LD_LIBRARY_PATH="$PROTONLIB${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" | |
| # setup proton environment variables | |
| for name in WINEVERPATH WINESERVER WINELOADER WINEDLLPATH LD_LIBRARY_PATH | |
| do | |
| print -v $name - ${(P)name} | |
| export $name | |
| done | |
| # find Saints Row 2 installation | |
| integer SRPID=9480 | |
| unset SRDIR WINEPREFIX | |
| print "\nLooking for Saints Row 2 installation directory..." | |
| for STEAMDIR in /run/media/*(/N) ~/.local/share | |
| do | |
| STEAMAPPS=( $STEAMDIR/Steam/steamapps(/N) ) | |
| [ "$STEAMAPPS" ] || continue | |
| [ "$SREXE" ] || SREXE=( $STEAMAPPS/common/*/SR2*.exe(.N) ) | |
| [ "$WINEPREFIX" ] || WINEPREFIX=( $STEAMAPPS/compatdata/$SRPID/pfx(/N) ) | |
| done | |
| [ "$SREXE" ] || die "- Unable to find the Saints Row 2 installation directory..." | |
| [ "$WINEPREFIX" ] || die "- Unable to find the Saints Row 2 prefix.\n- You need to run the game at least once to create it." | |
| SRDIR=${SREXE:h} | |
| print -v WINEPREFIX - $WINEPREFIX | |
| export WINEPREFIX | |
| print - "- Install: $SRDIR" | |
| print - "- Prefix: $WINEPREFIX" | |
| print "\nLooking for Gentleman of the Row under the current directory..." | |
| GOTRDOWNLOAD=( ~/Download*/Gentlemen_of_the_Row*(om[1]N) ) | |
| GOTRBAT=( ./**/Create_Custom_GotR_*.bat(om[1]N) ) | |
| if [ -z "$GOTRBAT" -a -r "$GOTRDOWNLOAD" ] | |
| then | |
| print -u2 - "Found downloaded GotR @ $GOTRDOWNLOAD, extracting..." | |
| 7z x -y $GOTRDOWNLOAD || exit $? | |
| fi | |
| GOTRBAT=( ./**/Create_Custom_GotR_*.bat(om[1]) ) | |
| GOTR=( ${GOTRBAT:h} ) | |
| print - "- GotR: $GOTR" | |
| if [ "${ARGS[(r)-n]}" ] | |
| then | |
| print "\nDRY_RUN: Would execute the following commands:" | |
| print -r "cd ${(q)GOTR}" | |
| export -p WINEVERPATH WINESERVER WINELOADER WINEDLLPATH WINEPREFIX LD_LIBRARY_PATH | |
| print -r "${(q)WINELOADER} ${(q)GOTRBAT}" | |
| print -r "cp ${(q)GOTR}/MY_CUSTOM_PATCH/* ${(q)SRDIR}" | |
| else | |
| export WINEDEBUG='trace-all,fixme-all' | |
| { | |
| ( cd $GOTR; $WINELOADER ${GOTRBAT:t} ) | |
| } always { | |
| $WINESERVER -w | |
| } | |
| FILES=( $GOTR/MY_CUSTOM_PATCH/*(.N) ) | |
| if [ "$FILES" ] | |
| then | |
| BACKUP="BACKUP_$(date '+%Y-%m-%dT%H:%M:%S')" | |
| print "\n\nCreating backup of patch files @ $GOTR/$BACKUP" | |
| mkdir -vp "$GOTR/$BACKUP" | |
| FILENAMES=( ${FILES:t} ) | |
| cp -v "$SRDIR/${=^FILENAMES}" "$GOTR/$BACKUP" | |
| print "\nInstalling patch files to game installation directory..." | |
| cp -vf $FILES $SRDIR | |
| fi | |
| print "\nDone." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment