Getting the best out of pkgsrc (by alaric)
pkgsrc, the software package installation system that comes with NetBSD, is a lovely and powerful thing, but the default out-of-the-box setup is pretty basic. There's a lot you can do to bring the power of it out that's either hidden in the pkgsrc manual or in extension packages.
So here's my quick guide to getting the best out of pkgsrc.
The first thing to do is to get it via CVS, so you can easily update your pkgsrc to the most recent version, thus getting the latest versions of all the packages to install.
I'm assuming you're doing all of this as user root
, by the way.
cd /usr
CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
CVS_RSH="ssh"
export CVSROOT CVS_RSH
cvs -q checkout -P pkgsrc
Now, pkgsrc obtains its general configuration from /etc/mk.conf
. The first change I'd make is to tell pkgsrc to keep its work directories out of /usr/pkgsrc
. The work directories are where the package sources are extracted and compiled, and after you've done a lot of package installation, they take up a lot of space; but with them all intermingled with the pkgsrc files themselves, you need to use the notoriously slow make clean
to get rid of them. But if we put them in a directory of their own, they can be cleaned up after a long compile session with a simple rm -rf *
. So do:
mkdir /usr/pkgsrc-work
Then edit /etc/mk.conf to say:
WRKOBJDIR=/usr/pkgsrc-work
One of the advantages of pkgsrc's build-from-source approach is that you can compile packages for your particular architecture, thus allowing the compiler to optimise for the exact CPU you have. pkgsrc, however, doesn't do this by default; you need to install devel/cpuflags
to do it for you.
cd /usr/pkgsrc/devel/cpuflags
make install
To activate cpuflags
we need to add another line to /etc/mk.conf
:
.sinclude "/usr/pkg/share/mk/cpuflags.mk"
Voila; from now on, any pkgsrc (or NetBSD systems software, including the kernel, for that matter) compilation will use the correct flags for your architecture.
By Ben, Mon 5th Mar 2007 @ 8:26 am
OpenBSD discourages use of processor specific optimisations as reveals bugs in the compiler which produce incorrect code. Does this not apply here?
By alaric, Mon 5th Mar 2007 @ 10:51 am
Revealing the bugs would be a good first step to fixing them 😉
By Ben, Mon 5th Mar 2007 @ 10:57 am
You are very kind to offer your production server as a test bed for the community's benefit.
By Matt, Wed 7th Mar 2007 @ 8:19 pm
Kind, of Craaaaaaaaaaaaazy!