Monthly Archives: November 2009

Setting up subversion on Mac OS X 10.5+

If you need a source control system (why wouldn’t you?) and you have a Mac, you have everything you need already built in. OS X ships with a Subversion (SVN) server and client by default. All you need to do is turn them on.

Setting Up Subversion Server

Create the following launchctl service definition file, name it org.tigris.subversion.svnserve.plist, and store it in /Library/LaunchDaemons:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Debug</key>
        <false/>
        <key>GroupName</key>
        <string>staff</string>
        <key>Label</key>
        <string>org.tigris.subversion.svnserve</string>
        <key>OnDemand</key>
        <true/>
        <key>Program</key>
        <string>/usr/bin/svnserve</string>
        <key>ProgramArguments</key>
        <array>
                <string>svnserve</string>
                <string>--inetd</string>
                <string>--root=/PATHTOSVNGOESHERE/svn</string>
        </array>
        <key>ServiceDescription</key>
        <string>SVN Version Control System</string>
        <key>Sockets</key>
        <dict>
                <key>Listeners</key>
                <array>
                <dict>
                        <key>SockFamily</key>
                        <string>IPv4</string>
                        <key>SockServiceName</key>
                        <string>svn</string>
                        <key>SockType</key>
                        <string>stream</string>
                </dict>
                <dict>
                        <key>SockFamily</key>
                        <string>IPv6</string>
                        <key>SockServiceName</key>
                        <string>svn</string>
                        <key>SockType</key>
                        <string>stream</string>
                </dict>
                </array>
        </dict>
        <key>Umask</key>
        <integer>2</integer>
        <key>UserName</key>
        <string>USERNAMEGOESHERE</string>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
                <false/>
        </dict>
</dict>
</plist>

Set the username to the user account that will run the server (your username will do), and the groupname to the usergroup your account is associated with, usually staff.

Make sure you chown the user and group of the plist file:

sudo chown root:wheel /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist

Now we need to set up the launchctl script to run the service:

sudo launchctl load /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist
sudo launchctl start org.tigris.subversion.svnserve

The above set up will run the svnserve subversion server on-demand, as and when clients connect to it.

SVN Clients I recommend that you use a graphical SVN client. You don’t need to, as OS X ships with a command-line client built in, which you can test with the following command:

svn co svn://your.host.name/SomewhereInYourRepository

However, life will be a lot simpler if you use something like Versions

Thanks to the following blog posts for source information