I just came across a nuisance with this patch: it warns about the use of su both inside, and outside, of the fakeroot run. Here's another version that checks INFAKEROOT before printing that, such that it'll only do so outside of the fakeroot.
>From 94840c1c5f1fc0f3b4699bcb174f615042ff1cf1 Mon Sep 17 00:00:00 2001 From: Ray Kohler <ataraxia...@gmail.com> Date: Sat, 20 Feb 2010 21:08:25 -0500 Subject: [PATCH] makepkg: fall back to su if sudo is not available Signed-off-by: Ray Kohler <ataraxia...@gmail.com> --- scripts/makepkg.sh.in | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 5bd294c..75ce7e9 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" ]] && 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 + su -c "$PACMAN $PACMAN_OPTS $*" || ret=$? + fi else $PACMAN $PACMAN_OPTS "$@" || ret=$? fi @@ -1687,12 +1691,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; falling back to su for acquiring root privileges.")" fi fi -- 1.7.0.1