mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-07-18 21:08:23 +08:00
[Fix] support arm64-musl on Alpine Linux
Node.js unofficial-builds publishes linux-arm64-musl binaries since v20.20.1 / v22.21.1 / v24+. Map NVM_ARCH=arm64 to arm64-musl on Alpine so `nvm install` resolves to the correct tarball instead of the glibc-linked arm64 build that won't run against musl. [Tests] `nvm_get_arch`: expect arm64-musl on Alpine Co-authored-by: Jesse Zhu <jesse@itjesse.com> Co-authored-by: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
co-authored by
Jordan Harband
parent
c7d5d7748b
commit
ce157c1171
@@ -2252,9 +2252,11 @@ nvm_get_arch() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "/etc/alpine-release" ]; then
|
if [ -f "/etc/alpine-release" ]; then
|
||||||
# Alpine Linux uses musl libc; only x64-musl binaries are available
|
# Alpine Linux uses musl libc; map to musl variants where available
|
||||||
|
# See https://unofficial-builds.nodejs.org/download/release/
|
||||||
case "${NVM_ARCH}" in
|
case "${NVM_ARCH}" in
|
||||||
x64) NVM_ARCH=x64-musl ;;
|
x64) NVM_ARCH=x64-musl ;;
|
||||||
|
arm64) NVM_ARCH=arm64-musl ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ die () { cleanup; echo "$@" ; exit 1; }
|
|||||||
MOCKS_DIR="$(pwd)/../../mocks"
|
MOCKS_DIR="$(pwd)/../../mocks"
|
||||||
export PATH=".:${PATH}"
|
export PATH=".:${PATH}"
|
||||||
|
|
||||||
# On Alpine (where /etc/alpine-release exists), x64 should get -musl suffix
|
# On Alpine (where /etc/alpine-release exists), both x64 and arm64 should get
|
||||||
# and arm64 should NOT get -musl suffix.
|
# the -musl suffix, since unofficial-builds publishes musl binaries for both.
|
||||||
# On non-Alpine, neither should get -musl.
|
# On non-Alpine, neither should get -musl.
|
||||||
|
|
||||||
if [ -f "/etc/alpine-release" ]; then
|
if [ -f "/etc/alpine-release" ]; then
|
||||||
@@ -26,11 +26,11 @@ if [ -f "/etc/alpine-release" ]; then
|
|||||||
rm -f ./uname
|
rm -f ./uname
|
||||||
[ "_${OUTPUT}" = "_x64-musl" ] || die "x64 on Alpine should be x64-musl, got ${OUTPUT}"
|
[ "_${OUTPUT}" = "_x64-musl" ] || die "x64 on Alpine should be x64-musl, got ${OUTPUT}"
|
||||||
|
|
||||||
# aarch64 on Alpine should produce arm64, NOT arm64-musl
|
# aarch64 on Alpine should produce arm64-musl
|
||||||
ln -sf "${MOCKS_DIR}/uname_linux_aarch64" ./uname
|
ln -sf "${MOCKS_DIR}/uname_linux_aarch64" ./uname
|
||||||
OUTPUT="$(nvm_get_arch)"
|
OUTPUT="$(nvm_get_arch)"
|
||||||
rm -f ./uname
|
rm -f ./uname
|
||||||
[ "_${OUTPUT}" = "_arm64" ] || die "aarch64 on Alpine should be arm64 (no musl suffix), got ${OUTPUT}"
|
[ "_${OUTPUT}" = "_arm64-musl" ] || die "aarch64 on Alpine should be arm64-musl, got ${OUTPUT}"
|
||||||
else
|
else
|
||||||
# x64 on non-Alpine should produce x64 (no musl suffix)
|
# x64 on non-Alpine should produce x64 (no musl suffix)
|
||||||
ln -sf "${MOCKS_DIR}/uname_linux_x86_64" ./uname
|
ln -sf "${MOCKS_DIR}/uname_linux_x86_64" ./uname
|
||||||
|
|||||||
Reference in New Issue
Block a user