On 21/02/10 12:20, Ray Kohler wrote:
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<ataraxia...@gmail.com>
---
  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=$?

does:
su -c "$PACMAN $PACMAN_OPTS $@"
not work?

+               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
-

Maybe we should keep this somewhat... With this patch I will be asked for a password. It could be my user password if I have sudo install or it could be the root password if not. That there is no indication which password is needed does not seem great from a usability perspective. We could keep the check for sudo and print that we are falling back to using su.

Allan

Reply via email to