From 8efc6dae8a781e3fc058cda0b49a0a6cfd745bb5 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Tue, 25 Jan 2011 21:59:03 +0100 Subject: [PATCH] scripts: fix double slash in paths Computed paths may contain double slashes. This is not an issue but it is just ugly to look at. Signed-off-by: "Yann E. MORIN" --- scripts/crosstool-NG.sh.in | 2 ++ scripts/functions | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index d7dba89d..2fa19949 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -295,6 +295,7 @@ if [ -z "${CT_RESTART}" ]; then CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}" CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root" CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include" + CT_SanitiseVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" @@ -308,6 +309,7 @@ if [ -z "${CT_RESTART}" ]; then CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}" CT_DEBUGROOT_DIR="${CT_SYSROOT_DIR}" CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include" + CT_SanitiseVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR # hack! Always use --with-sysroot for binutils. # binutils 2.14 and later obey it, older binutils ignore it. # Lets you build a working 32->64 bit cross gcc diff --git a/scripts/functions b/scripts/functions index 0bc16f7f..ba92d118 100644 --- a/scripts/functions +++ b/scripts/functions @@ -159,6 +159,24 @@ CT_SanitizePath() { PATH="${new}" } +# Sanitise the directory name contained in the variable passed as argument: +# - remove duplicate / +# Usage: CT_SanitiseVarDir CT_PREFIX_DIR +CT_SanitiseVarDir() { + local var + local old_dir + local new_dir + + for var in "$@"; do + eval "old_dir=\"\${${var}}\"" + new_dir="$( printf "${old_dir}" \ + |sed -r -e 's:/+:/:g;' \ + )" + eval "${var}=\"${new_dir}\"" + CT_DoLog DEBUG "Sanitised '${var}': '${old_dir}' -> '${new_dir}'" + done +} + # Abort the execution with an error message # Usage: CT_Abort CT_Abort() {