diff options
author | isaacs <i@izs.me> | 2010-11-21 04:35:19 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-11-21 04:35:19 +0300 |
commit | 1f46fb8443dcf627ed18938b57c349eebb638cde (patch) | |
tree | 759d5c3036b09e78b53b6d54734ac6789b321c63 /scripts | |
parent | 7277c456082742db8ed080d48f3c389e987ecf91 (diff) |
More portable install script.
Diffstat (limited to 'scripts')
-rw-r--r--[-rwxr-xr-x] | scripts/install.sh | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/scripts/install.sh b/scripts/install.sh index 9ad05843f..a8425fa7d 100755..100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,10 +1,20 @@ #!/bin/sh r=${RANDOM-$(date +%s)} +TMP=$(mktemp -dt npm.XXXXXX) +if [ "x$TMP" == "x" ]; then + TMP=$PWD/npm-$r + mkdir -- "$TMP" || (echo "failed to mkdir $TMP" >&2 ; exit 1) +fi +BACK="$PWD" tar=${TAR-$(if which gtar 1>/dev/null 2>/dev/null; then echo "gtar" ; else echo "tar" ; fi)} -mkdir npm-$r \ - && cd npm-$r \ - && curl -L http://github.com/isaacs/npm/tarball/master | $tar xzf - --strip-components=1 \ +egrep=$(if which gegrep 1>/dev/null 2>/dev/null; then echo "gegrep" ; else echo "egrep" ; fi) +cd -- "$TMP" \ + && curl -L $( + curl http://registry.npmjs.org/npm/latest \ + | $egrep -o 'tarball":"[^"]+' \ + | $egrep -o 'http://.*' + ) | $tar -xzf - --strip-components=1 \ && make uninstall install \ - && cd .. \ - && rm -rf npm-$r \ + && cd -- "$BACK" \ + && rm -rf -- "$TMP" \ && echo "It worked" |