Install Packages for Old OpenBSD Versions

I found myself running an old version of OpenBSD and wanting to install a binary package when, lo and behold, running pkg_add failed with the message:

$ sudo pkg_add rsync
Error from http://ftp.openbsd.org/pub/OpenBSD/5.6/packages/amd64/
ftp: Error retrieving file: 404 Not Found
http://ftp.openbsd.org/pub/OpenBSD/5.6/packages/amd64/ is empty
Can't find rsync

Funny, this used to work. Since I don’t know OpenBSD very well, I had to figure out what was going on.

According to the man page, the pkg_add command is configured via the environment variable, PKG_PATH, which on my system looked like this: http://ftp.openbsd.org/pub/OpenBSD/5.6/packages/amd64/. I browsed the server, http://ftp.openbsd.org/pub/OpenBSD/, and, sure enough, the directory named “5.6” was gone.

I know that OpenBSD only supports the current version and the one previous (5.8 is the current release on the day I write this). What I didn’t know was that the official repository would remove the old files from the FTP server. Lesson learned.

My next question was, are there any mirrors that keep old packages? Turns out the answer is yes. Reading the documentation on the OpenBSD download page I saw this phrase at the end,

“Depending on the disk space available, mirrors may provide more contents, such as older releases, current source tree, etc.”

If you’re running an unsupported version of OpenBSD, my first piece of advice is to upgrade if you can. If you can’t, or if now isn’t a good time, then you can surf the mirrors and find one that keeps older versions around.

Here are a couple of mirror servers that I found which contain older versions of OpenBSD. Please verify them yourself before you blindly use them.

Say I want to use a mirror on that list. This is how I would do so:

$ export PKG_PATH=http://ftp3.usa.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(machine -a)/
$ sudo pkg_add rsync

I wrote this blog post because when I tried searching the Internets for what was going wrong, I didn’t find anything. Maybe this will save you a few minutes. If you follow these instructions and they don’t work, please don’t spam the OpenBSD mailing lists. That’s what the “unsupported” part of “unsupported release” means.

Now, go upgrade your system. ;)

Further Reading

Here are some pointers to OpenBSD documentation about packaging and pkg_add.


Thanks to Kent Spillner for reading drafts of this and providing feedback.