From 591059ffd3ba406c4af010bacb07cbaf890c1500 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Wed, 17 Apr 2013 11:18:20 +0100 Subject: [PATCH] Improve Fedora build host support. Sudo command (even using -E) resets $PATH for security reasons, Fedora and other distos might have to explicitly add /usr/local/bin to $PATH in order to run the commands in the chroot environment. Change-Id: I95068ecf1e7437152e11c6d6789f59bcfd6ae9cc --- bin/disk-image-create | 5 +++++ lib/img-functions | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/disk-image-create b/bin/disk-image-create index 86ecdf1f..5b40aa28 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -25,6 +25,11 @@ export LANG=C export DIB_ARGS="$@" export DIB_ENV=$(export) +# Fedora and others don't always have /usr/local/bin in $PATH +if [[ ! "$PATH" == */usr/local/bin* ]] ; then + export PATH="${PATH}:/usr/local/bin/" +fi + SCRIPTNAME=$(basename $0) SCRIPT_HOME=$(dirname $0) export _LIB=$(dirname $0)/../lib diff --git a/lib/img-functions b/lib/img-functions index f0914840..a943c33c 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -102,8 +102,9 @@ function create_base () { # Helper function to run a command inside the chroot function run_in_target() { - # -E to preserve http_proxy - sudo -E chroot $TMP_MOUNT_PATH "$@" + # Explicitly set PATH to prevent sudo from resetting it + # and -E to preserve http_proxy + sudo -E PATH=${PATH} chroot $TMP_MOUNT_PATH "$@" } # Helper function to run a directory of scripts inside the chroot