Running Perforce on FreeBSD 10

Yesterday I updated our company server to FreeBSD 10. It went pretty well with only a few glitches: had to remove libiconv (documented in UPDATING) and some of the ports (such as Perl 5.16) needed manual recompilation as portupgrade failed on them.

But I quickly discovered that Perforce does not work – attempting to start the server produces the error message:

Shared object "libstdc++.so.6" not found, required by "p4d"

The reason is that FreeBSD 10 includes a new C++ stack and gcc, including libstdc++, is not installed by default.

So the problem is easy to fix: install lang/gcc from ports. This will bring back libstdc++ and Perforce will run smoothly again.

Update 4/23/2014: Perforce version 2014.1 has a FreeBSD 10 specific build, which does not depend on libstdc++.

Year-End Server Upgrades

At the end of every year I take some time to upgrade server hardware (if necessary and if it brings any benefit to the business) and to bring all software on it to the latest level. We are trusting our small business to FreeBSD for the second year – since 8.1. And I’m really happy with the OS. There are two business-critical services on it: Perforce and AFP file services (Netatalk).

On the hardware side this upgrade moved the boot/system partitions to SSD. The speed increase is dramatic. The machine feels much faster. Some tasks, like portsclean -D, which previously took considerable amount of time are completed in seconds. FreeBSD also supports TRIM, just don’t forget to specify -t for newfs when you create file systems. Now I’m investigating whether our ZFS pool would benefit from adding an SSD for L2ARC. Here I would like to note how much I love to use my ancient DLT VS tape drive to do backups and restores. Just dump, replace the disks, partition/create file systems, and finally restore. A truly easy and seamless experience!

FreeBSD 9.1 was officially released yesterday. The upgrade went smoothly, as usual. I also brought Perforce and Netatalk to the latest binaries. In case of Netatalk this means 3.0.1. This version puts AFP metadata into a database and does not trash your folders with AppleDouble directories. Just make sure that your /var filesystem has enough free space for it. In my case the CNID database occupies about 200MB (for 2.5TB of shared files).

Speaking of Perforce: the latest P4 Visual Client (2012.3) brings partial retina display support! Partial means that while text is high resolution, all graphical elements are just pixel-doubled. The majority of the UI is text, so image aren’t a big deal.

Switched to the Free 20/20 Perforce “Licensing”

Got the regular yearly email from Perforce that it’s time to renew our licenses. What they did not tell me this time, however, is their “20 users/20 workspaces free forever” stuff. Asked their licensing specialist to clarify this situation. Below is her answer.

Perforce is free for up to 20 users and 20 workspaces, and an unlimited number of files. Or free for an unlimited number of users and workspaces, and up to 1,000 files. The free version has all of the same features and functionality as the purchased version, aside from the restriction on workspaces and number of files.

With the licensed version, you purchase the number of users required and can have unlimited files and workspaces.

This free model had been introduced earlier this year, and is a great way to get your feet wet with the world’s best source control management system – at an unbelievable “cost”.

Being a small business we are well within the 20/20 limit, and I’m an SCM junkie, so support is not something we really need (even fixed some tougher bugs directly in our database after migrating it from Windows to FreeBSD – but is is not something for the faint of heart).

All this means that we saved a lot of money and still have the best SCM. Thank you Perforce!

Integrating Perforce with Xcode 4

I prefer to work with first rate tools. You might call it snobbery, but I’m just too old for spending my precious time on fiddling with inferior products. That’s why I’m using Mac OS X and even more the reason I chose Perforce as our source control system. It simply blows the competition away.

When Apple introduced Xcode 4, I had realized with horror that they removed Perforce support. This was simply unacceptable for me. I would give up on Xcode much easier than giving up one of the cornerstones of our business. So I waited patiently, filed bug reports with Apple, until the buggy-to-the-level-of-unusability Xcode 4 was released. I decided to stick with Xcode 3 for the foreseeable future (until of course Apple dropped the tools and I had to migrate).

I did not want much from the Xcode side – just let me check out the files when I start working on them. I usually handle all the other stuff (like diffing, code review, etc) from P4V. Then while walking through all the Xcode 4 options and menu items (to familiarize myself with the inevitable new tool) I found something on the Behaviors preference pane.

You can execute a shell script every time Xcode unlocks a file. Fortunately Perforce locks all the files that are under source control and not in the checked out state – so you can be sure that all your files will be locked when not checked out. This fits perfectly with the Unlock file behavior. When you start working on a file Xcode wants to unlock it and executes your script. The script could then check out the given file from Perforce. The checkout will unlock the file, so everybody will be happy.

My xcode4edit.sh script is pretty straightforward:

#!/bin/sh
`cat ~/.profile | grep P4PORT`
`cat ~/.profile | grep P4CHARSET`
`cat ~/.profile | grep P4USER`
`cat ~/.profile | grep P4CLIENTPATH`
/usr/local/bin/p4 edit ${1#file://localhost}

This is checked in into the root of the depot so every team member have access to it. My .profile (as well as other members of the group) contains the actual configuration parameters:

export P4PORT=<server>:1666
export P4USER=<user>
export P4CHARSET=utf8
export P4CLIENTPATH=/Volumes/Data/Workspace

Of course you can add additional configuration variables to the script and into .profile if you want.

Output from the p4 edit command will go into the Console, so you can use that for debugging any problems you face.