From c20eaea9bc4c85b65389b1edb52f35b6676ea0ec Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 4 Sep 2019 14:10:17 +0200 Subject: ptxd_normalize_config: handle symlinks in the workspace path correctly If the workspace path contains a symlink, which means "${PTXDIST_LAYERS[0]}" != $(readlink -f "${PTXDIST_LAYERS[0]}") and 'base' is a symlink to another subdirectory of the workspace, then ptxd_normalize_config() returns the wrong result: For example: PTXDIST_WORKSPACE = /tmp/link/BSP $(readlink -f $PTXDIST_WORKSPACE) = /tmp/real/BSP $(readlink -f $PTXDIST_WORKSPACE/base) = /tmp/real/BSP/layer file_dotconfig = /tmp/link/BSP/base/configs/ptxconfig After the first loop iteration: nomalized = /tmp/link/BSP/layer/configs/ptxconfig For the next loop iteration the substitution fails because now $nomalized contains a symlink. As a result, ptxd_normalize_config() returns the wrong path. Fix this by checking if the original resolved path is within each layer and update $nomalized if that is the case. This way the path is normalized correctly even if other layers patch as well. Signed-off-by: Michael Olbrich --- scripts/lib/ptxd_lib_kconfig.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/lib/ptxd_lib_kconfig.sh b/scripts/lib/ptxd_lib_kconfig.sh index 126ec766f..03c6b05b9 100644 --- a/scripts/lib/ptxd_lib_kconfig.sh +++ b/scripts/lib/ptxd_lib_kconfig.sh @@ -54,7 +54,10 @@ ptxd_normalize_config() { nomalized="$(readlink -f "${file_dotconfig}")" old="${nomalized}" for layer in "${PTXDIST_LAYERS[@]}"; do - nomalized="${nomalized/#$(readlink -f ${layer})\//${layer}/}" + local tmp="${old/#$(readlink -f ${layer})\//${layer}/}" + if [ "${tmp}" != "${old}" ]; then + nomalized="${tmp}" + fi done if [ "$(readlink -f "${nomalized}")" != "${old}" ]; then ptxd_bailout "Failed to normalize filename:" \ -- cgit v1.2.3