Using pkgsrc on debian GNU/Linux

While I tend to appreciate debian GNU/Linux, its tendency to be quite late on software versionning is sometimes annoying. Also, as a pkgsrc developer, I am used to have greater control over the packages I install, for example regarding the options I'd like to include.

For these reasons and a couple more, I sometimes choose to use pkgsrc along with apt to deal with particular packages. In this article, I'll show how to achieve that task.

First install build pre-requisite packages:

% apt-get install cvs libncurses5-dev gcc g++ zlib1g-dev zlib1g libssl-dev libudev-dev

Then fetch pkgsrc:

% cd /usr && cvs -d anoncvs@anoncvs3.de.NetBSD.org:/cvsroot co pkgsrc

export the SH environment variable to /bin/bash:

% export SH=/bin/bash

And bootstrap pkgsrc:

% cd /usr/pkgsrc/bootstrap
% ./bootstrap

From now on, you'll have a /usr/pkg directory filled with necessary bits for building packages from pkgsrc.

If you are to install services from pkgsrc packages, you'll have to copy NetBSD‘s /etc/rc.subr to debian's /etc directory:

% wget -O/etc/rc.subr "http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/etc/rc.subr?rev=1.96&content-type=text/plain"

Create an ad-hoc rc.d directory:

% mkdir /usr/pkg/etc/rc.d

Let's say you'd like to install nginx out of pkgsrc, possibly because debian‘s version is outdated or it does not contain your favorite module. Add the desired option to pkgsrc's options file, /usr/pkg/etc/mk.conf:

PKG_OPTIONS.nginx+= naxsi spdy

Build the software:

% cd /usr/pkgsrc/www/nginx
% /usr/pkg/bin/bmake install clean clean-depends

Copy the startup script:

% cp /usr/pkg/share/examples/rc.d/nginx /usr/pkg/etc/rc.d/

Enable the service:

% echo "nginx=YES" >> /etc/rc.conf

And start it:

% /usr/pkg/etc/rc.d/nginx start

Now, how you integrate services start to your favorite init system is up to you!