summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--node/Makefile44
-rwxr-xr-xnode/install79
2 files changed, 82 insertions, 41 deletions
diff --git a/node/Makefile b/node/Makefile
index 0b7775ed..cbfa1e4a 100644
--- a/node/Makefile
+++ b/node/Makefile
@@ -1,46 +1,8 @@
-ifndef version
- version := $(shell \
- curl -sS http://nodejs.org/ | \
- ../util/bin/hrefs | \
- sed -rn 's:.*node-(v[0-9.]+)\.tar\.gz:\1:p' | \
- sort | \
- tail -n 1)
-endif
-
-export CPPFLAGS := -Wno-unused-but-set-variable
-
-.PHONY: all build install
+.PHONY: all install
all:
@echo "You are made of stupid!"; exit 23
-build: out/node-$(version)
-
-install: out/node-$(version)
- ln -vsnf ../node/$</bin/node ../bin/node
-
-out/node-%: src/node-%
- cd $< && ./configure --prefix=$(PWD)/$@
- make -C $<
- make -C $< install
-
-../bin/node: out/
-
-src/node-git: src
- cd src && \
- git clone https://github.com/joyent/node node-git
-
-src/node-%: src/node-%.tar.gz
- cd src && tar xf node-$*.tar.gz
-
-.PRECIOUS: src/node-%.tar.gz
-src/node-%.tar.gz: /usr/bin/curl src
- { curl -o $@ http://nodejs.org/dist/node-$*.tar.gz && gzip -t $@; } || \
- { curl -o $@ http://nodejs.org/dist/$*/node-$*.tar.gz && gzip -t $@; }
-
-/usr/bin/curl:
- apt-get install --yes curl
-
-src:
- mkdir -v -p $@
+install:
+ ./install
diff --git a/node/install b/node/install
new file mode 100755
index 00000000..1284a73a
--- /dev/null
+++ b/node/install
@@ -0,0 +1,79 @@
+#! /bin/sh
+#
+# //node/install
+#
+# export version=X.Y.Z to install a specific version
+# otherwise the latest upstream version will be determined and used
+#
+# export force=true to install even though it already seems to be installed
+#
+# export clean=true to first wipe any generated files
+#
+set -xeuf
+
+# cd //node
+cd $(readlink -f $(dirname $0))
+
+# PATH prepend //node/tools //util/bin
+export PATH="$PWD/tools:$PWD/../util/bin${PATH+:$PATH}"
+
+if test "${force-false}" = true; then
+ : # skip check if it is already installed
+else
+ if test -e ../bin/node; then
+ : '//bin/node # is already installed'
+ exit
+ fi
+fi
+
+if test "${clean-false}" = true; then
+ rm -fR src out
+fi
+
+test -d src || mkdir -v src
+cd src
+
+version=${version-`latest-version`}
+
+target=node-v$version
+
+distfile=$target.tar.gz
+
+download() {
+ curl -C - -so $distfile http://nodejs.org/dist/v$version/$distfile ||
+ curl -C - -so $distfile http://nodejs.org/dist/$distfile || :
+}
+is_downloaded() {
+ gzip -t $distfile 2>/dev/null
+}
+if ! is_downloaded; then
+ download
+ if ! is_downloaded; then
+ rm -f $distfile
+ download
+ fi
+ if ! is_downloaded; then
+ rm -f $distfile
+ echo failed to download distfile
+ exit 1
+ fi
+fi
+
+if ! zcat $distfile | tar -x --keep-newer-files 2>/dev/null; then
+ rm -fR $target
+ zcat $distfile | tar -x
+fi
+
+cd ..
+
+prefix=out/$target
+mkdir -p $prefix
+prefix=`readlink -f $prefix`
+
+cd src/$target
+./configure --prefix=$prefix
+CPPFLAGS=-Wno-unused-but-set-variable make
+make install
+cd ../..
+
+ln -snf ../node/out/$target/bin/node ../bin/node