From 1845a4a5a96007976604e2c6dfd059ba9b2b1c1e Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Sat, 12 Jan 2013 14:40:41 +0900 Subject: [PATCH 1/7] added the description about -s option. --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index f989b1c..c339281 100644 --- a/README.markdown +++ b/README.markdown @@ -144,3 +144,6 @@ on Arch Linux and other systems using python3 by default, before running *instal export PYTHON=python2 +After the v0.8.6 release of node, nvm try to install from binary package. But in some systems, official binary package doesn't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source: + + nvm install -s 0.8.6 From 881178db01ca83ad77cbff0ccfd776bac3acece1 Mon Sep 17 00:00:00 2001 From: Yosiya Hinosawa Date: Fri, 11 Jan 2013 19:33:44 +0900 Subject: [PATCH 2/7] fixed syntax error. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index c339281..aae2195 100644 --- a/README.markdown +++ b/README.markdown @@ -144,6 +144,6 @@ on Arch Linux and other systems using python3 by default, before running *instal export PYTHON=python2 -After the v0.8.6 release of node, nvm try to install from binary package. But in some systems, official binary package doesn't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source: +After the v0.8.6 release of node, nvm tries to install from binary package. But in some systems, official binary package doesn't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source: nvm install -s 0.8.6 From 7013372867ced186b763ca2f3640f7ee0c9908f2 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Sat, 12 Jan 2013 00:37:17 +0900 Subject: [PATCH 3/7] added -s (install from source) option. --- nvm.sh | 76 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/nvm.sh b/nvm.sh index 303925b..e15d0a3 100755 --- a/nvm.sh +++ b/nvm.sh @@ -151,7 +151,7 @@ nvm() echo echo "Usage:" echo " nvm help Show this message" - echo " nvm install Download and install a " + echo " nvm install [-s] Download and install a " echo " nvm uninstall Uninstall a version" echo " nvm use Modify PATH to use " echo " nvm run [] Run with as arguments" @@ -180,6 +180,7 @@ nvm() local sum local tarball local shasum='shasum' + local nobinary if [ ! `which curl` ]; then echo 'NVM Needs curl to proceed.' >&2; @@ -193,10 +194,20 @@ nvm() nvm help return fi - VERSION=`nvm_remote_version $2` + + shift + + nobinary=0 + if [ "$1" = "-s" ]; then + nobinary=1 + shift + fi + + VERSION=`nvm_remote_version $1` ADDITIONAL_PARAMETERS='' + shift - shift + while [ $# -ne 0 ] do ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1" @@ -205,34 +216,37 @@ nvm() [ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return - # shortcut - try the binary if possible. - if [ -n "$os" ]; then - binavail= - # binaries started with node 0.8.6 - case "$VERSION" in - v0.8.[012345]) binavail=0 ;; - v0.[1234567]) binavail=0 ;; - *) binavail=1 ;; - esac - if [ $binavail -eq 1 ]; then - t="$VERSION-$os-$arch" - url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz" - sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt.asc | grep node-${t}.tar.gz | awk '{print $1}'` - if ( - mkdir -p "$NVM_DIR/bin/node-${t}" && \ - cd "$NVM_DIR/bin" && \ - curl -C - --progress-bar $url -o "node-${t}.tar.gz" && \ - nvm_checksum `${shasum} node-${t}.tar.gz | awk '{print $1}'` $sum && \ - tar -xzf "node-${t}.tar.gz" -C "node-${t}" --strip-components 1 && \ - mv "node-${t}" "../$VERSION" && \ - rm -f "node-${t}.tar.gz" - ) - then - nvm use $VERSION - return; - else - echo "Binary download failed, trying source." >&2 - cd "$NVM_DIR/bin" && rm -rf "node-${t}.tar.gz" "node-${t}" + # skip binary install if no binary option specified. + if [ $nobinary -ne 1 ]; then + # shortcut - try the binary if possible. + if [ -n "$os" ]; then + binavail= + # binaries started with node 0.8.6 + case "$VERSION" in + v0.8.[012345]) binavail=0 ;; + v0.[1234567]) binavail=0 ;; + *) binavail=1 ;; + esac + if [ $binavail -eq 1 ]; then + t="$VERSION-$os-$arch" + url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz" + sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt.asc | grep node-${t}.tar.gz | awk '{print $1}'` + if ( + mkdir -p "$NVM_DIR/bin/node-${t}" && \ + cd "$NVM_DIR/bin" && \ + curl -C - --progress-bar $url -o "node-${t}.tar.gz" && \ + nvm_checksum `${shasum} node-${t}.tar.gz | awk '{print $1}'` $sum && \ + tar -xzf "node-${t}.tar.gz" -C "node-${t}" --strip-components 1 && \ + mv "node-${t}" "../$VERSION" && \ + rm -f "node-${t}.tar.gz" + ) + then + nvm use $VERSION + return; + else + echo "Binary download failed, trying source." >&2 + cd "$NVM_DIR/bin" && rm -rf "node-${t}.tar.gz" "node-${t}" + fi fi fi fi From 278fd031b059057c329ed647b7219bec42927396 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Sat, 12 Jan 2013 13:30:12 +0900 Subject: [PATCH 4/7] added test for installation with -s option. --- test/slow/install from binary | 14 ++++++++++++++ test/slow/install from source | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 test/slow/install from binary create mode 100755 test/slow/install from source diff --git a/test/slow/install from binary b/test/slow/install from binary new file mode 100755 index 0000000..c22e0d8 --- /dev/null +++ b/test/slow/install from binary @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e +. ../../nvm.sh + +# Remove the stuff we're clobbering. +[ -e ../../v0.8.6 ] && rm -R ../../v0.8.6 + +# Install from binary +nvm install 0.8.6 + +# Check +[ -d ../../v0.8.6 ] +nvm run v0.8.6 --version | grep v0.8.6 diff --git a/test/slow/install from source b/test/slow/install from source new file mode 100755 index 0000000..d124b27 --- /dev/null +++ b/test/slow/install from source @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e +. ../../nvm.sh + +# Remove the stuff we're clobbering. +[ -e ../../v0.8.6 ] && rm -R ../../v0.8.6 + +# Install from source +nvm install -s 0.8.6 + +# Check +[ -d ../../v0.8.6 ] +nvm run v0.8.6 --version | grep v0.8.6 From 7dc0827eaa6ba363f4e072bc91ace80c3c0805c7 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Sat, 12 Jan 2013 13:59:28 +0900 Subject: [PATCH 5/7] minor modifications. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index aae2195..84479f4 100644 --- a/README.markdown +++ b/README.markdown @@ -144,6 +144,6 @@ on Arch Linux and other systems using python3 by default, before running *instal export PYTHON=python2 -After the v0.8.6 release of node, nvm tries to install from binary package. But in some systems, official binary package doesn't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source: +After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source: nvm install -s 0.8.6 From 184f64173097a5169950bb39fb6d17516243c662 Mon Sep 17 00:00:00 2001 From: Yosiya Hinosawa Date: Sun, 13 Jan 2013 16:10:50 +0900 Subject: [PATCH 6/7] fixed the condition for the binary package availability. --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index e15d0a3..cc85e49 100755 --- a/nvm.sh +++ b/nvm.sh @@ -224,7 +224,7 @@ nvm() # binaries started with node 0.8.6 case "$VERSION" in v0.8.[012345]) binavail=0 ;; - v0.[1234567]) binavail=0 ;; + v0.[1234567].*) binavail=0 ;; *) binavail=1 ;; esac if [ $binavail -eq 1 ]; then From a6be969403f7d590f9c439d8450deac3199b48d6 Mon Sep 17 00:00:00 2001 From: Yosiya Hinosawa Date: Sun, 13 Jan 2013 16:13:20 +0900 Subject: [PATCH 7/7] changed shasums file url because in v0.8.6 .txt.asc file is not available. --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index cc85e49..65a0462 100755 --- a/nvm.sh +++ b/nvm.sh @@ -230,7 +230,7 @@ nvm() if [ $binavail -eq 1 ]; then t="$VERSION-$os-$arch" url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz" - sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt.asc | grep node-${t}.tar.gz | awk '{print $1}'` + sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | grep node-${t}.tar.gz | awk '{print $1}'` if ( mkdir -p "$NVM_DIR/bin/node-${t}" && \ cd "$NVM_DIR/bin" && \