So, I'm supposed to be starting a blog, and (for reasons to be discussed later) I want to have it up by 6 o'clock (5 o'clock central, where I'm writing this) this morning. It really ought to live somewhere on kaduk.org, but (1) I haven't figured out where, yet, and (2) for logistical reasons too boring to go into here, that domain isn't serving anything at the moment. So, a text file will suffice for now, and I'll try to backfill it in to what I do finally end up with. Anyway, ... My first FreeBSD package (part 1) In a long chain of yaks, I find that I need a copy of libss.so on my system. (For, you see, I want to use barnowl with zephyr locally instead of remotely, and zephyr's zctl requires libss....) I could just install heimdal (or KTH krb4, but that's marked as BROKEN for recent versions), but that's kind of a huge package and can cause excitement by conflicting with the hacked-up version of heimdal that's in the base system. Alternately, I could grab the source from e2fsprogs and build its copy of libss, and get just what I need. So began an adventure ... Luckily, there is a lot of good documentation --- one of the great things about FreeBSD is that there's pretty good documentation for most of the things you might want to do, and most of it is even not horrendously outdated. Here, my first step was to consult the Porter's Handbook: http://www.freebsd.org/doc/en/books/porters-handbook/index.html Unfortunately, "Quick Porting" was not for me, as I wanted to fetch a medium-sized distfile (e2fsprogs) and only build a small part of it. So I got to read through most of the book. At the time, I was only looking for how to get this one particular package to work, so I could skip a lot. But the rest of it is useful reading in general, and I would pick up on it later. The first step in building a package is to get the source code; in this case, that actually took some thought, since the name of the tarball (a.k.a. "distfile") that I want bears basically no relation to what I thought I was going to call the port (libss). The file I want is e2fsprogs_1.41.9.orig.tar.gz (e2fsprogs is a Debian package (maintained by tytso@mit.edu !), so there's a '.orig' in there), and it's hosted on any Debian mirror. The core of a FreeBSD port is a Makefile, so to tell the system where to find the source code, I only had to specify a few make(1) variables: MASTER_SITES= ${MASTER_SITE_DEBIAN} MASTER_SITE_SUBDIR= pool/main/e/e2fsprogs DISTFILES= e2fsprogs_1.41.9.orig.tar.gz .include Note that MASTER_SITE_DEBIAN is defined by the infrastructure, so I automatically get the full set of Debian mirrors. There's a patch release of e2fsprogs out, though, so I might as well grab that, too, as an extra set of patches: PATCH_SITES= http://ftp.debian.org/debian/pool/main/e/e2fsprogs/ PATCHFILES= e2fsprogs_1.41.9-1.diff.gz PATCH_DIST_STRIP= -p1 (and strip git's 'a/' and 'b/' from the patch.) Now that I have the source, I let the port infrasructure gunzip(1) and un-tar(1) the file (a.k.a. "extract" it), and I have to specify where it extracts to (but only because Debian put that '.orig' in there ...): WRKSRC= ${WRKDIR}/e2fsprogs-1.41.9 Unfortunately, most of the preceding code is Wrong, and though my first attempt worked (that is, it installed a libss.so.2 that I could link against), it was not up to the style standards expected of a FreeBSD port, and I had to rewrite most of it. It turns out that since I only want to install a small part of some other piece of software, I can leverage a bunch of the "master" port's code and write a smaller "slave" port, that will track the updates of the "master" port. Thus: MASTERDIR= ${.CURDIR}/../../sysutils/e2fsprogs .include "${MASTERDIR}/Makefile" The '.include' of either the master ports' Makefile or bsd.port.mk should occur at the end of the Makefile --- I'm moving things around a bit to show how my Makefile grew, and will post the full final Makefile later. Anyway, the master port's Makefile sets WKRSRC for me, and does all the work to fetch and extract a reasonably-current distfile for e2fsprogs. Less work for me! What to do once I've got a working directory with extracted source in it is the subject of a later entry.