At work I have been busy developing the server side component of our top secret sports game. Since the production server is to be running on OpenBSD, I decided it would be a good idea to actually develop it using the same operating system.
One slight snag was that OpenBSD is no longer supported by Perforce, the version control we use at work. The last version of Perforce available for OpenBSD was for OpenBSD 3.1. Unfortunately loads of stuff has changed since then (in both OpenBSD and Perforce) so this binary no longer works. This is a little annoying but since Perforce is pretty great to work with, I decided to look for ways to get around this issue. Luckily, I found a solution.
OpenBSD for i386 still provides Linux binary compatibility in the GENERIC kernel (compat_linux(8)) and the p4 command line binary works with it. Since I am mainly developing the software on OpenBSD using ssh, tmux and vim, the command line binary is all I needed anyway.
The following steps were required to get this to work.
First I enabled Linux compatibility using sysctl.
# sysctl kern.emul.linux=1
I then set this to be persistent across reboots by uncommenting the following line in /etc/sysctl.conf.
Finally I installed the fedora_base package (This actually calls the same sysctl command in the first step as well).
# pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/5.5/packages/i386/fedora_base
This package adds a self contained Linux file hierarchy inside /emul/linux containing various libraries that might be needed by the Linux binaries.
With these steps complete, all that I then needed to do was download the x86 Linux p4 binary (you might want to download the latest version) from the Perforce website.
$ curl -O http://filehost.perforce.com/perforce/r14.1/bin.linux26x86/p4
Then I copied it to /usr/local/bin and set the permissions to executable.
# cp p4 /usr/local/bin # chmod +x /usr/local/bin/p4
And that was it. The p4 command could then be used as normal.
$ export P4PORT=perforce.[host].com:1666 $ export P4USER=[username] $ export P4PASSWD=[password] $ export P4CLIENT=[client] $ p4 workspace $ p4 sync etc...
So this all works great for me. There are a few limitations however. The Linux binary compatibility only works on i386 (not amd64) builds of OpenBSD. The Linux binary compatibility also does not see much development or improvements nowadays so is still quite incomplete. I don't know how much longer it is going to remain part of the OpenBSD kernel. I was pretty surprised to see it in the GENERIC kernel in the first place.
Out of pure curiosity I attempted to run the p4v GUI client for Perforce on OpenBSD using Linux compatibility. It got up to the login window which was fully working, however after logging in and as soon as the main window appears the whole program would segfault. I didn't look into it much further since debugging tools in Linux compatibility are quite lacking but... Darn, So close! ;)
Perforce provides another, more official solution called GitFusion which should allow me to use git on OpenBSD to effectively utilize to the Perforce repo. However, even though it sounds pretty awesome I have yet to have a play with it. It also does not seem to support streams yet which would be a bit of an issue for this project.