Installing Subversion on Mac OSX

SubversionYesterday it was the third time in two years that I needed to install Subversion from scratch on Mac OSX. The third time to reinvent the wheel and learn from earlier mistakes. So now I wrote down some notes, which I like to share…

First, the installation

Currently the most up to date binary builds with installer come from Martin Ott. Download the package (currently 1.4.3) and install. No sweat, no pain. Then I want to make sure the svnserve daemon is running whenever I boot my mac. Time to get into the dirty handwork. Edit a property list like the one below (replace repository path name as needed), from the command line:

$ sudo vi /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist

This is the plist file:

<?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>daemon</string>
        <key>Label</key>
        <string>org.tigris.subversion.svnserve</string>
        <key>OnDemand</key>
        <true/>
        <key>Program</key>
       <string>/usr/local/bin/svnserve</string>
        <key>ProgramArguments</key>
        <array>
                <string>svnserve</string>
                <string>--inetd</string>
                <string>--root=/Users/you/Library/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>joe</string>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
                <false/>
        </dict>
</dict>
</plist>

Finally, add the configuration the the Launch process and restart the service:

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

Most important, the repository layout.

Subversion stores all projects and revisions in one set of database files, no possibility to go into the repository and do all kind of manual tweaks like with CVS. That should, in itself, be considered A Good Thing. But it doesn’t give me the possibility to backup a single repository separately, which I hate. So, my repository scheme now looks like this:

  • ~/Library/svn/project1
  • ~/Library/svn/project2
  • And so on…

Nice, but that means that I have to edit the same boring config file over and over again. Which I limited to the bare minimum, by moving the files with authentication credentials outside the repository and keep the basic config file the same for every repository. Just copy the standard svnserve.cnf file to a new repository and I’m up and running! The svnserve.cnf file:

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are “write“, “read“,
### and “none“.
anon-access = none
auth-access = read
auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
password-db = /Users/you/Library/svn/passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory.  If you don't specify an authz-db, no path-based access
### control is done.
authz-db = /Users/you/Library/svn/authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
#realm = My Realm

Oh yeah, and now put the appropriate authz and passwd files in the location you just specified (in this example simply the svn repository root).

Loose ends

All of this was based on two excellent resources:

The latter has also an item about making scheduled backups of your repository, which you should configure right away (yes, it is on my todo list)! If you’re using Eclipse as your IDE of choice, you should (must?) take a look at the Subclipse plugin. A timesaver!

[ratings]