When I read passages like this, I want to look for the nearest wall to bang my head against.
— S.T. Joshi, "Arthur Machen: The Mystery of the Universe" in The Weird Tale
Marc's realm

Compiling netatalk on OpenSolaris

If you want to serve AFP (Apple Filing Protocol) shares from an OpenSolaris box you need to install netatalk. However, it doesn't seem to get maintained any more (I'm writing this in June 2008) and the code doesn't compile cleanly on OpenSolaris. These instructions talk about getting netatalk 2.0.3 to compile on OpenSolaris 2008.5. They have been slightly updated after getting input from Matt Connolly in April 2011.

We need to install two packages: the Berkeley DB and netatalk. I decided to use BDB 4.2.x because netatalk talks about supporting only 4.1.x and 4.2.x and because I wanted to reuse existing data from my former Linux server.

Preparations

These instructions assume you are a user that can call pfexec to get root access. I use a directory $HOME/src in which I will compile everything. So, let's first create that directory:

mkdir -p $HOME/src

We will install our stuff into the /usr/local tree because that's exactly what this directory tree is for: stuff compiled and installed by the admin. On older versions of netatalk the next step is necessary, but it seems that on current versions (> 2.2-beta) it's actually counter-productive: If not already done you need to add /usr/local/lib to the dynamic linker search path:

pfexec crle -u -l /usr/local/lib

Install the Berkeley DB

Of course you need to download the BDB first. Grab version 4.2.52 with AES support.

These are the steps to compile and install the BDB:

  • cd $HOME/src
  • Unpack the BDB:
    gzcat /path/to/db-4.2.52.tar.gz | tar xf -
  • The BDB doesn't want to get compiled in its source directory, we need a separate directory:
    mkdir -p $HOME/src/db-build
    cd $HOME/src/db-build

  • Now let's run configure. Normally configure already defaults to /usr/local, but not the one from BDB so we need to explicit about it:
    ../db-4.2.52/dist/configure --prefix=/usr/local
  • Compile it:
    make
  • Install it:
    pfexec make install

While compiling, it can happen that you see the following error message:

cc -o .libs/db_archive .libs/db_archive.o .libs/util_sig.o ./.libs/libdb-4.2.so@ -R/usr/local/lib
ld: fatal: file ./.libs/libdb-4.2.so@: open failed: No such file or directory
ld: fatal: File processing errors. No output written to .libs/db_archive

If so, you need to fix libtool: edit the file libtool and search for the comment "test EBCDIC or ASCII". Replace the line "A) # EBCDIC based system" with "foo)" and save. Then run "make" again.

Install netatalk

Now it's time for netatalk. Download it from SourceForge.

  • Go to the source directory:
    cd $HOME/src
  • Unpack netatalk:
    bzcat /path/to/netatalk-2.0.3.tar.bz2 | tar xf -
  • Next, we need to edit some files to make it to compile correctly.
    • In etc/atalkd/main.c line 14, etc/papd/main.c line 17 and etc/papd/lp.c line 57 replace "#if defined( sun ) && defined( __svr4__ )" with "#if 0" so that the correct include line is active (#include <sys/file.h>).
    • The DDP kernel module won't load correctly (and isn't necessary anyway). It also doesn't compile correctly without some patching, so we make sure it doesn't get compiled in the first place. Edit sys/Makefile.in and remove the "solaris" from line 214 which reads "SUBDIRS = netatalk generic solaris netbsd sunos ultrix".
  • Run configure. We need to disable the DDP (Datagram Delivery Protocol, an AppleTalk network protocol) since the necessary kernel module won't load and it's not used by modern Macs anyway:
    ./configure --disable-ddp
  • We're ready to compile:
    make
  • If everything worked alright (which it should) then install (you need root privileges, so we use pfexec):
    pfexec make install

That's it ! Note that while everything got installed into /usr/local and the configuration files are thus in /usr/local/etc/netatalk the boot (rc) script got installed correctly in /etc/init.d. So to start the daemon you need to call "/etc/init.d/atalk start" and to stop it "/etc/init.d/atalk stop". For instruction on how to configure netatalk, see netatalk's online documentation.

If you have additional comments/corrections, please tell me.