Recently we got our hands on some nice DDR3 era hardware, which we’ll use eventually for NAS purposes. It’s got 96 gigs of ECC RAM, two Xeons, the works. For fun we’ve decided to run OpenIndiana on it, an illumos distribution. OpenIndiana has a package manager called the Image Package System (IPS), and the default repositories have basically everything we’d need, but for another layer of excitement we put pkgsrc on here too. pkgsrc is a repository of package build scripts, most of which work on NetBSD, Solaris, illumos, Linux, macOS, and more! Joyent actually provides a binary distribution of pkgsrc for illumos, but on our everlasting journey for increasingly esoteric layers of fun we’re building pkgsrc from source. Don’t worry, it was easier than you think.
Ok so let’s get something out of the way first, if you’re familiar with pkgsrc and just want to know what dependencies to install, here’s the spoilers. Install this stuff:
$ pkg install gcc-11 gnu-binutils c-runtime system/header
Then do your usual pkgsrc bootstrap. For everyone else, here’s the brief tale of how we got to that point.
How we got there
First off we need an actual OpenIndiana installation to work from. We’ll spare you the details since the installer explains itself fairly well, but if you have a lot of RAM you might want to modify the default partition layout. We ended up with a 96GB swap partition which is uhh, excessive, you might say, particularly on a 200GB SSD.
Once we reboot into the system, a system update is in order.
$ pkg update
This updated something upwards of 400 packages for us and took awhile. A coffee break later and we can move on to grabbing a copy of pkgsrc itself.
$ curl https://cdn.netbsd.org/pub/pkgsrc/stable/pkgsrc.tar.xz | xz -d | sudo tar xvof - -C /usr
This downloads a copy of the latest stable snapshot of pkgsrc and extracts it into
/usr. Everything in the tar file is in
pkgsrc/whatever so we end up with
/usr/pkgsrc as our source tree. If you’re wondering why we use
xz -d as its own step instead of passing
J to tar: for some reason tar on our system gives us this weird error
tar: directory checksum error when we try that, so we’re not sure what it’s doing but we don’t think it’s doing it right.
We’ll probably also need a compiler toolchain so let’s install
binutils to get things going.
$ pkg install gcc-11 gnu-binutils
Cool, so do we have everything we need? Let’s find out:
$ cd /usr/pkgsrc/bootstrap $ ./bootstrap --prefix=/usr/pkg --prefer-pkgsrc yes --make-jobs 16 [... blah blah blah a bunch of build output ...] ld: fatal: file crt1.o: open failed: No such file or directory
Hmm, that’s no good. We actually have no idea what
crt1.o is used for, but whatever the case, we definitely need it. This is a decent opportunity to learn the ropes of IPS’s package searching features.
pkg search has a lot of advanced querying functionality, and the
man page has some examples of it. Here it demonstrates searching the locally installed packages (
-l) for a file named
$ pkg search -o path,pkg.name -l file:basename:vim PATH PKG.NAME usr/bin/vim editor/vim/vim-core
This demonstrates the
file:basename: query, and we can use that to search the remote repository for a file named
$ pkg search file:basename:crt1.o INDEX ACTION VALUE PACKAGE basename file usr/lib/amd64/crt1.o pkg:/firstname.lastname@example.org basename file usr/lib/crt1.o pkg:/email@example.com basename file usr/lib/amd64/crt1.o pkg:/firstname.lastname@example.org basename file usr/lib/crt1.o pkg:/email@example.com pkg install c-runtime
Ok let’s give
bootstrap another shot to see if that was all we needed.
conftest.c:9:10: fatal error: stdio.h: No such file or directory 9 | #include <stdio.h> | ^~~~~~~~~
Alright fair enough, so we didn’t have our libc headers. Let’s search for
stdio.h this time.
$ pkg search file:basename:stdio.h INDEX ACTION VALUE PACKAGE basename file usr/include/stdio.h pkg:/firstname.lastname@example.org $ pkg install system/header $ ./bootstrap --prefix=/usr/pkg --prefer-pkgsrc yes --make-jobs 16
And what do you know it works! That’s all we need to successfully bootstrap
pkgsrc and start building things. After that we succesfully built rust from source, which pulled in a build of
llvm and a few other fan favorites along the way, so it’s safe to say this is a fully functional pkgsrc bootstrap. Thanks for coming along on the journey.
Until next time!