2010
01.16

I just finished setting up Perforce Server on my system. Unlike the typical OS X application, this isn’t something you can just drop in the Applications folder, and there is no automated installer to help you out. Regardless, it’s not too difficult once you know what to do.

Downloading the files and making them executable

Download the Perforce Server (P4D) and the Perforce Command-Line Client (P4) from the Downloads page on the Perforce website. Be sure to download the versions for “Mac OS X for PPC/X86″.

Once they have been downloaded, you’ll need to change their file permissions. Using Terminal, you can change the permissions with the chmod command to make them executable, as follows:

chmod +x p4
chmod +x p4d

If you’re using Path Finder, you can also just use Get Info and change the properties there. As far as I know, it just the owner needs to be able to execute the file so -rwxr–r– or chmod 744 should be fine.

Creating a Perforce server root directory

The Perforce server needs a place to store all user-submitted files and associated metadata. I’ve found that a good place to put that is in /Developer/Perforce, although you could put it anywhere you’d like. Assuming that’s the same location you want to use, create the following two folders:

/Developer/Perforce
/Developer/Perforce/p4root

Once you’ve created the folders, move the p4 and p4d files you downloaded earlier to the /Developer/Perforce directory.

Configuring Perforce to start at boot time

You’re going to want to use the launchd service to start Perforce at boot time. This is done by creating a Property List (plist) that contains the required paths and information used by Perforce.

Create a text file named com.perforce.plist, and place it in “/Library/LaunchDaemons/“. This file must be configured with “root” as the owner, and “wheel” as the group. Using Terminal, you can change the owner and group with the chown command, as follows:

chown root:wheel /Library/LaunchDaemons/com.perforce.plist

With Path Finder you can also just duplicate one of the existing plist in the /Library/LaunchDaemons directory and then rename it to com.perforce.plist. Either way, once you have created the file, edit it with a text editor such as TextMate, or with Apple’s Property List Editor. This is what I used for my setup:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Debug</key>
	<false/>
	<key>Label</key>
	<string>com.perforce</string>
	<key>OnDemand</key>
	<false/>
	<key>ProgramArguments</key>
	<array>
		<string>/Developer/Perforce/p4d</string>
	</array>
	<key>EnvironmentVariables</key>
	<dict>
		<key>P4LOG</key>
		<string>/Library/Logs/Perforce/p4log.log</string>
		<key>P4PORT</key>
		<string>1666</string>
		<key>P4ROOT</key>
		<string>/Developer/Perforce/p4root</string>
	</dict>
	<key>RunAtLoad</key>
	<true/>
</dict>
</plist>

As you can see in the plist, the P4LOG environment variables is set to /Library/Logs/Perforce/p4log.log. By placing it there instead of with the other Perforce files, you’ll have a dedicated log entry in Console and Time Machine automatically excludes files in /Library/Logs.

The Perforce daemon

Although it should now start automatically when you restart Max OS X, you can manually load and unload the p4d daemon via Terminal with the following commands:

sudo launchctl load /Library/LaunchDaemons/com.perforce.plist
sudo launchctl unload /Library/LaunchDaemons/com.perforce.plist

You’ll need to enter your admin password to execute either command.

No Comment.

Add Your Comment

Comments links could be nofollow free.