Notes on using NetBSD’s pkgsrc on Mac OS X
I'm a kid in a chocolate shop! Look at all this stuff!
While there is an abundance of above average quality applications for Mac OS X, many tend to be more expensive and less feature complete than similar free and open source applications available on Linux, FreeBSD and the like. On Mac OS X we have the fantastic and easy to use MacPorts and Fink package managers, but if you're really serious about running said software you can't beat pkgsrc.
The pkgsrc system is the mature, elegant, sophisticated (can you tell I like it yet?) and cross platform package manager developed and used by the folks over at the NetBSD project. It's also used as the default package manager on DragonFly BSD and Draco GNU/Linux amongst others. I use it on my Macs, my Slackware Linux machine and even on a FreeBSD box, and I love it.
In this post I'll be describing what I've found to be the quickest and simplest way to get it up and running on Mac OS X. There are hundreds of other ways, but I've never gone wrong with this.
The only caveat with pkgsrc is that you really need to run it on a case sensitive file system which OS X does not use by default. If reformatting isn't an option, might I suggest using Leopard's new Disk Utility to shrink your current boot volume and creating a separate, case sensitive HFS+ volume.
ASIDE: Some of the NetBSD documentation describes creating virtual disk images and running pkgsrc from them if case sensitivity is an issue. While it is technically possible, I wouldn’t recommend it; from experience I’ve found them to be more trouble than they’re worth. If you’d like to give it a go though, the Darwin platform notes on the pkgsrc user guide details the procedure.
Firstly, open your Terminal, navigate to
/usr/ (or your new case sensitive volume you created earlier) and download a pkgsrc snapshot. This may take a while.
% cd /usr/ % sudo env CVS_RSH=ssh % cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc
Next, launch the bootstrap procedure which will create the required directories and install the utilities to build the packages:
% cd pkgsrc/bootstrap && sudo ./bootstrap
Congratulations, you now have pkgsrc installed on your Mac! The next step is to modify your shell's $PATH variable to point to the new binary directories, by default pkgsrc installs software in
/usr/pkg. If you use the Tiger and Leopard default bash shell, your PATH line in your
.profile should something like this:
You'll also want to add these lines to make it easier to update your pkgsrc tree:
export CVS_RSH=ssh export CVSROOTfirstname.lastname@example.org:/cvsroot
Very quick background I created for a fellow MBP user who started with pkgsrc on their Mac and since moved over entirely to NetBSD, will be the subject of a future post. Mai Tokiha was the only character we could really find who wears lots of orange :).
From this point forward, using pkgsrc is basically the same as using it on any other platform, the only difference is you use the
bmake tool instead of
make to build packages. If you haven't used pkgsrc before, below is a very quick crash course using Alpine as an example.
- Browsing available packages
- You can browse the
/usr/pkgsrc/directory, but the easiest way is to go to http://pkgsrc.se and either search for a specific piece of software, or browse the categories.
- Building and installing a package
% cd /usr/pkgsrc/mail/alpine% sudo bmake install clean clean-depends
- Updating your pkgsrc tree
% cd /usr/pkgsrc % sudo cvs update -dP
That's enough to get your started; once you've got the hang of it dive into the comprehensive and easy to follow pkgsrc guide by Alistair Crooks, Hubert Feyrer and the pkgsrc developers to learn all the cool things you can do with this package manager. I need a Rubenerd Seal of Approval or something :-)