the djb way


building djb

If the djb way means anything, it certainly means compiling packages from source. This is how djb software is distributed, and some pains have been taken to make sure that packages are very easy to build and install.

The build procedure for djb software is usually one of two "flavors" that may be categorized as:


djb "classic" (make setup check)

The djb classic build procedure applies to most of the software described in the djb way.

The procedure described here makes use of these directories:

/usr/local/djb/dist
local repository for downloaded source packages
/usr/local/djb/patches
local repository for downloaded patch files
/usr/local/djb/build
where the packages will be unpacked and compiled

Prepare them with:

# mkdir -p /usr/local/djb/dist
# mkdir /usr/local/djb/patches
# mkdir /usr/local/djb/build

We'll demonstrate the procedure with the clockspeed package. First, grab the source code, using your preferred download utility (ftp is shown here):

# cd /usr/local/djb/dist
# ftp ftp://cr.yp.to/clockspeed/clockspeed-0.62.tar.gz

Verify the MD5 checksum of the package:

# md5 clockspeed-0.62.tar.gz
MD5 (clockspeed-0.62.tar.gz) = 425614174fcfe2ad42d22d3d02e2d567

If the checksum reported doesn't agree, the package has been altered or corrupted. Delete the archive and download the package again from a trusted source.

Next, unpack the source package into the build directory:

# cd ../build
# tar -xzvf ../dist/clockspeed-0.62.tar.gz

Note that we show a smart tar here (compiled with zlib), that can uncompress gzip'd archives with the -z option. If your own tar does not recognize the -z option, use this command pipe instead:

# gzip -cd ../dist/clockspeed-0.62.tar.gz | tar -xvf -

After unpacking you should find a new directory in /usr/local/djb/dist named clockspeed-0.62. Change into this directory:

# cd clockspeed-0.62

If you need to patch the source code, do it now:

# patch -p1 < /path/to/patchfile

For example, the errno patch:

# patch -p1 < ../../patches/clockspeed-0.62.errno.patch

Now build the package and install it:

# make
# make setup check

Typically a bunch of compiler output and warnings will flash by on your screen. Don't worry, this is normal. When it's all done, that's it! The package has been compiled and installed on your system.

Note that djb software is mostly self-contained and the compilation is self-configuring. The build system usually figures out how to adapt the package to your specific hardware and operating system automatically.

Let Bernstein know how everything worked out, substituting your own name in the following:

# (echo 'Courtney Love'; cat `cat SYSDEPS`) | mail djb-qst@cr.yp.to 

slashpackage

The slashpackage build procedure represents the latest in Bernstein's thinking about package management and filesystem layout. (Read more about these ideas directly at http://cr.yp.to/slashpackage.html.)

As of this writing, only the daemontools package follows this new format. But we can expect new djb releases to be converted to this system in the future, and most of the latest software from djb "friends" has already adopted it.

Following the standard installation instructions, these new top-level directories will be created in the filesystem:

/command
/package
/service

The /command directory will contain symbolic links to the executables built by the package; /package will be used for the top-level build and installation directory; and /service will contain links to sub-directories under the control of daemontools' supervise utility.

Before the installation, we need to create the /package directory ourselves. For systems with small, separate root partitions (as is common on BSD systems), we set up the /package directory by way of symbolic link to a directory in the /usr partition:

# mkdir -p /usr/local/package
# chmod 1755 /usr/local/package
# ln -s /usr/local/package /package

Now all the installed files will be accessible through /package, though they will physically reside in /usr/local/package. Check this with a directory listing (the ouput is truncated here to fit the page):

# ls -ld /package
lrwxr-xr-x ... /package -> /usr/local/package

The top-level /command and /service directories will be created by the installation procedure itself. These directories will be populated only by symlinks, and should not be an issue even on small root partitions.

Ok? Now we're ready to go. Snag the sources into your local repository:

# cd /usr/local/djb/dist
# wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz

Verify the MD5 checksum of the package:

# md5 daemontools-0.76.tar.gz
MD5 (daemontools-0.76.tar.gz) = 1871af2453d6e464034968a0fbcb2bfc

If the checksum reported doesn't agree, the package has been altered or corrupted. Delete the archive and download the package again from a trusted source.

Unpack the source archive into /package:

# cd /package
# tar -xzvpf /usr/local/djb/dist/daemontools-0.76.tar.gz

Change into the admin/daemontools-0.76 directory just created:

# cd admin/daemontools-0.76

(Other slashpackage packages may be installed elsewhere within the /package hierarchy; follow the specific installation instructions for the package.)

If you need to apply the errno patch, this is the place to do it:

# patch -p1 < /usr/local/djb/patches/daemontools-0.76.errno.patch

Then build and install the package according to its specific instructions. In the case of daemontools:

# package/install

Report your successful installation:

# mail djb-sysdeps@cr.yp.to < /package/admin/daemontools/compile/sysdeps

Copyright © 2002, 2003, 2004, Wayne Marshall.
All rights reserved.

Last edit 2004.10.16, wcm.