From 779a34e6a9adcb6528e63d595a7a8838747e7915 Mon Sep 17 00:00:00 2001 From: Botspot <54716352+Botspot@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:56:25 -0500 Subject: [PATCH] [Fix] `nvm_get_arch`: Rasbperry Pi: armv7l with arm64 kernel, get correct arch Co-authored-by: Botspot <54716352+Botspot@users.noreply.github.com> Co-authored-by: Jordan Harband Co-authored-by: Sladyn Nunes --- nvm.sh | 8 ++++++++ test/fast/Unit tests/nvm_get_arch | 2 ++ 2 files changed, 10 insertions(+) diff --git a/nvm.sh b/nvm.sh index edf964a..aab6c5d 100644 --- a/nvm.sh +++ b/nvm.sh @@ -1796,6 +1796,14 @@ nvm_get_arch() { aarch64) NVM_ARCH="arm64" ;; *) NVM_ARCH="${HOST_ARCH}" ;; esac + + # If running a 64bit ARM kernel but a 32bit ARM userland, change ARCH to 32bit ARM (armv7l) + L=$(ls -dl /sbin/init) # if /sbin/init is 32bit executable + if [ "$(uname)" = "Linux" ] && [ "${NVM_ARCH}" = arm64 ] && [ "$(od -An -t x1 -j 4 -N 1 "${L#*-> }")" = ' 01' ]; then + NVM_ARCH=armv7l + HOST_ARCH=armv7l + fi + nvm_echo "${NVM_ARCH}" } diff --git a/test/fast/Unit tests/nvm_get_arch b/test/fast/Unit tests/nvm_get_arch index f064203..aaf3e83 100755 --- a/test/fast/Unit tests/nvm_get_arch +++ b/test/fast/Unit tests/nvm_get_arch @@ -79,4 +79,6 @@ run_test amd64 smartos x64 no_pkg_info run_test x86 osx x86 run_test amd64 osx x64 +run_test arm64 smartos x64 + cleanup