Neither doas nor sudo exist there and id -u never reports root, so install/uninstall always hit the no-root error. IS_WIN is now computed once alongside MK_FILE and reused for the priv check.
47 lines
912 B
Bash
Executable File
47 lines
912 B
Bash
Executable File
#!/bin/sh
|
|
|
|
UNAME_S=$(uname -s)
|
|
export UNAME_S
|
|
|
|
OS=$(echo "$UNAME_S" | tr '[:upper:]' '[:lower:]')
|
|
|
|
case "$OS" in
|
|
linux|mingw*|msys*|ucrt*|clang*) MK_FILE="gmake.mk" ;;
|
|
*) MK_FILE="bmake.mk" ;;
|
|
esac
|
|
|
|
case "$OS" in
|
|
mingw*|msys*|ucrt*|clang*) IS_WIN=1 ;;
|
|
*) IS_WIN=0 ;;
|
|
esac
|
|
|
|
HAS_INSTALL=0
|
|
HAS_UNINSTALL=0
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
install) HAS_INSTALL=1 ;;
|
|
uninstall) HAS_UNINSTALL=1 ;;
|
|
esac
|
|
done
|
|
|
|
if [ "$HAS_INSTALL" = "1" ] || [ "$HAS_UNINSTALL" = "1" ]; then
|
|
if [ "$HAS_INSTALL" = "1" ]; then
|
|
make -f "$MK_FILE" release
|
|
fi
|
|
|
|
if [ "$IS_WIN" = "1" ] || [ "$(id -u)" = "0" ]; then
|
|
PRIV=""
|
|
elif command -v doas > /dev/null 2>&1; then
|
|
PRIV="doas"
|
|
elif command -v sudo > /dev/null 2>&1; then
|
|
PRIV="sudo"
|
|
else
|
|
echo "error: install requires root. neither doas nor sudo found." >&2
|
|
exit 1
|
|
fi
|
|
|
|
$PRIV make -f "$MK_FILE" "$@"
|
|
else
|
|
make -f "$MK_FILE" "$@"
|
|
fi
|