From 590606a5d7c699e4d4705501377ca83fb696b61c Mon Sep 17 00:00:00 2001 From: Ray Kohler Date: Thu, 4 Mar 2010 21:57:46 -0500 Subject: makepkg: fall back to su if sudo is not available Signed-off-by: Ray Kohler Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- scripts/makepkg.sh.in | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index baf47032..08b4c9e6 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -344,8 +344,12 @@ download_file() { run_pacman() { local ret=0 - if (( ! ASROOT )) && [[ $1 != "-T" && $1 != "-Qq" ]] && sudo -l $PACMAN &>/dev/null; then - sudo $PACMAN $PACMAN_OPTS "$@" || ret=$? + if (( ! ASROOT )) && [[ $1 != "-T" && $1 != "-Qq" ]]; then + if [ "$(type -p sudo)" ] && sudo -l $PACMAN &>/dev/null; then + sudo $PACMAN $PACMAN_OPTS "$@" || ret=$? + else + su -c "$PACMAN $PACMAN_OPTS $*" || ret=$? + fi else $PACMAN $PACMAN_OPTS "$@" || ret=$? fi @@ -1694,12 +1698,9 @@ else fi # check for sudo if we will need it during makepkg execution -if (( ! ASROOT && ( DEP_BIN || RMDEPS || INSTALL ) )); then +if (( ! ( ASROOT || INFAKEROOT ) && ( DEP_BIN || RMDEPS || INSTALL ) )); then if [ ! "$(type -p sudo)" ]; then - error "$(gettext "Cannot find the sudo binary! Is sudo installed?")" - plain "$(gettext "Missing dependencies cannot be installed or removed as a normal user")" - plain "$(gettext "without sudo; install and configure sudo to auto-resolve dependencies.")" - exit 1 + warning "$(gettext "Sudo can not be found. Will use su to acquire root privileges.")" fi fi -- cgit v1.2.3-24-g4f1b