diff options
author | Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> | 2010-07-29 19:30:37 +0200 |
---|---|---|
committer | Johannes Stezenbach <js@sig21.net> | 2010-07-29 19:30:37 +0200 |
commit | 8bd0034057c8bd34df4fb401bedfca49384f5323 (patch) | |
tree | daed6bc3aef5dbaa508abd1b86cb0cbbf67ecb59 /scripts/functions | |
parent | 8bb436dad16d1157121c29b35fa95f40b0c08250 (diff) | |
download | crosstool-ng-8bd0034057c8bd34df4fb401bedfca49384f5323.tar.gz crosstool-ng-8bd0034057c8bd34df4fb401bedfca49384f5323.tar.bz2 crosstool-ng-8bd0034057c8bd34df4fb401bedfca49384f5323.zip |
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 <js@sig21.net>
[Yann E. MORIN: style fixes + explanations]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Diffstat (limited to 'scripts/functions')
-rw-r--r-- | scripts/functions | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/scripts/functions b/scripts/functions index c284881e..0250f051 100644 --- a/scripts/functions +++ b/scripts/functions @@ -137,6 +137,24 @@ CT_DoEnd() 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 <message> CT_Abort() { |