There's a bit of a hack here with the "fullcmd" temporary
variable to get around the need to pass the entire command line
to su -c as one argument.

Signed-off-by: Ray Kohler <[email protected]>
---
 scripts/makepkg.sh.in |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 5bd294c..2dc9262 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -344,8 +344,13 @@ download_file() {
 
 run_pacman() {
        local ret=0
-       if (( ! ASROOT )) && [[ $1 != "-T" ]] && sudo -l $PACMAN &>/dev/null; 
then
-               sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
+       if (( ! ASROOT )) && [[ $1 != "-T" ]]; then
+               if [ "$(type -p sudo)" ] && sudo -l $PACMAN &>/dev/null; then
+                       sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
+               else
+                       fullcmd="$PACMAN $PACMAN_OPTS $@"
+                       su -c "$fullcmd" || ret=$?
+               fi
        else
                $PACMAN $PACMAN_OPTS "$@" || ret=$?
        fi
@@ -1686,16 +1691,6 @@ else
        fi
 fi
 
-# check for sudo if we will need it during makepkg execution
-if (( ! ASROOT && ( 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
-       fi
-fi
-
 unset pkgname pkgbase pkgver pkgrel pkgdesc url license groups provides
 unset md5sums replaces depends conflicts backup source install changelog build
 unset makedepends optdepends options noextract
-- 
1.7.0


Reply via email to