Merge pull request #1204 from ljharb/iojs_source
[New] [Refactor] Rewrite installation code path
commit
6784767bea
|
@ -1,5 +1,5 @@
|
||||||
HEAD
|
HEAD
|
||||||
src
|
.cache
|
||||||
v*
|
v*
|
||||||
alias
|
alias
|
||||||
|
|
||||||
|
|
14
.travis.yml
14
.travis.yml
|
@ -1,11 +1,19 @@
|
||||||
language: generic
|
language: generic
|
||||||
|
sudo: required
|
||||||
addons:
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- gcc-4.8
|
||||||
|
- g++-4.8
|
||||||
apt_packages:
|
apt_packages:
|
||||||
- zsh
|
- zsh
|
||||||
- ksh
|
- ksh
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.stack
|
- $HOME/.stack
|
||||||
|
- $TRAVIS_BUILD_DIR/.cache
|
||||||
before_install:
|
before_install:
|
||||||
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
|
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
|
||||||
- curl --version
|
- curl --version
|
||||||
|
@ -16,6 +24,8 @@ install:
|
||||||
- chmod +x /tmp/urchin/package/urchin
|
- chmod +x /tmp/urchin/package/urchin
|
||||||
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
|
||||||
script:
|
script:
|
||||||
|
- export CXX=g++-4.8
|
||||||
|
- export CC=gcc-4.8
|
||||||
- export PATH=$(echo $PATH | sed 's/::/:/')
|
- export PATH=$(echo $PATH | sed 's/::/:/')
|
||||||
- export NVM_DIR="${TRAVIS_BUILD_DIR}"
|
- export NVM_DIR="${TRAVIS_BUILD_DIR}"
|
||||||
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash nvm.sh && shellcheck -s sh nvm.sh && shellcheck -s dash nvm.sh && shellcheck -s ksh nvm.sh && shellcheck -s bash install.sh ; fi
|
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash nvm.sh && shellcheck -s sh nvm.sh && shellcheck -s dash nvm.sh && shellcheck -s ksh nvm.sh && shellcheck -s bash install.sh ; fi
|
||||||
|
|
660
nvm.sh
660
nvm.sh
|
@ -1036,6 +1036,111 @@ nvm_get_checksum_alg() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_compute_checksum() {
|
||||||
|
local FILE
|
||||||
|
FILE="${1-}"
|
||||||
|
if [ -z "${FILE}" ]; then
|
||||||
|
nvm_err 'Provided file to checksum is empty.'
|
||||||
|
return 2
|
||||||
|
elif ! [ -f "${FILE}" ]; then
|
||||||
|
nvm_err 'Provided file to checksum does not exist.'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if nvm_has "sha256sum" && ! nvm_is_alias "sha256sum"; then
|
||||||
|
nvm_err 'Computing checksum with sha256sum'
|
||||||
|
command sha256sum "${FILE}" | command awk '{print $1}'
|
||||||
|
elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then
|
||||||
|
nvm_err 'Computing checksum with shasum -a 256'
|
||||||
|
command shasum -a 256 "${FILE}" | command awk '{print $1}'
|
||||||
|
elif nvm_has "sha256" && ! nvm_is_alias "sha256"; then
|
||||||
|
nvm_err 'Computing checksum with sha256 -q'
|
||||||
|
command sha256 -q "${FILE}" | command awk '{print $1}'
|
||||||
|
elif nvm_has "gsha256sum" && ! nvm_is_alias "gsha256sum"; then
|
||||||
|
nvm_err 'Computing checksum with gsha256sum'
|
||||||
|
command gsha256sum "${FILE}" | command awk '{print $1}'
|
||||||
|
elif nvm_has "openssl" && ! nvm_is_alias "openssl"; then
|
||||||
|
nvm_err 'Computing checksum with openssl dgst -sha256'
|
||||||
|
command openssl dgst -sha256 "${FILE}" | rev | command awk '{print $1}' | rev
|
||||||
|
elif nvm_has "libressl" && ! nvm_is_alias "libressl"; then
|
||||||
|
nvm_err 'Computing checksum with libressl dgst -sha256'
|
||||||
|
command libressl dgst -sha256 "${FILE}" | rev | command awk '{print $1}' | rev
|
||||||
|
elif nvm_has "bssl" && ! nvm_is_alias "bssl"; then
|
||||||
|
nvm_err 'Computing checksum with bssl sha256sum'
|
||||||
|
command bssl sha256sum "${FILE}" | command awk '{print $1}'
|
||||||
|
elif nvm_has "sha1sum" && ! nvm_is_alias "sha1sum"; then
|
||||||
|
nvm_err 'Computing checksum with sha1sum'
|
||||||
|
command sha1sum "${FILE}" | command awk '{print $1}'
|
||||||
|
elif nvm_has "sha1" && ! nvm_is_alias "sha1"; then
|
||||||
|
nvm_err 'Computing checksum with sha1 -q'
|
||||||
|
command sha1 -q "${FILE}"
|
||||||
|
elif nvm_has "shasum" && ! nvm_is_alias "shasum"; then
|
||||||
|
nvm_err 'Computing checksum with shasum'
|
||||||
|
command shasum "${FILE}" | command awk '{print $1}'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_compare_checksum() {
|
||||||
|
local FILE
|
||||||
|
FILE="${1-}"
|
||||||
|
if [ -z "${FILE}" ]; then
|
||||||
|
nvm_err 'Provided file to checksum is empty.'
|
||||||
|
return 4
|
||||||
|
elif ! [ -f "${FILE}" ]; then
|
||||||
|
nvm_err 'Provided file to checksum does not exist.'
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
local COMPUTED_SUM
|
||||||
|
COMPUTED_SUM="$(nvm_compute_checksum "${FILE}")"
|
||||||
|
|
||||||
|
local CHECKSUM
|
||||||
|
CHECKSUM="${2-}"
|
||||||
|
if [ -z "${CHECKSUM}" ]; then
|
||||||
|
nvm_err 'Provided checksum to compare to is empty.'
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${COMPUTED_SUM}" ]; then
|
||||||
|
nvm_err "Computed checksum of '${FILE}' is empty." # missing in raspberry pi binary
|
||||||
|
nvm_err 'WARNING: Continuing *without checksum verification*'
|
||||||
|
return
|
||||||
|
elif [ "${COMPUTED_SUM}" != "${CHECKSUM}" ]; then
|
||||||
|
nvm_err "Checksums do not match: '${COMPUTED_SUM}' found, '${CHECKSUM}' expected."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
nvm_err 'Checksums matched!'
|
||||||
|
}
|
||||||
|
|
||||||
|
# args: flavor, type, version, slug, compression
|
||||||
|
nvm_get_checksum() {
|
||||||
|
local FLAVOR
|
||||||
|
case "${1-}" in
|
||||||
|
node | iojs) FLAVOR="${1}" ;;
|
||||||
|
*)
|
||||||
|
nvm_err 'supported flavors: node, iojs'
|
||||||
|
return 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local MIRROR
|
||||||
|
MIRROR="$(nvm_get_mirror "${FLAVOR}" "${2-}")"
|
||||||
|
if [ -z "${MIRROR}" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local SHASUMS_URL
|
||||||
|
if [ "$(nvm_get_checksum_alg)" = 'sha-256' ]; then
|
||||||
|
SHASUMS_URL="${MIRROR}/${3}/SHASUMS256.txt"
|
||||||
|
else
|
||||||
|
SHASUMS_URL="${MIRROR}/${3}/SHASUMS.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvm_download -L -s "${SHASUMS_URL}" -o - | \
|
||||||
|
nvm_grep "${4}.tar.${5}" | \
|
||||||
|
command awk '{print $1}'
|
||||||
|
}
|
||||||
|
|
||||||
nvm_checksum() {
|
nvm_checksum() {
|
||||||
local NVM_CHECKSUM
|
local NVM_CHECKSUM
|
||||||
if [ -z "${3-}" ] || [ "${3-}" = 'sha1' ]; then
|
if [ -z "${3-}" ] || [ "${3-}" = 'sha1' ]; then
|
||||||
|
@ -1304,7 +1409,7 @@ nvm_get_arch() {
|
||||||
if [ $EXIT_CODE -ne 0 ]; then
|
if [ $EXIT_CODE -ne 0 ]; then
|
||||||
HOST_ARCH=$(isainfo -n)
|
HOST_ARCH=$(isainfo -n)
|
||||||
else
|
else
|
||||||
HOST_ARCH=$(echo "$HOST_ARCH" | tail -1)
|
HOST_ARCH=$(echo "$HOST_ARCH" | command tail -1)
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
HOST_ARCH="$(command uname -m)"
|
HOST_ARCH="$(command uname -m)"
|
||||||
|
@ -1382,211 +1487,201 @@ nvm_get_mirror() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_install_merged_node_binary() {
|
# args: flavor, kind, version, reinstall
|
||||||
local NVM_NODE_TYPE
|
nvm_install_binary() {
|
||||||
NVM_NODE_TYPE="${1}"
|
local FLAVOR
|
||||||
local MIRROR
|
case "${1-}" in
|
||||||
if [ "${NVM_NODE_TYPE}" = 'std' ]; then
|
node | iojs) FLAVOR="${1}" ;;
|
||||||
MIRROR="${NVM_NODEJS_ORG_MIRROR}"
|
*)
|
||||||
else
|
nvm_err 'supported flavors: node, iojs'
|
||||||
nvm_err 'unknown type of node.js release'
|
return 4
|
||||||
return 4
|
;;
|
||||||
fi
|
esac
|
||||||
local VERSION
|
|
||||||
VERSION="${2}"
|
|
||||||
|
|
||||||
if ! nvm_is_merged_node_version "${VERSION}" || nvm_is_iojs_version "${VERSION}"; then
|
local MIRROR
|
||||||
nvm_err 'nvm_install_merged_node_binary requires a node version v4.0 or greater.'
|
MIRROR="$(nvm_get_mirror node "${2-}")"
|
||||||
return 10
|
if [ -z "${MIRROR}" ]; then
|
||||||
|
return 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local PREFIXED_VERSION
|
||||||
|
PREFIXED_VERSION="${3-}"
|
||||||
|
local VERSION
|
||||||
|
VERSION="$(nvm_strip_iojs_prefix "${PREFIXED_VERSION}")"
|
||||||
|
|
||||||
local VERSION_PATH
|
local VERSION_PATH
|
||||||
VERSION_PATH="$(nvm_version_path "${VERSION}")"
|
|
||||||
local NVM_OS
|
|
||||||
NVM_OS="$(nvm_get_os)"
|
|
||||||
local t
|
|
||||||
local url
|
|
||||||
local sum
|
|
||||||
local NODE_PREFIX
|
|
||||||
local compression
|
|
||||||
compression='gz'
|
|
||||||
local tar_compression_flag
|
|
||||||
tar_compression_flag='z'
|
|
||||||
if nvm_supports_xz "${VERSION}"; then
|
|
||||||
compression='xz'
|
|
||||||
tar_compression_flag='J'
|
|
||||||
fi
|
|
||||||
NODE_PREFIX="$(nvm_node_prefix)"
|
|
||||||
|
|
||||||
if [ -z "${NVM_OS}" ]; then
|
if [ -z "$(nvm_get_os)" ]; then
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
t="${VERSION}-${NVM_OS}-$(nvm_get_arch)"
|
local tar_compression_flag
|
||||||
url="${MIRROR}/$VERSION/$NODE_PREFIX-${t}.tar.${compression}"
|
tar_compression_flag='z'
|
||||||
sum="$(
|
if nvm_supports_xz "${VERSION}"; then
|
||||||
nvm_download -L -s "${MIRROR}/${VERSION}/SHASUMS256.txt" -o - \
|
tar_compression_flag='J'
|
||||||
| nvm_grep "${NODE_PREFIX}-${t}.tar.${compression}" \
|
fi
|
||||||
| command awk '{print $1}'
|
|
||||||
)"
|
local TARBALL
|
||||||
local tmpdir
|
local TMPDIR
|
||||||
tmpdir="${NVM_DIR}/bin/node-${t}"
|
local VERSION_PATH
|
||||||
local tmptarball
|
|
||||||
tmptarball="${tmpdir}/node-${t}.tar.${compression}"
|
TARBALL="$(nvm_download_artifact "${FLAVOR}" binary std "${VERSION}" | command tail -1)"
|
||||||
local NVM_INSTALL_ERRORED
|
if [ -f "${TARBALL}" ]; then
|
||||||
command mkdir -p "${tmpdir}" && \
|
TMPDIR="$(dirname "${TARBALL}")/files"
|
||||||
nvm_echo "Downloading ${url}..." && \
|
|
||||||
nvm_download -L -C - --progress-bar "${url}" -o "${tmptarball}" || \
|
|
||||||
NVM_INSTALL_ERRORED=true
|
|
||||||
if nvm_grep '404 Not Found' "${tmptarball}" >/dev/null; then
|
|
||||||
NVM_INSTALL_ERRORED=true
|
|
||||||
nvm_err "HTTP 404 at URL $url";
|
|
||||||
fi
|
fi
|
||||||
if (
|
if (
|
||||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
[ -n "${TMPDIR-}" ] && \
|
||||||
nvm_checksum "${tmptarball}" "${sum}" "{sha256}" && \
|
command mkdir -p "${TMPDIR}" && \
|
||||||
command tar -x${tar_compression_flag}f "${tmptarball}" -C "${tmpdir}" --strip-components 1 && \
|
command tar -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
|
||||||
command rm -f "${tmptarball}" && \
|
VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
|
||||||
command mkdir -p "${VERSION_PATH}" && \
|
command mkdir -p "${VERSION_PATH}" && \
|
||||||
command mv "${tmpdir}"/* "${VERSION_PATH}"
|
command mv "${TMPDIR}/"* "${VERSION_PATH}" && \
|
||||||
|
command rm -rf "${TMPDIR}"
|
||||||
); then
|
); then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nvm_err 'Binary download failed, trying source.'
|
nvm_err 'Binary download failed, trying source.'
|
||||||
command rm -rf "${tmptarball}" "${tmpdir}"
|
if [ -n "${TMPDIR-}" ]; then
|
||||||
|
command rm -rf "${TMPDIR}"
|
||||||
|
fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_install_iojs_binary() {
|
# args: flavor, kind, version
|
||||||
local NVM_IOJS_TYPE
|
nvm_get_download_slug() {
|
||||||
NVM_IOJS_TYPE="$1"
|
local FLAVOR
|
||||||
local MIRROR
|
case "${1-}" in
|
||||||
if [ "_$NVM_IOJS_TYPE" = "_std" ]; then
|
node | iojs) FLAVOR="${1}" ;;
|
||||||
MIRROR="$NVM_IOJS_ORG_MIRROR"
|
*)
|
||||||
else
|
nvm_err 'supported flavors: node, iojs'
|
||||||
nvm_err 'unknown type of io.js release'
|
return 1
|
||||||
return 4
|
;;
|
||||||
fi
|
esac
|
||||||
local PREFIXED_VERSION
|
|
||||||
PREFIXED_VERSION="$2"
|
|
||||||
|
|
||||||
if ! nvm_is_iojs_version "$PREFIXED_VERSION"; then
|
local KIND
|
||||||
nvm_err 'nvm_install_iojs_binary requires an iojs-prefixed version.'
|
case "${2-}" in
|
||||||
return 10
|
binary | source) KIND="${2}" ;;
|
||||||
fi
|
*)
|
||||||
|
nvm_err 'supported kinds: binary, source'
|
||||||
|
return 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$(nvm_strip_iojs_prefix "$PREFIXED_VERSION")"
|
VERSION="${3}"
|
||||||
local VERSION_PATH
|
|
||||||
VERSION_PATH="$(nvm_version_path "$PREFIXED_VERSION")"
|
|
||||||
local NVM_OS
|
local NVM_OS
|
||||||
NVM_OS="$(nvm_get_os)"
|
NVM_OS="$(nvm_get_os)"
|
||||||
local t
|
|
||||||
local url
|
|
||||||
local sum
|
|
||||||
local compression
|
|
||||||
compression="gz"
|
|
||||||
local tar_compression_flag
|
|
||||||
tar_compression_flag="x"
|
|
||||||
if nvm_supports_xz "$VERSION"; then
|
|
||||||
compression="xz"
|
|
||||||
tar_compression_flag="J"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$NVM_OS" ]; then
|
local NVM_ARCH
|
||||||
if nvm_binary_available "$VERSION"; then
|
NVM_ARCH="$(nvm_get_arch)"
|
||||||
t="$VERSION-$NVM_OS-$(nvm_get_arch)"
|
if ! nvm_is_merged_node_version "${VERSION}"; then
|
||||||
url="$MIRROR/$VERSION/$(nvm_iojs_prefix)-${t}.tar.${compression}"
|
if [ "${NVM_ARCH}" = 'armv6l' ] || [ "${NVM_ARCH}" = 'armv7l' ]; then
|
||||||
sum="$(nvm_download -L -s "$MIRROR/$VERSION/SHASUMS256.txt" -o - | nvm_grep "$(nvm_iojs_prefix)-${t}.tar.${compression}" | command awk '{print $1}')"
|
NVM_ARCH="arm-pi"
|
||||||
local tmpdir
|
|
||||||
tmpdir="$NVM_DIR/bin/iojs-${t}"
|
|
||||||
local tmptarball
|
|
||||||
tmptarball="$tmpdir/iojs-${t}.tar.${compression}"
|
|
||||||
local NVM_INSTALL_ERRORED
|
|
||||||
command mkdir -p "$tmpdir" && \
|
|
||||||
nvm_echo "Downloading $url..." && \
|
|
||||||
nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \
|
|
||||||
NVM_INSTALL_ERRORED=true
|
|
||||||
if nvm_grep '404 Not Found' "$tmptarball" >/dev/null; then
|
|
||||||
NVM_INSTALL_ERRORED=true
|
|
||||||
nvm_err "HTTP 404 at URL $url";
|
|
||||||
fi
|
|
||||||
if (
|
|
||||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
|
||||||
nvm_checksum "$tmptarball" "$sum" "sha256" && \
|
|
||||||
command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
|
||||||
command rm -f "$tmptarball" && \
|
|
||||||
command mkdir -p "$VERSION_PATH" && \
|
|
||||||
command mv "$tmpdir"/* "$VERSION_PATH"
|
|
||||||
); then
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
nvm_err 'Binary download failed, trying source.'
|
|
||||||
command rm -rf "$tmptarball" "$tmpdir"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
return 2
|
|
||||||
|
if [ "${KIND}" = 'binary' ]; then
|
||||||
|
nvm_echo "${FLAVOR}-${VERSION}-${NVM_OS}-${NVM_ARCH}"
|
||||||
|
elif [ "${KIND}" = 'source' ]; then
|
||||||
|
nvm_echo "${FLAVOR}-${VERSION}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_install_node_binary() {
|
# args: flavor, kind, type, version
|
||||||
|
nvm_download_artifact() {
|
||||||
|
local FLAVOR
|
||||||
|
case "${1-}" in
|
||||||
|
node | iojs) FLAVOR="${1}" ;;
|
||||||
|
*)
|
||||||
|
nvm_err 'supported flavors: node, iojs'
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local KIND
|
||||||
|
case "${2-}" in
|
||||||
|
binary | source) KIND="${2}" ;;
|
||||||
|
*)
|
||||||
|
nvm_err 'supported kinds: binary, source'
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local TYPE
|
||||||
|
TYPE="${3-}"
|
||||||
|
|
||||||
|
local MIRROR
|
||||||
|
MIRROR="$(nvm_get_mirror "${FLAVOR}" "${TYPE}")"
|
||||||
|
if [ -z "${MIRROR}" ]; then
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="${4}"
|
||||||
|
|
||||||
if nvm_is_iojs_version "$VERSION"; then
|
if [ "${KIND}" = 'binary' ] && ! nvm_binary_available "${VERSION}"; then
|
||||||
nvm_err 'nvm_install_node_binary does not allow an iojs-prefixed version.'
|
nvm_err "No precompiled binary available for ${VERSION}."
|
||||||
return 10
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local VERSION_PATH
|
local SLUG
|
||||||
VERSION_PATH="$(nvm_version_path "$VERSION")"
|
SLUG="$(nvm_get_download_slug "${FLAVOR}" "${KIND}" "${VERSION}")"
|
||||||
local NVM_OS
|
|
||||||
NVM_OS="$(nvm_get_os)"
|
|
||||||
local t
|
|
||||||
local url
|
|
||||||
local sum
|
|
||||||
|
|
||||||
if [ -n "$NVM_OS" ]; then
|
local COMPRESSION
|
||||||
if nvm_binary_available "$VERSION"; then
|
COMPRESSION='gz'
|
||||||
local NVM_ARCH
|
if nvm_supports_xz "${VERSION}"; then
|
||||||
NVM_ARCH="$(nvm_get_arch)"
|
COMPRESSION='xz'
|
||||||
if [ "_$NVM_ARCH" = '_armv6l' ] || [ "_$NVM_ARCH" = 'armv7l' ]; then
|
fi
|
||||||
NVM_ARCH="arm-pi"
|
|
||||||
fi
|
local CHECKSUM
|
||||||
t="$VERSION-$NVM_OS-$NVM_ARCH"
|
CHECKSUM="$(nvm_get_checksum "${FLAVOR}" "${TYPE}" "${VERSION}" "${SLUG}" "${COMPRESSION}")"
|
||||||
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
|
|
||||||
sum=$(nvm_download -L -s "$NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt" -o - | nvm_grep "node-${t}.tar.gz" | command awk '{print $1}')
|
local tmpdir
|
||||||
local tmpdir
|
if [ "${KIND}" = 'binary' ]; then
|
||||||
tmpdir="$NVM_DIR/bin/node-${t}"
|
tmpdir="$(nvm_cache_dir)/bin/${SLUG}"
|
||||||
local tmptarball
|
else
|
||||||
tmptarball="$tmpdir/node-${t}.tar.gz"
|
tmpdir="$(nvm_cache_dir)/src/${SLUG}"
|
||||||
local NVM_INSTALL_ERRORED
|
fi
|
||||||
command mkdir -p "$tmpdir" && \
|
command mkdir -p "${tmpdir}/files" || (
|
||||||
nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \
|
nvm_err "creating directory ${tmpdir}/files failed"
|
||||||
NVM_INSTALL_ERRORED=true
|
return 3
|
||||||
if nvm_grep '404 Not Found' "$tmptarball" >/dev/null; then
|
)
|
||||||
NVM_INSTALL_ERRORED=true
|
|
||||||
nvm_err "HTTP 404 at URL $url";
|
local TARBALL
|
||||||
fi
|
TARBALL="${tmpdir}/${SLUG}.tar.${COMPRESSION}"
|
||||||
if (
|
local TARBALL_URL
|
||||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
if nvm_version_greater_than_or_equal_to "${VERSION}" 0.1.14; then
|
||||||
nvm_checksum "$tmptarball" "$sum" && \
|
TARBALL_URL="${MIRROR}/${VERSION}/${SLUG}.tar.${COMPRESSION}"
|
||||||
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
else
|
||||||
command rm -f "$tmptarball" && \
|
# node <= 0.1.13 does not have a directory
|
||||||
command mkdir -p "$VERSION_PATH" && \
|
TARBALL_URL="${MIRROR}/${SLUG}.tar.${COMPRESSION}"
|
||||||
command mv "$tmpdir"/* "$VERSION_PATH"
|
fi
|
||||||
); then
|
|
||||||
return 0
|
if nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" >/dev/null 2>&1; then
|
||||||
else
|
nvm_err "Checksums match! Using existing downloaded archive $(nvm_sanitize_path "${TARBALL}")"
|
||||||
nvm_err 'Binary download failed, trying source.'
|
else
|
||||||
command rm -rf "$tmptarball" "$tmpdir"
|
nvm_echo "Downloading ${TARBALL_URL}..."
|
||||||
return 1
|
nvm_download -L -C - --progress-bar "${TARBALL_URL}" -o "${TARBALL}" || (
|
||||||
fi
|
command rm -rf "${TARBALL}" "${tmpdir}"
|
||||||
|
nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
|
||||||
|
return 4
|
||||||
|
)
|
||||||
|
|
||||||
|
if nvm_grep '404 Not Found' "${TARBALL}" >/dev/null; then
|
||||||
|
command rm -rf "${TARBALL}" "$tmpdir"
|
||||||
|
nvm_err "HTTP 404 at URL ${TARBALL_URL}";
|
||||||
|
return 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" || (
|
||||||
|
command rm -rf "${tmpdir}/files"
|
||||||
|
return 6
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
return 2
|
|
||||||
|
nvm_echo "${TARBALL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_get_make_jobs() {
|
nvm_get_make_jobs() {
|
||||||
|
@ -1624,67 +1719,76 @@ nvm_get_make_jobs() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_install_node_source() {
|
# args: flavor, type, version, make jobs, additional
|
||||||
|
nvm_install_source() {
|
||||||
|
local FLAVOR
|
||||||
|
case "${1-}" in
|
||||||
|
node | iojs) FLAVOR="${1}" ;;
|
||||||
|
*)
|
||||||
|
nvm_err 'supported flavors: node, iojs'
|
||||||
|
return 4
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
local TYPE
|
||||||
|
TYPE="${2-}"
|
||||||
|
|
||||||
|
local PREFIXED_VERSION
|
||||||
|
PREFIXED_VERSION="${3-}"
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="$(nvm_strip_iojs_prefix "${PREFIXED_VERSION}")"
|
||||||
|
|
||||||
local NVM_MAKE_JOBS
|
local NVM_MAKE_JOBS
|
||||||
NVM_MAKE_JOBS="$2"
|
NVM_MAKE_JOBS="${4-}"
|
||||||
|
|
||||||
local ADDITIONAL_PARAMETERS
|
local ADDITIONAL_PARAMETERS
|
||||||
ADDITIONAL_PARAMETERS="$3"
|
ADDITIONAL_PARAMETERS="${5-}"
|
||||||
|
|
||||||
local NVM_ARCH
|
local NVM_ARCH
|
||||||
NVM_ARCH="$(nvm_get_arch)"
|
NVM_ARCH="$(nvm_get_arch)"
|
||||||
if [ "_$NVM_ARCH" = '_armv6l' ] || [ "_$NVM_ARCH" = '_armv7l' ]; then
|
if [ "${NVM_ARCH}" = 'armv6l' ] || [ "${NVM_ARCH}" = 'armv7l' ]; then
|
||||||
ADDITIONAL_PARAMETERS="--without-snapshot $ADDITIONAL_PARAMETERS"
|
ADDITIONAL_PARAMETERS="--without-snapshot ${ADDITIONAL_PARAMETERS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$ADDITIONAL_PARAMETERS" ]; then
|
if [ -n "${ADDITIONAL_PARAMETERS}" ]; then
|
||||||
nvm_echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
|
nvm_echo "Additional options while compiling: ${ADDITIONAL_PARAMETERS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local VERSION_PATH
|
|
||||||
VERSION_PATH="$(nvm_version_path "$VERSION")"
|
|
||||||
local NVM_OS
|
local NVM_OS
|
||||||
NVM_OS="$(nvm_get_os)"
|
NVM_OS="$(nvm_get_os)"
|
||||||
|
|
||||||
local tarball
|
|
||||||
tarball=''
|
|
||||||
local sum
|
|
||||||
sum=''
|
|
||||||
local make
|
local make
|
||||||
make='make'
|
make='make'
|
||||||
if [ "_$NVM_OS" = "_freebsd" ]; then
|
if [ "${NVM_OS}" = 'freebsd' ]; then
|
||||||
make='gmake'
|
make='gmake'
|
||||||
MAKE_CXX="CXX=c++"
|
MAKE_CXX='CXX=c++'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local tmpdir
|
local tar_compression_flag
|
||||||
tmpdir="$NVM_DIR/src"
|
tar_compression_flag='z'
|
||||||
local tmptarball
|
if nvm_supports_xz "${VERSION}"; then
|
||||||
tmptarball="$tmpdir/node-$VERSION.tar.gz"
|
tar_compression_flag='J'
|
||||||
|
|
||||||
if [ "$(nvm_download -L -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - 2>&1 | nvm_grep '200 OK')" != '' ]; then
|
|
||||||
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
|
|
||||||
sum=$(nvm_download -L -s "$NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt" -o - | nvm_grep "node-${VERSION}.tar.gz" | command awk '{print $1}')
|
|
||||||
elif [ "$(nvm_download -L -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | nvm_grep '200 OK')" != '' ]; then
|
|
||||||
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local TARBALL
|
||||||
|
local TMPDIR
|
||||||
|
local VERSION_PATH
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
if (
|
if (
|
||||||
[ -n "$tarball" ] && \
|
TARBALL="$(nvm_download_artifact "${FLAVOR}" source "${TYPE}" "${VERSION}" | command tail -1)" && \
|
||||||
command mkdir -p "$tmpdir" && \
|
[ -f "${TARBALL}" ] && \
|
||||||
nvm_echo "Downloading $tarball..." && \
|
TMPDIR="$(dirname "${TARBALL}")/files" && \
|
||||||
nvm_download -L --progress-bar "$tarball" -o "$tmptarball" && \
|
command mkdir -p "${TMPDIR}" && \
|
||||||
nvm_checksum "$tmptarball" "$sum" && \
|
command tar -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
|
||||||
command tar -xzf "$tmptarball" -C "$tmpdir" && \
|
VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
|
||||||
cd "$tmpdir/node-$VERSION" && \
|
cd "${TMPDIR}" && \
|
||||||
./configure --prefix="$VERSION_PATH" $ADDITIONAL_PARAMETERS && \
|
./configure --prefix="${VERSION_PATH}" $ADDITIONAL_PARAMETERS && \
|
||||||
$make -j "$NVM_MAKE_JOBS" ${MAKE_CXX-} && \
|
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} && \
|
||||||
command rm -f "$VERSION_PATH" 2>/dev/null && \
|
command rm -f "${VERSION_PATH}" 2>/dev/null && \
|
||||||
$make -j "$NVM_MAKE_JOBS" ${MAKE_CXX-} install
|
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} install && \
|
||||||
)
|
command rm -rf "${TMPDIR}"
|
||||||
then
|
); then
|
||||||
if ! nvm_has "npm" ; then
|
if ! nvm_has "npm" ; then
|
||||||
nvm_echo 'Installing npm...'
|
nvm_echo 'Installing npm...'
|
||||||
if nvm_version_greater 0.2.0 "$VERSION"; then
|
if nvm_version_greater 0.2.0 "$VERSION"; then
|
||||||
|
@ -1699,12 +1803,11 @@ nvm_install_node_source() {
|
||||||
nvm_download -L https://npmjs.org/install.sh -o - | clean=yes sh
|
nvm_download -L https://npmjs.org/install.sh -o - | clean=yes sh
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
return $?
|
||||||
nvm_err "nvm: install $VERSION failed!"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return $?
|
nvm_err "nvm: install ${VERSION} failed!"
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_match_version() {
|
nvm_match_version() {
|
||||||
|
@ -1889,6 +1992,10 @@ nvm_check_file_permissions() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvm_cache_dir() {
|
||||||
|
nvm_echo "${NVM_DIR}/.cache"
|
||||||
|
}
|
||||||
|
|
||||||
nvm() {
|
nvm() {
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
nvm --help
|
nvm --help
|
||||||
|
@ -1957,6 +2064,8 @@ nvm() {
|
||||||
nvm_echo ' nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version'
|
nvm_echo ' nvm reinstall-packages <version> Reinstall global `npm` packages contained in <version> to current version'
|
||||||
nvm_echo ' nvm unload Unload `nvm` from shell'
|
nvm_echo ' nvm unload Unload `nvm` from shell'
|
||||||
nvm_echo ' nvm which [<version>] Display path to installed node version. Uses .nvmrc if available'
|
nvm_echo ' nvm which [<version>] Display path to installed node version. Uses .nvmrc if available'
|
||||||
|
nvm_echo ' nvm cache dir Display path to the cache directory for nvm'
|
||||||
|
nvm_echo ' nvm cache clear Empty cache directory for nvm'
|
||||||
nvm_echo
|
nvm_echo
|
||||||
nvm_echo 'Example:'
|
nvm_echo 'Example:'
|
||||||
nvm_echo ' nvm install v0.10.32 Install a specific version number'
|
nvm_echo ' nvm install v0.10.32 Install a specific version number'
|
||||||
|
@ -1970,6 +2079,26 @@ nvm() {
|
||||||
nvm_echo
|
nvm_echo
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"cache" )
|
||||||
|
case "${1-}" in
|
||||||
|
dir) nvm_cache_dir ;;
|
||||||
|
clear)
|
||||||
|
local DIR
|
||||||
|
DIR="$(nvm_cache_dir)"
|
||||||
|
if command rm -rf "${DIR}" && command mkdir -p "${DIR}"; then
|
||||||
|
nvm_echo 'Cache cleared.'
|
||||||
|
else
|
||||||
|
nvm_err "Unable to clear cache: ${DIR}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
>&2 nvm --help
|
||||||
|
return 127
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
"debug" )
|
"debug" )
|
||||||
local ZSH_HAS_SHWORDSPLIT_UNSET
|
local ZSH_HAS_SHWORDSPLIT_UNSET
|
||||||
ZSH_HAS_SHWORDSPLIT_UNSET=1
|
ZSH_HAS_SHWORDSPLIT_UNSET=1
|
||||||
|
@ -2126,12 +2255,11 @@ nvm() {
|
||||||
return 5
|
return 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NVM_NODE_MERGED
|
local FLAVOR
|
||||||
local NVM_IOJS
|
|
||||||
if nvm_is_iojs_version "$VERSION"; then
|
if nvm_is_iojs_version "$VERSION"; then
|
||||||
NVM_IOJS=true
|
FLAVOR="$(nvm_iojs_prefix)"
|
||||||
elif nvm_is_merged_node_version "$VERSION"; then
|
else
|
||||||
NVM_NODE_MERGED=true
|
FLAVOR="$(nvm_node_prefix)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if nvm_is_version_installed "$VERSION"; then
|
if nvm_is_version_installed "$VERSION"; then
|
||||||
|
@ -2158,14 +2286,11 @@ nvm() {
|
||||||
nvm_err "Currently, there is no binary of version $VERSION for $NVM_OS"
|
nvm_err "Currently, there is no binary of version $VERSION for $NVM_OS"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local NVM_INSTALL_SUCCESS
|
local NVM_INSTALL_SUCCESS
|
||||||
# skip binary install if "nobinary" option specified.
|
# skip binary install if "nobinary" option specified.
|
||||||
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
|
if [ $nobinary -ne 1 ] && nvm_binary_available "$VERSION"; then
|
||||||
if [ "$NVM_IOJS" = true ] && nvm_install_iojs_binary std "$VERSION"; then
|
if nvm_install_binary "${FLAVOR}" std "${VERSION}"; then
|
||||||
NVM_INSTALL_SUCCESS=true
|
|
||||||
elif [ "$NVM_NODE_MERGED" = true ] && nvm_install_merged_node_binary std "$VERSION"; then
|
|
||||||
NVM_INSTALL_SUCCESS=true
|
|
||||||
elif [ "$NVM_IOJS" != true ] && nvm_install_node_binary "$VERSION"; then
|
|
||||||
NVM_INSTALL_SUCCESS=true
|
NVM_INSTALL_SUCCESS=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -2174,23 +2299,9 @@ nvm() {
|
||||||
nvm_get_make_jobs
|
nvm_get_make_jobs
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "true" in
|
if nvm_install_source "${FLAVOR}" std "${VERSION}" "${NVM_MAKE_JOBS}" "${ADDITIONAL_PARAMETERS}"; then
|
||||||
"$NVM_IOJS")
|
NVM_INSTALL_SUCCESS=true
|
||||||
# nvm_install_iojs_source "$VERSION" "$NVM_MAKE_JOBS" "$ADDITIONAL_PARAMETERS"
|
fi
|
||||||
nvm_err 'Installing iojs from source is not currently supported'
|
|
||||||
return 105
|
|
||||||
;;
|
|
||||||
"$NVM_NODE_MERGED")
|
|
||||||
# nvm_install_merged_node_source "$VERSION" "$NVM_MAKE_JOBS" "$ADDITIONAL_PARAMETERS"
|
|
||||||
nvm_err 'Installing node v1.0 and greater from source is not currently supported'
|
|
||||||
return 106
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if nvm_install_node_source "$VERSION" "$NVM_MAKE_JOBS" "$ADDITIONAL_PARAMETERS"; then
|
|
||||||
NVM_INSTALL_SUCCESS=true
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then
|
if [ "$NVM_INSTALL_SUCCESS" = true ] && nvm use "$VERSION"; then
|
||||||
|
@ -2226,50 +2337,56 @@ nvm() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "_$VERSION" = "_$(nvm_ls_current)" ]; then
|
if [ "_${VERSION}" = "_$(nvm_ls_current)" ]; then
|
||||||
if nvm_is_iojs_version "$VERSION"; then
|
if nvm_is_iojs_version "${VERSION}"; then
|
||||||
nvm_err "nvm: Cannot uninstall currently-active io.js version, $VERSION (inferred from $PATTERN)."
|
nvm_err "nvm: Cannot uninstall currently-active io.js version, ${VERSION} (inferred from ${PATTERN})."
|
||||||
else
|
else
|
||||||
nvm_err "nvm: Cannot uninstall currently-active node version, $VERSION (inferred from $PATTERN)."
|
nvm_err "nvm: Cannot uninstall currently-active node version, ${VERSION} (inferred from ${PATTERN})."
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! nvm_is_version_installed "$VERSION"; then
|
if ! nvm_is_version_installed "${VERSION}"; then
|
||||||
nvm_err "$VERSION version is not installed..."
|
nvm_err "${VERSION} version is not installed..."
|
||||||
return;
|
return;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
t="$VERSION-$(nvm_get_os)-$(nvm_get_arch)"
|
local SLUG_BINARY
|
||||||
|
local SLUG_SOURCE
|
||||||
local NVM_PREFIX
|
if nvm_is_iojs_version "${VERSION}"; then
|
||||||
local NVM_SUCCESS_MSG
|
SLUG_BINARY="$(nvm_get_download_slug iojs binary std "${VERSION}")"
|
||||||
if nvm_is_iojs_version "$VERSION"; then
|
SLUG_SOURCE="$(nvm_get_download_slug iojs source std "${VERSION}")"
|
||||||
NVM_PREFIX="$(nvm_iojs_prefix)"
|
|
||||||
NVM_SUCCESS_MSG="Uninstalled io.js $(nvm_strip_iojs_prefix "$VERSION")"
|
|
||||||
else
|
else
|
||||||
NVM_PREFIX="$(nvm_node_prefix)"
|
SLUG_BINARY="$(nvm_get_download_slug node binary std "${VERSION}")"
|
||||||
NVM_SUCCESS_MSG="Uninstalled node $VERSION"
|
SLUG_SOURCE="$(nvm_get_download_slug node source std "${VERSION}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local NVM_SUCCESS_MSG
|
||||||
|
if nvm_is_iojs_version "${VERSION}"; then
|
||||||
|
NVM_SUCCESS_MSG="Uninstalled io.js $(nvm_strip_iojs_prefix "${VERSION}")"
|
||||||
|
else
|
||||||
|
NVM_SUCCESS_MSG="Uninstalled node ${VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local VERSION_PATH
|
local VERSION_PATH
|
||||||
VERSION_PATH="$(nvm_version_path "$VERSION")"
|
VERSION_PATH="$(nvm_version_path "${VERSION}")"
|
||||||
if ! nvm_check_file_permissions "$VERSION_PATH"; then
|
if ! nvm_check_file_permissions "${VERSION_PATH}"; then
|
||||||
nvm_err 'Cannot uninstall, incorrect permissions on installation folder.'
|
nvm_err 'Cannot uninstall, incorrect permissions on installation folder.'
|
||||||
nvm_err 'This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again.'
|
nvm_err 'This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again.'
|
||||||
nvm_err
|
nvm_err
|
||||||
nvm_err " chown -R $(whoami) \"$(nvm_sanitize_path "$VERSION_PATH")\""
|
nvm_err " chown -R $(whoami) \"$(nvm_sanitize_path "${VERSION_PATH}")\""
|
||||||
nvm_err " chmod -R u+w \"$(nvm_sanitize_path "$VERSION_PATH")\""
|
nvm_err " chmod -R u+w \"$(nvm_sanitize_path "${VERSION_PATH}")\""
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Delete all files related to target version.
|
# Delete all files related to target version.
|
||||||
command rm -rf "$NVM_DIR/src/$NVM_PREFIX-$VERSION" \
|
local CACHE_DIR
|
||||||
"$NVM_DIR/src/$NVM_PREFIX-$VERSION.tar.*" \
|
CACHE_DIR="$(nvm_cache_dir)"
|
||||||
"$NVM_DIR/bin/$NVM_PREFIX-${t}" \
|
command rm -rf \
|
||||||
"$NVM_DIR/bin/$NVM_PREFIX-${t}.tar.*" \
|
"${CACHE_DIR}/bin/${SLUG_BINARY}/files" \
|
||||||
"$VERSION_PATH" 2>/dev/null
|
"${CACHE_DIR}/src/${SLUG_SOURCE}/files" \
|
||||||
nvm_echo "$NVM_SUCCESS_MSG"
|
"${VERSION_PATH}" 2>/dev/null
|
||||||
|
nvm_echo "${NVM_SUCCESS_MSG}"
|
||||||
|
|
||||||
# rm any aliases that point to uninstalled version.
|
# rm any aliases that point to uninstalled version.
|
||||||
for ALIAS in $(nvm_grep -l "$VERSION" "$(nvm_alias_path)/*" 2>/dev/null)
|
for ALIAS in $(nvm_grep -l "$VERSION" "$(nvm_alias_path)/*" 2>/dev/null)
|
||||||
|
@ -2923,16 +3040,17 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | nvm_grep -v "N/A" | command sed '/^$/d')"
|
||||||
nvm_echo '0.31.7'
|
nvm_echo '0.31.7'
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"unload" )
|
||||||
unset -f nvm nvm_print_versions nvm_checksum \
|
unset -f nvm \
|
||||||
nvm_iojs_prefix nvm_node_prefix \
|
nvm_iojs_prefix nvm_node_prefix \
|
||||||
nvm_add_iojs_prefix nvm_strip_iojs_prefix \
|
nvm_add_iojs_prefix nvm_strip_iojs_prefix \
|
||||||
nvm_is_iojs_version nvm_is_alias \
|
nvm_is_iojs_version nvm_is_alias \
|
||||||
nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \
|
nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \
|
||||||
nvm_ls nvm_remote_version nvm_remote_versions \
|
nvm_ls nvm_remote_version nvm_remote_versions \
|
||||||
nvm_install_iojs_binary nvm_install_node_binary \
|
nvm_install_binary \
|
||||||
nvm_install_merged_node_binary nvm_get_mirror \
|
nvm_get_mirror nvm_get_download_slug nvm_download_artifact \
|
||||||
nvm_install_node_source nvm_check_file_permissions \
|
nvm_install_source nvm_check_file_permissions \
|
||||||
nvm_get_checksum_alg \
|
nvm_print_versions nvm_compute_checksum nvm_checksum \
|
||||||
|
nvm_get_checksum_alg nvm_get_checksum nvm_compare_checksum \
|
||||||
nvm_version nvm_rc_version nvm_match_version \
|
nvm_version nvm_rc_version nvm_match_version \
|
||||||
nvm_ensure_default_set nvm_get_arch nvm_get_os \
|
nvm_ensure_default_set nvm_get_arch nvm_get_os \
|
||||||
nvm_print_implicit_alias nvm_validate_implicit_alias \
|
nvm_print_implicit_alias nvm_validate_implicit_alias \
|
||||||
|
@ -2956,7 +3074,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | nvm_grep -v "N/A" | command sed '/^$/d')"
|
||||||
nvm_print_default_alias nvm_print_formatted_alias nvm_resolve_local_alias \
|
nvm_print_default_alias nvm_print_formatted_alias nvm_resolve_local_alias \
|
||||||
nvm_sanitize_path nvm_has_colors nvm_process_parameters \
|
nvm_sanitize_path nvm_has_colors nvm_process_parameters \
|
||||||
> /dev/null 2>&1
|
> /dev/null 2>&1
|
||||||
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
|
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
>&2 nvm --help
|
>&2 nvm --help
|
||||||
|
|
|
@ -63,3 +63,15 @@ make_fake_iojs() {
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch() {
|
||||||
|
$@ &
|
||||||
|
local JOB
|
||||||
|
JOB=$!
|
||||||
|
while true; do sleep 15; >&2 echo '* ping *'; done &
|
||||||
|
wait $JOB;
|
||||||
|
local EXIT_CODE
|
||||||
|
EXIT_CODE=$?
|
||||||
|
kill %2;
|
||||||
|
return $EXIT_CODE
|
||||||
|
}
|
||||||
|
|
|
@ -9,4 +9,4 @@ mkdir src/node-v0.0.1
|
||||||
. ./nvm.sh
|
. ./nvm.sh
|
||||||
nvm uninstall v0.0.1
|
nvm uninstall v0.0.1
|
||||||
|
|
||||||
[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1' ]
|
[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1/files' ]
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
unset -f nvm_compute_checksum
|
||||||
|
}
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
nvm_compute_checksum() {
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compare_checksum 2>&1 >/dev/null || echo)"
|
||||||
|
EXIT_CODE="$(nvm_compare_checksum >/dev/null 2>&1 || echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT='Provided file to checksum is empty.'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 4 ] || die "expected to exit with code 4, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compare_checksum foo 2>&1 >/dev/null || echo)"
|
||||||
|
EXIT_CODE="$(nvm_compare_checksum foo >/dev/null 2>&1 || echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT='Provided file to checksum does not exist.'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 3 ] || die "expected to exit with code 3, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compare_checksum ../../../nvm.sh 2>&1 >/dev/null || echo)"
|
||||||
|
EXIT_CODE="$(nvm_compare_checksum ../../../nvm.sh >/dev/null 2>&1 || echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT='Provided checksum to compare to is empty.'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 2 ] || die "expected to exit with code 2, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compare_checksum ../../../nvm.sh checksum 2>&1 >/dev/null)"
|
||||||
|
EXIT_CODE="$(nvm_compare_checksum ../../../nvm.sh checksum >/dev/null 2>&1 ; echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT="Computed checksum of '../../../nvm.sh' is empty.
|
||||||
|
WARNING: Continuing *without checksum verification*"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 0 ] || die "expected to exit with code 0, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
nvm_compute_checksum() {
|
||||||
|
echo "not checksum: ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compare_checksum ../../../nvm.sh checksum 2>&1 >/dev/null || echo)"
|
||||||
|
EXIT_CODE="$(nvm_compare_checksum ../../../nvm.sh checksum >/dev/null 2>&1 || echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT="Checksums do not match: 'not checksum: ../../../nvm.sh' found, 'checksum' expected."
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 1 ] || die "expected to exit with code 1, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
nvm_compute_checksum() {
|
||||||
|
echo checksum
|
||||||
|
}
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compare_checksum ../../../nvm.sh checksum 2>&1 >/dev/null)"
|
||||||
|
EXIT_CODE="$(nvm_compare_checksum ../../../nvm.sh checksum >/dev/null 2>&1; echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT='Checksums matched!'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 0 ] || die "expected to exit with code 0, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
cleanup
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compute_checksum 2>&1 >/dev/null || echo)"
|
||||||
|
EXIT_CODE="$(nvm_compute_checksum >/dev/null 2>&1 || echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT='Provided file to checksum is empty.'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 2 ] || die "expected to exit with code 2, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
set +x
|
||||||
|
OUTPUT="$(nvm_compute_checksum foo 2>&1 >/dev/null || echo)"
|
||||||
|
EXIT_CODE="$(nvm_compute_checksum foo >/dev/null 2>&1 || echo $?)"
|
||||||
|
set -x
|
||||||
|
EXPECTED_OUTPUT='Provided file to checksum does not exist.'
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 1 ] || die "expected to exit with code 1, got ${EXIT_CODE}"
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
unset -f nvm_download nvm_get_checksum_alg nvm_get_mirror
|
||||||
|
}
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; }
|
||||||
|
|
||||||
|
set +e # TODO: fix
|
||||||
|
. ../../../nvm.sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
nvm_get_mirror() {
|
||||||
|
echo "mirror-${1}-${2}"
|
||||||
|
}
|
||||||
|
|
||||||
|
set +ex # needed to capture error output
|
||||||
|
OUTPUT="$(nvm_get_checksum 2>&1 >/dev/null)"
|
||||||
|
EXPECTED_OUTPUT='supported flavors: node, iojs'
|
||||||
|
EXIT_CODE="$(nvm_get_checksum >/dev/null 2>&1 ; echo $?)"
|
||||||
|
set -ex
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected error output >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
[ "${EXIT_CODE}" = 2 ] || die "expected exit code 2, got ${EXIT_CODE}"
|
||||||
|
|
||||||
|
nvm_download() {
|
||||||
|
echo "ERROR_FAILED_MATCH no_match more fields"
|
||||||
|
echo "${3} bar.tar.baz more fields"
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_get_checksum_alg() {
|
||||||
|
echo 'sha-256'
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm_get_checksum node std foo bar baz)"
|
||||||
|
EXPECTED_OUTPUT="mirror-node-std/foo/SHASUMS256.txt"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
|
||||||
|
nvm_get_checksum_alg() {
|
||||||
|
echo 'sha-1'
|
||||||
|
}
|
||||||
|
OUTPUT="$(nvm_get_checksum iojs std foo bar baz)"
|
||||||
|
EXPECTED_OUTPUT="mirror-iojs-std/foo/SHASUMS.txt"
|
||||||
|
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
|
||||||
|
|
||||||
|
cleanup
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../common.sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
NVM_TEST_VERSION='v3.3.1'
|
||||||
|
NVM_PREFIXED_TEST_VERSION="iojs-${NVM_TEST_VERSION}"
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
nvm uninstall "${NVM_TEST_VERSION}" || echo 'not installed'
|
||||||
|
|
||||||
|
# Install from source
|
||||||
|
(watch nvm install -s "${NVM_PREFIXED_TEST_VERSION}") || die "'nvm install -s ${NVM_PREFIXED_TEST_VERSION}' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
nvm_is_version_installed "${NVM_PREFIXED_TEST_VERSION}" || die 'version not installed'
|
||||||
|
nvm run "${NVM_PREFIXED_TEST_VERSION}" --version | grep "${NVM_TEST_VERSION}" || "'nvm run ${NVM_PREFIXED_TEST_VERSION} --version | grep ${NVM_TEST_VERSION}' failed"
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
NVM_TEST_VERSION='v3.3.0'
|
||||||
|
NVM_PREFIXED_TEST_VERSION="iojs-${NVM_TEST_VERSION}"
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
nvm uninstall "${NVM_TEST_VERSION}" || echo 'not installed'
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
echo "${NVM_PREFIXED_TEST_VERSION}" > .nvmrc
|
||||||
|
|
||||||
|
nvm install -s || "'nvm install -s' failed"
|
||||||
|
|
||||||
|
# Check
|
||||||
|
nvm_is_version_installed "${NVM_PREFIXED_TEST_VERSION}" || die 'version is not installed'
|
||||||
|
nvm run "${NVM_PREFIXED_TEST_VERSION}" --version | grep "${NVM_TEST_VERSION}" \
|
||||||
|
|| die "'nvm run ${NVM_PREFIXED_TEST_VERSION} --version | grep ${NVM_TEST_VERSION}' failed"
|
|
@ -3,6 +3,9 @@
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
nvm deactivate
|
nvm deactivate
|
||||||
nvm uninstall iojs-v1.0.0
|
nvm uninstall iojs-v1.0.0
|
||||||
|
nvm uninstall iojs-v1.0.3
|
||||||
|
nvm uninstall iojs-v3.3.0
|
||||||
|
nvm uninstall iojs-v3.3.1
|
||||||
|
|
||||||
if [ -f ".nvmrc" ]; then
|
if [ -f ".nvmrc" ]; then
|
||||||
rm .nvmrc
|
rm .nvmrc
|
||||||
|
|
Loading…
Reference in New Issue