From de138849df98ebc6260c6bab665707cc817248e9 Mon Sep 17 00:00:00 2001
From: yves <steve.harrison@gmx.net>
Date: Wed, 19 Jan 2011 16:07:42 +0100
Subject: updated bootstrap.sh

---
 bootstrap.sh | 48 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/bootstrap.sh b/bootstrap.sh
index 02d71df..73fcf3b 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,32 +1,46 @@
 #! /bin/sh
 
+###########################
+# start config
+
+PREFIX=`pwd`/usr/
 NODE_VERSION=0.3.5
 
+# end config 
+###########################
+
+export PATH=${PREFIX}/bin:${PATH}
+
 ## Download Helper 
-# $1 - url 
-# $2 - tarball name
+# $1 - url
+# $2 - destdir
 download() {
-    echo $1
-    mkdir -p usr/src
+    mkdir -p ${PREFIX}/src
     
     if [ ! -f ${2} ]; then
-        curl ${1} > ${2}
+	echo "!! saving source to $1"
+        curl ${1} | tar -x -z -C ${PREFIX}/src
     fi
-
-    tar -xf ${2} -C usr/src
 }
 
-# fetch and compile nodejs
-download http://nodejs.org/dist/node-v${NODE_VERSION}.tar.gz node-${NODE_VERSION}.tar.gz
-rm -f node-${NODE_VERSION}.tar.gz
+if [ ! -f ${PREFIX}/bin/node ]; then
+    # fetch and compile nodejs
+    download http://nodejs.org/dist/node-v${NODE_VERSION}.tar.gz ${PREFIX}/src/node-v${NODE_VERSION}
+
+    cd ${PREFIX}/src/node-v${NODE_VERSION} 
+    ./configure --prefix=${PREFIX}
+    make install
+else 
+   echo "!! node already installed"
+fi
 
-cd usr/src/node-v${NODE_VERSION} 
-./configure --prefix=../..
-make install
-cd ../../..
+if [ ! -f ${PREFIX}/bin/npm ];then
+    # fetch and compile npm
+    curl http://npmjs.org/install.sh |  sh
+else 
+   echo "!! npm already installed"
 
-# fetch and compile npm
-curl http://npmjs.org/install.sh |  PATH=`pwd`/usr/bin:${PATH} sh
+fi
 
 # load development code and compile dependencies
-usr/bin/npm link src/nodejs/
+npm link src/nodejs/
-- 
cgit v1.2.3