Commits

Anonymous committed 5d46baa

update install/uninstall scripts: remove check for root access (UID=0), and add simple permissions check (verify write permissions on any install directories which exist prior to installation)

Comments (0)

Files changed (2)

tools/install_binary_bundle.sh

 # 02110-1301, USA.
 #
 
-if [[ $EUID -ne 0 ]]; then
-   echo "This script must be run as root" 1>&2
-   exit 1
-fi
-
 set -e
 
 export PATH=/bin:/usr/bin
 PLUGINDIR="${5:-${PREFIX}/lib/mupen64plus}"
 MANDIR="${6:-${PREFIX}/share/man}"
 
+# simple check for permissions
+if [ -d "${SHAREDIR}" -a ! -w "${SHAREDIR}" ]; then
+	printf "Error: you do not have permission to install at: ${SHAREDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${BINDIR}" -a ! -w "${BINDIR}" ]; then
+	printf "Error: you do not have permission to install at: ${BINDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${LIBDIR}" -a ! -w "${LIBDIR}" ]; then
+	printf "Error: you do not have permission to install at: ${LIBDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${PLUGINDIR}" -a ! -w "${PLUGINDIR}" ]; then
+	printf "Error: you do not have permission to install at: ${PLUGINDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${MANDIR}" -a ! -w "${MANDIR}" ]; then
+	printf "Error: you do not have permission to install at: ${MANDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+
 printf "Installing Mupen64Plus Binary Bundle to ${PREFIX}\n"
 # Mupen64Plus-Core
 $INSTALL -d -v "${LIBDIR}"

tools/uninstall_binary_bundle.sh

 # 02110-1301, USA.
 #
 
-if [[ $EUID -ne 0 ]]; then
-   echo "This script must be run as root" 1>&2
-   exit 1
-fi
-
 set -e
 
 export PATH=/bin:/usr/bin
 PLUGINDIR="${5:-${PREFIX}/lib/mupen64plus}"
 MANDIR="${6:-${PREFIX}/share/man}"
 
+# simple check for some permissions
+if [ -d "${SHAREDIR}" -a ! -w "${SHAREDIR}" ]; then
+	printf "Error: you do not have permission to uninstall from: ${SHAREDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${BINDIR}" -a ! -w "${BINDIR}" ]; then
+	printf "Error: you do not have permission to uninstall from: ${BINDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${LIBDIR}" -a ! -w "${LIBDIR}" ]; then
+	printf "Error: you do not have permission to uninstall from: ${LIBDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${PLUGINDIR}" -a ! -w "${PLUGINDIR}" ]; then
+	printf "Error: you do not have permission to uninstall from: ${PLUGINDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+if [ -d "${MANDIR}" -a ! -w "${MANDIR}" ]; then
+	printf "Error: you do not have permission to uninstall from: ${MANDIR}\nMaybe you need to be root?\n"
+	exit 1
+fi
+
 printf "Uninstalling Mupen64Plus Binary Bundle from ${PREFIX}\n"
 # Mupen64Plus-Core
 rm -f "${LIBDIR}"/libmupen64plus.so*
 [ ! -L "${MANDIR}/man6" ] && rmdir --ignore-fail-on-non-empty "${MANDIR}/man6"
 [ ! -L "${MANDIR}" ] && rmdir --ignore-fail-on-non-empty "${MANDIR}"
 
-printf "Done.\n"
+printf "Uninstall successful.\n"