Skip to content

Instantly share code, notes, and snippets.

@NitroHxC
Created December 16, 2023 21:57
Show Gist options
  • Select an option

  • Save NitroHxC/ff579d57b15f7ba5dcd1429eac13468f to your computer and use it in GitHub Desktop.

Select an option

Save NitroHxC/ff579d57b15f7ba5dcd1429eac13468f to your computer and use it in GitHub Desktop.
Setup & Run git Fork on Arch/Ubuntu
### Prerequisites for Arch:
# sudo pacman -Sy p7zip wine-staging winetricks
# or
# yay p7zip
# yay wine-staging
# yay winetricks
# easy, no? YAYAYAY
#!/bin/bash
## NOTE: I used these commands to run Fork in a Docker container many months ago and it
## worked, then I could VNC into it.
## however it didn't work on my Ubuntu 22.04 Virtual Machine
## I don't want to investigate further because it worked without hassle on Arch :P but let me know if you try!
# Update package lists and install required packages
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y --no-install-recommends \
wget \
curl \
gnupg2 \
software-properties-common \
xvfb \
x11vnc \
winbind \
p7zip-full \
cabextract
# Add Wine repository and install Wine staging
wget -qO - https://dl.winehq.org/wine-builds/winehq.key | apt-key add - && \
apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ jammy main' && \
apt-get update && \
apt-get install -y --install-recommends winehq-staging
# Install Winetricks
wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks && \
chmod +x winetricks && \
mv winetricks /usr/local/bin
#!/bin/bash
# Default Wine prefix
WINEPREFIX_NAME=".winefork"
# Parse arguments for the Wine prefix
while getopts "p:" opt; do
case $opt in
p) WINEPREFIX_NAME=".$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2; exit 1
;;
esac
done
USERNAME=$(whoami)
export WINEPREFIX=~/$WINEPREFIX_NAME
FORK_PATH="$WINEPREFIX/drive_c/users/$USERNAME/AppData/Local/Fork/app-1.92.0"
# Run Fork
if [ -d "$FORK_PATH" ]; then
cd "$FORK_PATH" && WINEPREFIX="$WINEPREFIX" wine Fork.exe
else
echo "Fork directory not found: $FORK_PATH"
exit 1
fi
#!/bin/bash
# Default values
TARGET_FOLDER="Fork"
WINEPREFIX_NAME=".winefork"
print_help() {
echo "Usage: ./setup_fork.sh -t <working_folder> -p <wine_prefix>"
echo ""
echo "For example, "
echo " ./setup_fork.sh -t Fork -p winefork"
echo "will create the '~/.winefork' environment, download and unpack stuff in the folder 'Fork', "
echo "and then copy it to the wine environment in the AppData/Local folder."
}
# Parse arguments
while getopts "t:p:h" opt; do
case $opt in
t) TARGET_FOLDER="$OPTARG"
;;
p) WINEPREFIX_NAME=".$OPTARG"
;;
h) print_help
exit 0
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
esac
done
# Function to download the latest .nupkg file name
get_latest_nupkg() {
curl -s https://fork.dev/update/win/RELEASES | grep -oP 'Fork-\d+\.\d+\.\d+-full\.nupkg' | tail -1
}
# Create target folder
mkdir -p "$TARGET_FOLDER"
cd "$TARGET_FOLDER" || exit
# Download the latest Fork package
NUPKG_FILE=$(get_latest_nupkg)
curl "https://fork.dev/update/win/$NUPKG_FILE" --output fork-full.nupkg
# Extract the .nupkg in place
7z x fork-full.nupkg
# Copy contents to app-x.y.z
VERSION=$(echo "$NUPKG_FILE" | grep -oP '\d+\.\d+\.\d+')
mkdir -p "app-$VERSION"
cp -r lib/net45/* "app-$VERSION/"
# Prepare Wine environment
export WINEPREFIX=~/$WINEPREFIX_NAME
wineboot
winetricks -q dotnet462 # on ubuntu it might prompt to install Wine Mono
winetricks -q corefonts
wineboot
# Copy Fork folder into Wine prefix
USERNAME=$(whoami)
mkdir -p $WINEPREFIX/drive_c/users/$USERNAME/AppData/Local/Fork
cp -r ./ $WINEPREFIX/drive_c/users/$USERNAME/AppData/Local/Fork/
# Inform user how to run Fork
echo "To run Fork, execute:"
echo "cd $WINEPREFIX/drive_c/users/$USERNAME/AppData/Local/Fork/app-$VERSION"
echo "WINEPREFIX=$WINEPREFIX wine Fork.exe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment