Skip to content

Instantly share code, notes, and snippets.

@AAGaming00
Forked from Matoking/install_mfplat.sh
Last active May 6, 2022 00:44
Show Gist options
  • Save AAGaming00/692e95643a86dcce47afe38e5819ad58 to your computer and use it in GitHub Desktop.
Save AAGaming00/692e95643a86dcce47afe38e5819ad58 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Simple single-command mfplat installation designed for use with protontricks
# https://github.com/Matoking/protontricks
#
# Licensed under CC0 1.0 Universal:
# https://creativecommons.org/publicdomain/zero/1.0/
PYTHON_INSTALLCAB_PATH="/tmp/mfplat-python-installcab";
INSTALLCAB_PY="python3 $PYTHON_INSTALLCAB_PATH/installcab.py";
WINETRICKS_CACHE_PATH=$(cd ~/.cache/winetricks; pwd);
help() {
echo "Usage:"
echo "install_mfplat.sh <arch> <out>"
echo ""
echo "arch: '32' or '64' depending on game"
echo "out: directory containing the .exe file, relative to the game's installation directory"
exit
}
# Script has two parameters:
# arch -- app architecture (either '32' or '64')
# out -- directory containing the .exe file; this is where the .dll files will be dropped to
ARCH=$1
OUT=$(pwd)"/"$2
if [[ -z $ARCH ]] || [[ -z $OUT ]]; then
help
fi
if [[ $ARCH != "32" ]] && [[ $ARCH != "64" ]]; then
help
fi
if [[ $ARCH == "32" ]]; then
WIN7SP1_EXE="$WINETRICKS_CACHE_PATH/win7sp1/windows6.1-KB976932-X86.exe";
MFPLAT_DLL_URL="https://lutris.net/files/tools/dll/mfplat/x32/mfplat.dll";
else
WIN7SP1_EXE="$WINETRICKS_CACHE_PATH/win7sp1/windows6.1-KB976932-X64.exe";
MFPLAT_DLL_URL="https://lutris.net/files/tools/dll/mfplat/x64/mfplat.dll";
fi
# Clone python-installcab
if [[ ! -d "/tmp/mfplat-python-installcab" ]]; then
echo "python-installcab doesn't exist, cloning the repository...";
git clone https://github.com/tonix64/python-installcab "$PYTHON_INSTALLCAB_PATH";
# chmod +x "$INSTALLCAB_PY";
fi
# Download EXE containing mfplat DLL files with winetricks if it doesn't
# already exist
if [[ ! -e $WIN7SP1_EXE ]]; then
echo "win7sp1 missing, downloading it using winetricks...";
# Use '--force' so installation files are downloaded again if the user deletes them to save space
winetricks --force mf;
fi
# Install components using installcab.py
echo "Installing components using installcab.py...";
$INSTALLCAB_PY "$WIN7SP1_EXE" mediafoundation;
$INSTALLCAB_PY "$WIN7SP1_EXE" mf_;
$INSTALLCAB_PY "$WIN7SP1_EXE" mfreadwrite;
$INSTALLCAB_PY "$WIN7SP1_EXE" wmadmod;
$INSTALLCAB_PY "$WIN7SP1_EXE" wmvdecod;
if [[ $ARCH == "64" ]]; then
$INSTALLCAB_PY "$WIN7SP1_EXE" wmadmod;
fi
# Finally, copy the mfplat.dll into the application directory
echo "Copying mfplat.dll to $OUT";
wget -o "$OUT"/mfplat.dll "$MFPLAT_DLL_URL";
echo "";
echo "All done! You can free disk space by removing the remaining installation files by running the following command:";
echo "$ rm -r $WINETRICKS_CACHE_PATH/win7sp1";
echo "";
echo "You can also leave the files intact to avoid redownloading them again in the future.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment