|
| 1 | +#!/bin/bash |
| 2 | +# This script is used to setup the needed Wine environment |
| 3 | +# so that mgfxc can be run on Linux / macOS systems. |
| 4 | + |
| 5 | +# check dependencies |
| 6 | +if ! type "wine64" > /dev/null 2>&1 |
| 7 | +then |
| 8 | + echo "wine64 not found" |
| 9 | + exit 1 |
| 10 | +fi |
| 11 | + |
| 12 | +if ! type "7z" > /dev/null 2>&1 |
| 13 | +then |
| 14 | + echo "7z not found" |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | + |
| 18 | +# wine 8 is the minimum requirement for dotnet 8 |
| 19 | +# wine --version will output "wine-#.# (Distro #.#.#)" or "wine-#.#" |
| 20 | +WINE_VERSION=$(wine64 --version 2>&1 | grep -o 'wine-.' | sed 's/wine-//') |
| 21 | +if (( $WINE_VERSION < 8 )); then |
| 22 | + echo "Wine version $WINE_VERSION is below the minimum required version (8.0)." |
| 23 | + exit 1 |
| 24 | +fi |
| 25 | + |
| 26 | +# init wine stuff |
| 27 | +export WINEARCH=win64 |
| 28 | +export WINEPREFIX=$HOME/.winemonogame |
| 29 | +wine64 wineboot |
| 30 | + |
| 31 | +TEMP_DIR="${TMPDIR:-/tmp}" |
| 32 | +SCRIPT_DIR="$TEMP_DIR/winemg2" |
| 33 | +mkdir -p "$SCRIPT_DIR" |
| 34 | + |
| 35 | +# disable wine crash dialog |
| 36 | +cat > "$SCRIPT_DIR"/crashdialog.reg <<_EOF_ |
| 37 | +REGEDIT4 |
| 38 | +[HKEY_CURRENT_USER\\Software\\Wine\\WineDbg] |
| 39 | +"ShowCrashDialog"=dword:00000000 |
| 40 | +_EOF_ |
| 41 | + |
| 42 | +pushd $SCRIPT_DIR |
| 43 | +wine64 regedit crashdialog.reg |
| 44 | +popd |
| 45 | + |
| 46 | +# get dotnet |
| 47 | +DOTNET_URL="https://dotnetcli.azureedge.net/dotnet/Sdk/9.0.100-rc.1.24452.12/dotnet-sdk-9.0.100-rc.1.24452.12-win-x64.zip" |
| 48 | +curl $DOTNET_URL --output "$SCRIPT_DIR/dotnet-sdk.zip" |
| 49 | +7z x "$SCRIPT_DIR/dotnet-sdk.zip" -o"$WINEPREFIX/drive_c/windows/system32/" |
| 50 | + |
| 51 | +# get d3dcompiler_47 |
| 52 | +FIREFOX_URL="https://download-installer.cdn.mozilla.net/pub/firefox/releases/62.0.3/win64/ach/Firefox%20Setup%2062.0.3.exe" |
| 53 | +curl $FIREFOX_URL --output "$SCRIPT_DIR/firefox.exe" |
| 54 | +7z x "$SCRIPT_DIR/firefox.exe" -o"$SCRIPT_DIR/firefox_data/" |
| 55 | +cp -f "$SCRIPT_DIR/firefox_data/core/d3dcompiler_47.dll" "$WINEPREFIX/drive_c/windows/system32/d3dcompiler_47.dll" |
| 56 | + |
| 57 | +# append MGFXC_WINE_PATH env variable |
| 58 | +echo -e "\nexport MGFXC_WINE_PATH=$HOME/.winemonogame" >> ~/.profile |
| 59 | +echo -e "\nexport MGFXC_WINE_PATH=$HOME/.winemonogame" >> ~/.zprofile |
| 60 | + |
| 61 | +# cleanup |
| 62 | +rm -rf "$SCRIPT_DIR" |
0 commit comments