NodeJS on the Drobo

Recently I have been loading data onto my DroboFS. Much of it I would like to share with family and friends, but I also want others to be able to share files with me, too. I considered many options for file sharing, and settled on WebDAV (specification). However, the only software already compiled for the Drobo which supports WebDAV was lighttpd. Its WebDAV implementation is incomplete, so it has different problems depending on which client connects. I've been working with JavaScript very closely for some time, have been enjoying working with NodeJS, and found a module called jsDAV, so I thought to myself, "Why not install NodeJS on my Drobo?" The following is a HOWTO I've pieced together after a week of struggling with it.

WebDAV

Why did I choose WebDAV?

The Quick Way

Download my precompiled package here.

The Easy Way

Follow the "Prerequisites" steps below (remember to enable the 2009 tool-chain), then...

Download the shell script I created, place it in ~/code, and run it.

The Hard Way

Prerequisites

Make sure you have set up a cross-compile environment as described here.

Follow the instructions to get the latest cross-compile tool-chain as described here.

Install the latest copy of nodejs for the HOST machine. This is needed later during the install process, as nodejs uses itself to execute the script for installing itself to the target directory (clever, but annoying when cross-compiling).

$ sudo apt-get install python-software-properties
      $ sudo apt-add-repository ppa:chris-lea/node.js
      $ sudo apt-get update
      $ sudo apt-get install nodejs

Fetch Resources

Save this patch file: ~/code/nodejs-configuration-patch.txt

$ wget http://zlib.net/zlib-1.2.7.tar.gz
      $ wget http://www.openssl.org/source/openssl-1.0.0d.tar.gz
      $ wget http://nodejs.org/dist/v0.8.2/node-v0.8.2.tar.gz
Then extract each file into your ~/code directory.

Build zlib

Thankfully, zlib is very easy to build statically:

$ cd zlib-1.2.7
      $ ./configure --prefix=/mnt/DroboFS/Shares/DroboApps/nodejs --static
      $ make clean
      $ make
      $ make install

Build openssl

OpenSSL needs a bit more to compile. Many thanks to Ricardo for making it easy.

$ cd openssl-1.0.0d
      $ ./Configure linux-generic32 \
        -DL_ENDIAN \
        --prefix=/mnt/DroboFS/Shares/DroboApps/nodejs \
        --openssldir=/mnt/DroboFS/Shares/DroboApps/nodejs no-shared no-zlib-dynamic \
        --with-zlib-include=/mnt/DroboFS/Shares/DroboApps/nodejs/include \
        --with-zlib-lib=/mnt/DroboFS/Shares/DroboApps/nodejs/lib
      $ sed -i -e "s/CFLAG= /CFLAG=${CFLAGS} /g" Makefile
      $ make clean
      $ make # First make always dies on a non-error, strange, but...
      $ make # Second one succeeds
      $ make install

Build nodejs

A few notes about why things are done the way they are below:

$ cd node-v0.8.2
      $ make distclean clean
      $ patch < ../nodejs-configuration-patch.txt
      $ ./configure --dest-cpu=arm \
        --prefix=/mnt/DroboFS/Shares/DroboApps/nodejs \
        --without-snapshot \
        --shared-openssl \
        --shared-openssl-includes=/mnt/DroboFS/Shares/DroboApps/nodejs/include \
        --shared-openssl-libpath=/mnt/DroboFS/Shares/DroboApps/nodejs/lib \
        --shared-zlib \
        --shared-zlib-includes=/mnt/DroboFS/Shares/DroboApps/nodejs/include \
        --shared-zlib-libpath=/mnt/DroboFS/Shares/DroboApps/nodejs/lib
      $ make CC="$CC" \
        CXX="$CXX" \
        CFLAGS+="$CFLAGS -O3 -mfloat-abi=soft" \
        CXXFLAGS+="$CFLAGS -O3 -mfloat-abi=soft" \
        DESTDIR=/mnt/DroboFS/Shares/DroboApps/nodejs \
        install
      $ rsync \
        --recursive \
        --remove-source-files \
        --verbose \
        /mnt/DroboFS/Shares/DroboApps/nodejs/usr/ \
        /mnt/DroboFS/Shares/DroboApps/nodejs/
      $ find /mnt/DroboFS/Shares/DroboApps/nodejs/usr/ -depth -type d -exec rmdir "{}" \;  
Congratulations! You're ready to package it up and run nodejs on your DroboFS!