Wednesday, September 3, 2008

Installing Subversion on Leopard

Having previously installed subversion on Linux without issue ($ sudo yum install subversion and $ sudo chkconfig --add svnserve) I was expecting a similarly happy experience with Mac OS X 10.5. Perhaps I wasn't paying as much attention the second time around which contributed to my woes. The various instructions I used as reference all got me part of the way for which I'm grateful.


As an aside, I'm also partway through the extraordinary Flow: The Psychology of Optimal Experience. In this case installing and configuring subversion was definitely not a flow activity for me. One of the precursors to achieving flow is being able to concentrate. Trying to find useful information on the Internet can be extremely frustrating. I know the information I'm looking for, I drop some search terms into Google, middle-click some likely links to open in new tabs, and then wade through the tabs looking for the good stuff. Effectively I've just broken my concentration to spend unproductive time looking for the answer to a question that can be difficult to phrase without trawling all manner of dead herrings (so to speak). Think about how good the MSDN documentation is and how easy it is to find not only the API you're looking for but also example code. Think about the code completion features in Visual Studio. These all contribute to getting you into a state of flow and keeping you there.


Getting back to my skirmish with subversion, here's how it all panned out. The first step is to install subversion (I know there are options that don't include compiling from source but I like to see the machinery working):



$ mkdir subversion
$ cd subversion
$ curl -O http://subversion.tigris.org/downloads/subversion-1.5.1.tar.gz
$ curl -O http://subversion.tigris.org/downloads/subversion-deps-1.5.1.tar.gz
$ # that's the letter O btw, not a number.
$ tar xzf subversion-1.5.1.tar.gz
$ tar xzf subversion-deps-1.5.1.tar.gz
$ cd subversion-1.5.1/zlib
$ ./configure
$ sudo make install
$ cd ..
$ ./configure --prefix=/usr/local --with-ssl --with-zlib=/usr/local
$ sudo make install

Actually I was in something of a hurry and some of the suggested options were causing the configure step to fail. The instructions I was following didn't include the step to build and install zlib, and didn't include specifying the location of the library. Configure would fail when trying to locate the library and googling turned up a lot of information but not much of it useful. YMMV.


So that takes care of $ sudo yum install subversion. The next step is to get subversion to load at boot. On Mac OS X this is handled by launchd. I've previously written a launchd plist for PostgreSQL under OS X 10.4 where the data was stored on a firewire-attached RAID. I have a strong recollection that it was a PITA trying to get it to wait for the RAID to be initialised before starting postgres. I went back to the freyside and used his sample plist. It was pretty close, but it didn't specify a username for running subversion. It turns out that there already exists a subversion account on Leopard, _svn. The modified /Library/LaunchDaemons/subversion.svnserve.plist is below. And the new service can be initialised without rebooting by $ sudo launchctl load /Library/LaunchDaemons/subversion.svnserve.plist.



<?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>Disabled</key>
    <false />
    <key>UserName</key>
    <string>_svn</string>
    <key>Label</key>
    <string>subversion.svnserve</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/bin/svnserve</string>
      <string>--inetd</string>
      <string>--root=/Users/dave/develop/source</string>
    </array>
    <key>ServiceDescription</key>
    <string>Subversion Standalone Server</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>inetdCompatibility</key>
    <dict>
      <key>Wait</key>
      <false />
    </dict>
  </dict>
</plist>

Nearly there. I'm using TortoiseSVN in Parallels to access my subversion repository (which is really not going to work if I use BootCamp). I created my repository via



$ svnadmin create /Users/dave/develop/source/

Trying to access the repository using the TortoiseSVN Repo-browser from Parallels resulted in the error expected FS format '2'; found format '3'. Turns out subversion 1.5 has a new repository format to support some new features. For some reason TortoiseSVN (1.5.3, Build 13783 - 32 Bit , 2008/08/30 20:59:46) on my system didn't want to talk to the new format. At this stage my repository is for personal use and I'm really OK with using the older format. I deleted my repository and started over. Note also that the _svn account needs to be able to write to the repository, it seemed reasonable to make _svn the owner of the repository:



$ svnadmin create --pre-1.5-compatible ~/develop/source/
$ sudo chown -R _svn ~/develop/source

Now to create the root for my c# code.



$ svn mkdir svn://localhost/csharp --username dave -m "c# source"
svn: Authorization failed

Duh, so after uncommenting the line # password-db = passwd in ~/develop/source/conf/svnserve.conf and adding an appropriate entry to ~/develop/source/conf/passwd my subversion repository is alive and I can access it from Parallels using TortoiseSVN.

No comments: