diff --git a/constructor/header.sh b/constructor/header.sh index 0a5d740f..ec3b03d6 100644 --- a/constructor/header.sh +++ b/constructor/header.sh @@ -35,27 +35,29 @@ fi {%- elif linux and min_glibc_version %} min_glibc_version="{{ min_glibc_version }}" system_glibc_version="${CONDA_OVERRIDE_GLIBC:-}" -case "$(ldd --version 2>&1)" in - *musl*) - # musl ldd will report musl version; call libc.so directly - # see https://github.com/conda/constructor/issues/850#issuecomment-2343756454 - libc_so="$(find /lib /usr/local/lib /usr/lib -name 'libc.so.*' -print -quit 2>/dev/null)" - if [ -z "${libc_so}" ]; then - libc_so="$(strings /etc/ld.so.cache | grep '^/.*/libc\.so.*' | head -1)" - fi - if [ -z "${libc_so}" ]; then - echo "Warning: Couldn't find libc.so; won't be able to determine GLIBC version!" >&2 - echo "Override by setting CONDA_OVERRIDE_GLIBC" >&2 - system_glibc_version="0.0" - else - system_glibc_version=$("${libc_so}" --version | awk 'NR==1{ sub(/\.$/, ""); print $NF}') - fi - ;; - *) - # ldd reports glibc in the last field of the first line - system_glibc_version=$(ldd --version | awk 'NR==1{print $NF}') - ;; -esac +if [ "${system_glibc_version}" = "" ]; then + case "$(ldd --version 2>&1)" in + *musl*) + # musl ldd will report musl version; call libc.so directly + # see https://github.com/conda/constructor/issues/850#issuecomment-2343756454 + libc_so="$(find /lib /usr/local/lib /usr/lib -name 'libc.so.*' -print -quit 2>/dev/null)" + if [ -z "${libc_so}" ]; then + libc_so="$(strings /etc/ld.so.cache | grep '^/.*/libc\.so.*' | head -1)" + fi + if [ -z "${libc_so}" ]; then + echo "Warning: Couldn't find libc.so; won't be able to determine GLIBC version!" >&2 + echo "Override by setting CONDA_OVERRIDE_GLIBC" >&2 + system_glibc_version="0.0" + else + system_glibc_version=$("${libc_so}" --version | awk 'NR==1{ sub(/\.$/, ""); print $NF}') + fi + ;; + *) + # ldd reports glibc in the last field of the first line + system_glibc_version=$(ldd --version | awk 'NR==1{print $NF}') + ;; + esac +fi # shellcheck disable=SC2183 disable=SC2046 int_min_glibc_version="$(printf "%02d%02d%02d" $(echo "$min_glibc_version" | sed 's/\./ /g'))" # shellcheck disable=SC2183 disable=SC2046