From 6199e368f68dcc9faabb48277c9d014ea0a4f0db Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 30 Mar 2022 05:07:36 +0200 Subject: mbuto: Parse options before fakeroot check ...so that we can display the help message even if fakeroot is not available. Suggested-by: Wainer dos Santos Moschetta Signed-off-by: Stefano Brivio --- mbuto | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mbuto b/mbuto index ef5faf7..99b0e2d 100755 --- a/mbuto +++ b/mbuto @@ -916,14 +916,7 @@ usage() { ################################################################################ -# Entry point: if we're not running as root, re-run with fakeroot -if [ "${LD_PRELOAD}" != "libfakeroot-sysv.so" ] && [ "$(id -u)" -ne 0 ]; then - if ! FAKEROOT="$(command -v fakeroot)"; then - err "Not root and no fakeroot available, exiting" - fi - PATH="${PATH}:/sbin:/usr/sbin" "${FAKEROOT}" "${0}" "$@" - exit ${?} -fi +ARGS=${@} # Parse options while getopts c:df:k:m:p:s:vh __opt; do @@ -940,9 +933,17 @@ while getopts c:df:k:m:p:s:vh __opt; do esac done shift $((OPTIND - 1)) - [ -z "${PROFILE}" ] && PROFILE="base" +# If we're not running as root, re-run with fakeroot +if [ "${LD_PRELOAD}" != "libfakeroot-sysv.so" ] && [ "$(id -u)" -ne 0 ]; then + if ! FAKEROOT="$(command -v fakeroot)"; then + err "Not root and no fakeroot available, exiting" + fi + PATH="${PATH}:/sbin:/usr/sbin" "${FAKEROOT}" "${0}" ${ARGS} + exit ${?} +fi + # Check needed tools, exit if any is missing for __l in ${TOOLS}; do cmd_check "${__l}" -- cgit v1.2.3