# HG changeset patch # User Johannes Stezenbach # Date 1280424637 -7200 # Node ID ace1d90c9b157dfa96787ef9f8c49dcd28546344 # Parent 471acb219d7758400772c3be486e1176ac5cdead scripts: remove . from $PATH Add CT_SanitizePath function which removes entries referring to ., /tmp and non-existing directories from $PATH, and call it early in the build script. If . is in PATH, gcc-4.4.4 build breaks: [ALL ] checking what assembler to use... /tmp/build/targets/arm-unknown-linux-uclibcgnueabi/build/gcc-core-static/arm-unknown-linux-uclibcgnueabi/bin/as ... [ALL ] config.status: creating as i.e. "as" is supposed to be the arm-unknown-linux-uclibcgnueabi cross assembler, but config.status creates a local "as" script which is calling the host assembler. Signed-off-by: Johannes Stezenbach [Yann E. MORIN: style fixes + explanations] Signed-off-by: "Yann E. MORIN" (transplanted from 20dd8cef1c8adff0aa3e78ae6d7acfbc45ed5a83) diff -r 471acb219d77 -r ace1d90c9b15 scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Mon Jul 19 23:16:02 2010 +0200 +++ b/scripts/crosstool-NG.sh.in Thu Jul 29 19:30:37 2010 +0200 @@ -28,6 +28,9 @@ # Overide the locale early, in case we ever translate crosstool-NG messages [ -z "${CT_NO_OVERIDE_LC_MESSAGES}" ] && export LC_ALL=C +# remove . from PATH since it can cause gcc build failures +CT_SanitizePath + # Some sanity checks in the environment and needed tools CT_DoLog INFO "Performing some trivial sanity checks" CT_TestAndAbort "Don't set LD_LIBRARY_PATH. It screws up the build." -n "${LD_LIBRARY_PATH}" diff -r 471acb219d77 -r ace1d90c9b15 scripts/functions --- a/scripts/functions Mon Jul 19 23:16:02 2010 +0200 +++ b/scripts/functions Thu Jul 29 19:30:37 2010 +0200 @@ -137,6 +137,24 @@ CT_DoLog ${level:-INFO} "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})" } +# Remove entries referring to ., /tmp and non-existing directories from $PATH +# Usage: CT_SanitizePath +CT_SanitizePath() { + local new + local tmp + local IFS=: + for p in $PATH; do + # Replace any occurence of . with $(pwd -P) + # Use /tmp as a default if the directory is non-existent + # Do not add /tmp in the PATH + tmp="$( cd /tmp; cd "${p}" 2>/dev/null || true; pwd -P )" + if [ "${tmp}" != "/tmp" ]; then + new="${new}${new:+:}${p}" + fi + done + PATH="${new}" +} + # Abort the execution with an error message # Usage: CT_Abort CT_Abort() {