[Breaking] cache previously downloaded artifacts for source installs
- `nvm uninstall` no longer removes source artifacts
parent
ba3ad8e460
commit
2214cb7ad7
143
nvm.sh
143
nvm.sh
|
@ -1392,7 +1392,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)"
|
||||||
|
@ -1664,7 +1664,8 @@ nvm_download_artifact() {
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="${4}"
|
VERSION="${4}"
|
||||||
|
|
||||||
if ! nvm_binary_available "${VERSION}"; then
|
if [ "${KIND}" = 'binary' ] && ! nvm_binary_available "${VERSION}"; then
|
||||||
|
nvm_err "No precompiled binary available for ${VERSION}."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1681,7 +1682,11 @@ nvm_download_artifact() {
|
||||||
CHECKSUM="$(nvm_get_checksum "${VERSION}" "${SLUG}" "${COMPRESSION}")"
|
CHECKSUM="$(nvm_get_checksum "${VERSION}" "${SLUG}" "${COMPRESSION}")"
|
||||||
|
|
||||||
local tmpdir
|
local tmpdir
|
||||||
|
if [ "${KIND}" = 'binary' ]; then
|
||||||
tmpdir="${NVM_DIR}/bin/${SLUG}"
|
tmpdir="${NVM_DIR}/bin/${SLUG}"
|
||||||
|
else
|
||||||
|
tmpdir="${NVM_DIR}/src/${SLUG}"
|
||||||
|
fi
|
||||||
command mkdir -p "${tmpdir}/files" || (
|
command mkdir -p "${tmpdir}/files" || (
|
||||||
nvm_err "creating directory ${tmpdir}/files failed"
|
nvm_err "creating directory ${tmpdir}/files failed"
|
||||||
return 3
|
return 3
|
||||||
|
@ -1690,7 +1695,12 @@ nvm_download_artifact() {
|
||||||
local TARBALL
|
local TARBALL
|
||||||
TARBALL="${tmpdir}/${SLUG}.tar.${COMPRESSION}"
|
TARBALL="${tmpdir}/${SLUG}.tar.${COMPRESSION}"
|
||||||
local TARBALL_URL
|
local TARBALL_URL
|
||||||
|
if nvm_version_greater_than_or_equal_to "${VERSION}" 0.1.14; then
|
||||||
TARBALL_URL="${MIRROR}/${VERSION}/${SLUG}.tar.${COMPRESSION}"
|
TARBALL_URL="${MIRROR}/${VERSION}/${SLUG}.tar.${COMPRESSION}"
|
||||||
|
else
|
||||||
|
# node <= 0.1.13 does not have a directory
|
||||||
|
TARBALL_URL="${MIRROR}/${SLUG}.tar.${COMPRESSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
if nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" >/dev/null 2>&1; then
|
if nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" >/dev/null 2>&1; then
|
||||||
nvm_err "Checksums match! Using existing downloaded archive ${TARBALL}"
|
nvm_err "Checksums match! Using existing downloaded archive ${TARBALL}"
|
||||||
|
@ -1754,65 +1764,56 @@ nvm_get_make_jobs() {
|
||||||
|
|
||||||
nvm_install_node_source() {
|
nvm_install_node_source() {
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="${1}"
|
||||||
local NVM_MAKE_JOBS
|
local NVM_MAKE_JOBS
|
||||||
NVM_MAKE_JOBS="$2"
|
NVM_MAKE_JOBS="${2}"
|
||||||
local ADDITIONAL_PARAMETERS
|
local ADDITIONAL_PARAMETERS
|
||||||
ADDITIONAL_PARAMETERS="$3"
|
ADDITIONAL_PARAMETERS="${3}"
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
local TARBALL
|
||||||
|
local TMPDIR
|
||||||
|
local VERSION_PATH
|
||||||
|
|
||||||
if (
|
if (
|
||||||
[ -n "$tarball" ] && \
|
TARBALL="$(nvm_download_artifact node source std "${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 "${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
|
||||||
|
@ -1827,12 +1828,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() {
|
||||||
|
@ -2352,49 +2352,54 @@ 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" \
|
command rm -rf \
|
||||||
"$NVM_DIR/src/$NVM_PREFIX-$VERSION.tar.*" \
|
"${NVM_DIR}/bin/${SLUG_BINARY}/files" \
|
||||||
"$NVM_DIR/bin/$NVM_PREFIX-${t}/files" \
|
"${NVM_DIR}/src/${SLUG_SOURCE}/files" \
|
||||||
"$VERSION_PATH" 2>/dev/null
|
"${VERSION_PATH}" 2>/dev/null
|
||||||
nvm_echo "$NVM_SUCCESS_MSG"
|
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)
|
||||||
|
|
|
@ -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' ]
|
||||||
|
|
Loading…
Reference in New Issue