Skip to content

Commit

Permalink
[Fix] nvm_get_arch: Rasbperry Pi: armv7l with arm64 kernel, get cor…
Browse files Browse the repository at this point in the history
…rect arch

Co-authored-by: Botspot <[email protected]>
Co-authored-by: Jordan Harband <[email protected]>
Co-authored-by: Sladyn Nunes <[email protected]>
  • Loading branch information
3 people committed Mar 22, 2021
1 parent 2b5e53f commit 779a34e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

Expand Down
2 changes: 2 additions & 0 deletions test/fast/Unit tests/nvm_get_arch
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 779a34e

Please sign in to comment.