HOWTO: Compile Unison (and OCaml) under Unslung 6.10 on a Linksys NSLU2

This is a pretty obscure and incomplete howto, but I was left to figure all this out without much help so I figure I might as well post what I learned in case it is of assistance to anyone else.

At the office, we’re running a Linksys NSLU2 with the Unslung 6.10 firmware as our file server. We wanted to use Unison to do a two-way sync between portions of the server and a laptop, so that we can access documents offline and out of the office (e.g. in a meeting off-site). The unslung NSLU2 has a lot of software available through the OptWare package system, but Unison is not available. Since the architecture is non-standard (I want to say “arm” or something? anyways, not x86), I figured we’d have to compile from source. Then, one more roadblock — it’s written in OCaml, which also lacks an OptWare package and would need to be compiled from source.

Obviously, make sure you read and follow all the instructions provided with OCaml and Unison, and be sure to pay attention to the documentation at the NSLU2 Linux wiki. The following are just some tips for things that weren’t in the documentation which we had to figure out along the way.

Compiling OCaml

This proved a bit tricky. First all, you’ll need to install a few dependencies, which thankfully have OptWare packages available: make, crosstool-native (for gcc), and gawk.

Second, make sure to use the prefix flag in the configure step to install to /opt/bin and /opt/lib, rather than the standard /bin and /lib (i.e. you want to install it on one of the NSLU2 drives, not the limited internal memory). So, for example:

./configure -prefix /opt

Last, there is one problem with the MakeFile generated — there is a reference to “awk” somewhere to needs to be changed to /opt/bin/awk (unless you’re luckier than me and somehow have /opt/bin correctly on the path, but trust me, I tried…). So, I did a `grep -n awk MakeFile` to find it and then you can use nano/vim to make the edit manually to the file before compiling.

If you do those things first, compilation should be easy (just be prepared to wait awhile):

make world opt 2>&1 > log.worldopt
make install

Compiling Unison

Don’t ask me what “etags” are, but the compiler will complain if you don’t have them, and I figured out it has something to do with emacs. Once you install emacs, it gets past that stage in the compilation, so:

ipkg update
ipkg install emacs

The emacs installation actually gave me an error with a file conflict of sorts, so I had to run:
ipkg -force-overwrite install emacs

For some reason, Nathan discovered that you need to set NATIVE=false when you make Unison. I didn’t see the command, but I gather it looked something like this:
make NATIVE=false UISTYLE=text

Lastly, you’ll want to put unison on your path, so something like…
cp ./unison /opt/bin/

And then, magic! Or tragedy, if you did something wrong.

Leave a comment

Your email address will not be published. Required fields are marked *