Skip to content
Myr

[Fix] support arm64-musl on Alpine Linux

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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

authored by Jesse Zhu · committed by Jordan Harband · parent c7d5d77 · Browse files · 2 files+7 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Jesse Zhu <jesse@itjesse.com>
  • Co-authored-by: Jordan Harband <ljharb@gmail.com>

Diff stats

2 files+7 added−5 removed

  • tests:+4 added−4 removed
  • other:+3 added−1 removed

2 files+7 added−5 removed

modified:test/fast/Unit tests/nvm_get_arch alpine+4 added-4 removed
13 unmodified lines
1415MOCKS_DIR="$(pwd)/../../mocks"16export PATH=".:${PATH}"1718# On Alpine (where /etc/alpine-release exists), x64 should get -musl suffix19# and arm64 should NOT get -musl suffix.18# On Alpine (where /etc/alpine-release exists), both x64 and arm64 should get19# the -musl suffix, since unofficial-builds publishes musl binaries for both.20# On non-Alpine, neither should get -musl.2122if [ -f "/etc/alpine-release" ]; then23 # x64 on Alpine should produce x64-musl
1 unmodified line
25 OUTPUT="$(nvm_get_arch)"26 rm -f ./uname27 [ "_${OUTPUT}" = "_x64-musl" ] || die "x64 on Alpine should be x64-musl, got ${OUTPUT}"2829 # aarch64 on Alpine should produce arm64, NOT arm64-musl29 # aarch64 on Alpine should produce arm64-musl30 ln -sf "${MOCKS_DIR}/uname_linux_aarch64" ./uname31 OUTPUT="$(nvm_get_arch)"32 rm -f ./uname33 [ "_${OUTPUT}" = "_arm64" ] || die "aarch64 on Alpine should be arm64 (no musl suffix), got ${OUTPUT}"33 [ "_${OUTPUT}" = "_arm64-musl" ] || die "aarch64 on Alpine should be arm64-musl, got ${OUTPUT}"34else35 # x64 on non-Alpine should produce x64 (no musl suffix)36 ln -sf "${MOCKS_DIR}/uname_linux_x86_64" ./uname37 OUTPUT="$(nvm_get_arch)"
11 unmodified lines
modified:nvm.sh+3 added-1 removed
2250 unmodified lines
2251 HOST_ARCH=armv7l2252 fi22532254 if [ -f "/etc/alpine-release" ]; then2255 # Alpine Linux uses musl libc; only x64-musl binaries are available2255 # Alpine Linux uses musl libc; map to musl variants where available2256 # See https://unofficial-builds.nodejs.org/download/release/2257 case "${NVM_ARCH}" in2258 x64) NVM_ARCH=x64-musl ;;2259 arm64) NVM_ARCH=arm64-musl ;;2260 esac2261 fi22622263 nvm_echo "${NVM_ARCH}"
2689 unmodified lines