FEX/Scripts/CheckBinfmtNotInstall.sh
Ryan Houdek 84379b5fdf CMake: Check for binfmt_misc conflicts before install
Check for qemu and box binfmt_misc file conflicts before the
`binfmt_misc` install command.

This ensures if you're building from source that you won't inadvertently
install conflicting binfmt_misc files, breaking program execution.
2022-07-01 13:42:45 -07:00

35 lines
845 B
Bash
Executable File

#!/bin/sh
for binfmt in "$@"
do
result=0
if command -v update-binfmts>/dev/null; then
update-binfmts --find "$binfmt" 1>&- 2>&-
if [ $? -eq 0 ]
then
# If we found the binfmt_misc file passed in then error
result=1
fi
fi
if [ $result -eq 0 ]
then
if [ -f "$binfmt" ]; then
# If the binfmt_misc file exists then error
result=1
fi
fi
if [ $result -eq 1 ]
then
echo "==============================================================="
echo "$binfmt binfmt file is installed!"
echo "This conflicts with FEX-Emu's binfmt_misc!"
echo "This will cause issues when running FEX-Emu through binfmt_misc"
echo "Not installing until you uninstall this binfmt_misc file!"
echo "==============================================================="
exit 1
fi
done
exit 0