From a32b914bab639d308f41b84a55256d42c5afac1a Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Fri, 29 Jul 2016 13:51:06 -0700 Subject: [PATCH] Fix nvm on SmartOS setups using 64 bits pkgsrc repository On SmartOS setups using 64 bits pkgsrc repositories, `nvm_get_arch` would not handle pkg_info's output properly. This would result in nvm not being to install any node binary when running on SmartOS setups using a 64 bits pkgsrc repository. This change fixes this problem, and fixes the tests suite on similar setups. --- nvm.sh | 2 ++ test/fast/Unit tests/nvm_get_arch | 2 ++ test/mocks/pkg_info_amd64 | 3 +++ test/mocks/pkg_info_fail | 1 + 4 files changed, 8 insertions(+) create mode 100755 test/mocks/pkg_info_fail diff --git a/nvm.sh b/nvm.sh index 3559367..aad67e1 100644 --- a/nvm.sh +++ b/nvm.sh @@ -1235,6 +1235,8 @@ nvm_get_arch() { EXIT_CODE=$? if [ $EXIT_CODE -ne 0 ]; then HOST_ARCH=$(isainfo -n) + else + HOST_ARCH=$(echo "$HOST_ARCH" | tail -1) fi else HOST_ARCH="$(command uname -m)" diff --git a/test/fast/Unit tests/nvm_get_arch b/test/fast/Unit tests/nvm_get_arch index b3fd51b..102c9da 100755 --- a/test/fast/Unit tests/nvm_get_arch +++ b/test/fast/Unit tests/nvm_get_arch @@ -32,6 +32,8 @@ setup_mock_arch() { ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo if [ "_$OPT" != "_no_pkg_info" ]; then ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info + else + ln -sf "${MOCKS_DIR}/pkg_info_fail" ./pkg_info fi fi diff --git a/test/mocks/pkg_info_amd64 b/test/mocks/pkg_info_amd64 index 8437c2b..d25c527 100755 --- a/test/mocks/pkg_info_amd64 +++ b/test/mocks/pkg_info_amd64 @@ -1 +1,4 @@ +# On SmartOS 64bits setups, pkg_info outputs _both_ i386 and x86_64 +# architectures as architectures supported by pkg_install. +echo "i386" echo "x86_64" diff --git a/test/mocks/pkg_info_fail b/test/mocks/pkg_info_fail new file mode 100755 index 0000000..379a4c9 --- /dev/null +++ b/test/mocks/pkg_info_fail @@ -0,0 +1 @@ +exit 1