mirror of
https://github.com/starship/starship.git
synced 2024-11-22 08:14:10 +01:00
fix: [install.sh] if glibc >= 2.18, use the dynamically linked binary
`install.sh` previously uses the statically linked `unknown-linux-musl` build for every Linux installation. If the host's `libc` is a recent enough GNU libc, however, it should use this rather than the statically linked build. Includes documentation from the PR conversation about how to recompute the minimum version as needed. Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
This commit is contained in:
parent
0f3a58352f
commit
dd9e7323d6
@ -193,8 +193,34 @@ detect_platform() {
|
|||||||
cygwin_nt*) platform="pc-windows-msvc";;
|
cygwin_nt*) platform="pc-windows-msvc";;
|
||||||
# mingw is Git-Bash
|
# mingw is Git-Bash
|
||||||
mingw*) platform="pc-windows-msvc" ;;
|
mingw*) platform="pc-windows-msvc" ;;
|
||||||
# use the statically compiled musl bins on linux to avoid linking issues.
|
linux)
|
||||||
linux) platform="unknown-linux-musl" ;;
|
# default to the statically compiled musl bins on linux
|
||||||
|
# to avoid linking issues.
|
||||||
|
platform="unknown-linux-musl"
|
||||||
|
# musl's ldd from Alpine prints to stderr
|
||||||
|
ldd_verstr="$(ldd --version 2>&1 | head -n1)"
|
||||||
|
# glibc version string is inconsistent across distributions
|
||||||
|
# instead check if the string does not contain musl (case insensitive)
|
||||||
|
if echo "${ldd_verstr}" | grep -iv musl >/dev/null; then
|
||||||
|
glibc_version=$(echo "${ldd_verstr}" | awk 'NR==1 { print $NF }')
|
||||||
|
# on installations with a new enough glibc, use the dynamically compiled binary
|
||||||
|
#
|
||||||
|
# use this to see potential max versions
|
||||||
|
# strings $(which starship) | grep -i glibc
|
||||||
|
#
|
||||||
|
# then use https://gist.github.com/fasterthanlime/17e002a8f5e0f189861c with
|
||||||
|
# `MAX_VER` set to the version from earlier e.g. GLIBC_2.33 => 2.33
|
||||||
|
glibc_maj_ver=$(echo "${glibc_version}" | cut -d. -f1)
|
||||||
|
glibc_min_ver=$(echo "${glibc_version}" | cut -d. -f2)
|
||||||
|
min_maj_ver=2
|
||||||
|
min_min_ver=18
|
||||||
|
if [ "${glibc_maj_ver}" -gt "${min_maj_ver}" ] \
|
||||||
|
|| { [ "${glibc_maj_ver}" -eq "${min_maj_ver}" ] \
|
||||||
|
&& [ "${glibc_min_ver}" -ge "${min_min_ver}" ]; }; then
|
||||||
|
platform="unknown-linux-gnu"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
darwin) platform="apple-darwin" ;;
|
darwin) platform="apple-darwin" ;;
|
||||||
freebsd) platform="unknown-freebsd" ;;
|
freebsd) platform="unknown-freebsd" ;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user