kaashif's blog

Programming, with some mathematics on the side

Pkgsrc on Slackware

2014-10-11

Back in the day, I used to use Slackware. It was the best distro around and all the cool kids used it. Nowadays, it's rather different: a much lower proportion of people use Slackware. Despite the efforts of Eric and Patrick (and whoever else), Slackware isn't really all that popular. It's still a solid distro, though. There is one problem

that seems to annoy people.

No dependency management.

But isn't that a selling point of Slackware?

Maybe it is, but it causes a lot more problems than it solves. If you're going for a system where not a single thing was installed that you didn't want and where you've built all the packages and kernels from source, then you're a lot better off with Gentoo (which has a much cooler selling point: USE flags).

Using binary packages without dependency management just causes problems. If you try to use sbopkg (the SlackBuild package manager), you quickly find that having to build from source and not being able to manage dependencies is the worst of every single world: installing anything takes ages and the builds will all probably fail halfway through.

Of course, there is a "solution" in place: queues. You're supposed to look up the whole dependency tree beforehand and queue up all of the packages, one by one. Pretty tedious.

There are alternatives, like slapt-get, but those require you to surrender all control to the package manager, at which point you might as well go back to Ubuntu. So we want dependency management and control. Where can we turn? Of course, NetBSD's pkgsrc.

Getting started

You might think that since it's part of the NetBSD project, pkgsrc can only run on NetBSD. That's not true, it can run on any vaguely POSIXy OS. To get started on Slackware, you need to make sure you have a few of the sets. I'm not sure how many you actually need, but this is what I got it down to:

  • a
  • ap
  • d
  • l
  • n

The need for "a" is obvious: that's the base. You need "d" and "l" for compiling, which we'll be doing a lot of. "n" for downloading pkgsrc. "ap" for, well, being able to do things while you build everything (which could take a while). Eventually, you could uninstall "ap" and "n" and replace everything with programs from the pkgsrc tree. You can't do that yet, though.

Next, get and extract the pkgsrc tree:

# cd /usr
# wget ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz
# tar xzvf pkgsrc.tar.gz

Now, there is a ports-looking sort of thing under /usr/pkgsrc. Nifty. But you need NetBSD's make to use it. Luckily, there's a bootstrap script to get you started.

# cd /usr/pkgsrc/bootstrap
# ./bootstrap

Something should happen and at the end, there should be some binaries in /usr/pkg/bin and /usr/pkg/sbin. That's where all of the pkgsrc installed stuff will go, so you might want to add the following to your shell's profile:

export PATH=$PATH:/usr/pkg/bin:/usr/pkg/sbin

Additionally, you might want man pages.

export MANPATH=$MANPATH:/usr/pkg/man

Now everything's set up to start building. You might not have an X server yet and even if you do, you'll want to replace it with pkgsrc's. Installing a port is easy:

$ cd /usr/pkgsrc/x11/modular-xorg-server
$ sudo bmake install

On my old laptop, this took several hours. If you have a more recent machine, it shouldn't take too long.

While building, you might think "Hey, why's it installing Perl, I already have that!". That's a valid question, but pkgsrc doesn't detect dependencies by looking in /usr/bin/, it searches its own package database, which is completely empty.

This means that you'll end up building Perl, Python and dozens of libraries you already have. After pkgsrc is done, you might as well uninstall all of the Slackware packages you don't need. Go to /var/log/packages and and removepkg everything you don't want.

What now?

You can search the ports tree with /usr/pkgsrc/pkglocate for all your favourite software and install it. There's more software in pkgsrc than there is in the default Slackware repos and it's a lot more convenient than sbopkg. For more info: http://www.netbsd.org/docs/pkgsrc/.

Disclaimer: I do not use pkgsrc on Slackware on a day-to-day basis, so don't blame me for your problems. Send something in to the pkgsrc mailing list or some NetBSD IRC channel instead.