diff options
author | Michał Górny <mgorny@gentoo.org> | 2020-05-26 09:41:40 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2020-05-28 13:41:22 +0200 |
commit | f1e8874cc2de2055c3a07f7faf0c78d723106d06 (patch) | |
tree | aea07a9490031bd9cb93b7f26e28d5fff5826bd1 /eclass | |
parent | llvm.eclass: Remove remnants of slot :0 support (diff) | |
download | gentoo-f1e8874cc2de2055c3a07f7faf0c78d723106d06.tar.gz gentoo-f1e8874cc2de2055c3a07f7faf0c78d723106d06.tar.bz2 gentoo-f1e8874cc2de2055c3a07f7faf0c78d723106d06.zip |
llvm.eclass: Fix prepending LLVM path before system paths
Do not prepend LLVM path before system path, in particular before
ccache/distcc paths. Instead, prepend it before the first LLVM version
found in PATH, or append to the end if no LLVM is found in PATH.
Closes: https://bugs.gentoo.org/627726
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/llvm.eclass | 25 | ||||
-rwxr-xr-x | eclass/tests/llvm.sh | 16 |
2 files changed, 31 insertions, 10 deletions
diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass index 4f968dc39f87..61b34d4985eb 100644 --- a/eclass/llvm.eclass +++ b/eclass/llvm.eclass @@ -198,8 +198,29 @@ llvm_pkg_setup() { debug-print-function ${FUNCNAME} "${@}" if [[ ${MERGE_TYPE} != binary ]]; then - local llvm_prefix=$(get_llvm_prefix "${LLVM_MAX_SLOT}") - export PATH=${llvm_prefix}/bin:${PATH} + local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin + local IFS=: + local split_path=( ${PATH} ) + local new_path=() + local x added= + + # prepend new path before first LLVM version found + for x in "${split_path[@]}"; do + if [[ ${x} == */usr/lib/llvm/*/bin ]]; then + if [[ ${x} != ${llvm_path} ]]; then + new_path+=( "${llvm_path}" ) + elif [[ ${added} && ${x} == ${llvm_path} ]]; then + # deduplicate + continue + fi + added=1 + fi + new_path+=( "${x}" ) + done + # ...or to the end of PATH + [[ ${added} ]] || new_path+=( "${llvm_path}" ) + + export PATH=${new_path[*]} fi } diff --git a/eclass/tests/llvm.sh b/eclass/tests/llvm.sh index bb8d5fc998e8..8527d81765dd 100755 --- a/eclass/tests/llvm.sh +++ b/eclass/tests/llvm.sh @@ -91,17 +91,17 @@ eindent LLVM_MAX_SLOT=11 \ LLVM_INSTALLED_SLOT=1* \ PATH=${BASEPATH}:/usr/lib/llvm/11/bin \ - check_setup_path "/usr/lib/llvm/11/bin:${BASEPATH}:/usr/lib/llvm/11/bin" + check_setup_path "${BASEPATH}:/usr/lib/llvm/11/bin" LLVM_MAX_SLOT=10 \ LLVM_INSTALLED_SLOT=1* \ PATH=${BASEPATH}:/usr/lib/llvm/11/bin:/usr/lib/llvm/10/bin \ - check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}:/usr/lib/llvm/11/bin:/usr/lib/llvm/10/bin" + check_setup_path "${BASEPATH}:/usr/lib/llvm/10/bin:/usr/lib/llvm/11/bin" LLVM_MAX_SLOT=11 \ LLVM_INSTALLED_SLOT=10 \ PATH=${BASEPATH}:/usr/lib/llvm/10/bin \ - check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}:/usr/lib/llvm/10/bin" + check_setup_path "${BASEPATH}:/usr/lib/llvm/10/bin" eoutdent ebegin "Testing pkg_setup with the other LLVM version in PATH" @@ -109,12 +109,12 @@ eindent LLVM_MAX_SLOT=11 \ LLVM_INSTALLED_SLOT=1* \ PATH=${BASEPATH}:/usr/lib/llvm/10/bin \ - check_setup_path "/usr/lib/llvm/11/bin:${BASEPATH}:/usr/lib/llvm/10/bin" + check_setup_path "${BASEPATH}:/usr/lib/llvm/11/bin:/usr/lib/llvm/10/bin" LLVM_MAX_SLOT=10 \ LLVM_INSTALLED_SLOT=1* \ PATH=${BASEPATH}:/usr/lib/llvm/11/bin \ - check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}:/usr/lib/llvm/11/bin" + check_setup_path "${BASEPATH}:/usr/lib/llvm/10/bin:/usr/lib/llvm/11/bin" eoutdent ebegin "Testing pkg_setup with LLVM missing from PATH" @@ -122,17 +122,17 @@ eindent LLVM_MAX_SLOT=11 \ LLVM_INSTALLED_SLOT=1* \ PATH=${BASEPATH} \ - check_setup_path "/usr/lib/llvm/11/bin:${BASEPATH}" + check_setup_path "${BASEPATH}:/usr/lib/llvm/11/bin" LLVM_MAX_SLOT=10 \ LLVM_INSTALLED_SLOT=1* \ PATH=${BASEPATH} \ - check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}" + check_setup_path "${BASEPATH}:/usr/lib/llvm/10/bin" LLVM_MAX_SLOT=11 \ LLVM_INSTALLED_SLOT=10 \ PATH=${BASEPATH} \ - check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}" + check_setup_path "${BASEPATH}:/usr/lib/llvm/10/bin" eoutdent texit |