SVN 1.5, Open Directory and OS X Server

We've upgraded our Subversion repository on our OS X 10.5 Leopard Server from 1.4.x to 1.5.x and hooked it up to the Open Directory for user authentication.   A fair amount of digging was required so I thought I'd share the experience...

1. Download and Install a Mac OS X Binary of 1.5.x

There's a MacPorts version and Fink version but we decided to go for the standard installer from collab.net, specifically we used the 1.5.4 Universal Binary found at 

Font size
This installs the v1.5.x binaries in /opt/subversion/bin.  We need to add this to the system path so the OS picks up v1.5.x rather than 1.4.x (which is in /usr/bin).  Most documentation suggests adding this path to the top of the file /etc/path so it is loaded first, before /usr/bin.  However OS X seems to enforce an order to the path such that system defaults such as /usr/bin are always loaded first (perhaps as a safety measue of some sort to stop us crazy people breaking thier OS?).  The solution is to modify the file /etc/profile by adding this line to the top of the file:

PATH=/opt/subversion/bin:$PATH;

[credit to Renato for his reply at the bottom of this page for figuring all this out!! - http://littlesquare.com/2008/01/24/upgraded-to-leopard-making-use-of-etcpathsd-and-path_helper/ ]

2. Create the Folders to Hold the Repositories

Most services in OS X Server use the Library folder to host their content so we did the same for SVN.  We will potentially host more that one repository so we created 

/Library/Subversion/Repositories/ 

to hold them.  

3. Make a Repository

Inside this 'Repositories' folder we created the folder that will hold our main repository:

mkdir main

Then we created the SVN repository:

sudo svnadmin create ./main

At this point we dumped the old repository from our old system and loaded it into this fresh repository:

sudo svnadmin load ./main < /dumpfile.dmp
 
And then set the correct owner and permissions:

sudo chown -R www:admin /Library/Subversion
sudo chmod -R 770 /Libray/Subversion

4. Set Up a Web Site to Host SVN

Using Server Admin, we created a new website.  We wanted this on the standard HTTP port (80).  We also changed the Web Folder from /Library/WebServer/Documents to /Library/Subversion becasue the /main url we're planning to use ended up mapping to the main.css file in the original folder! 

In the Options tab, we turned on WebDAV

In the Realms tab we created a new Realm (by pressing the little + buttom under the list of Realms) to control the access to the repository.  We gave the realm a name (the actual name is not important), Authentication set to Basic and the Location set to /main

Once the realm was created we assiged our Developer group to have Browse and Read/Write WebDAV rights

We pressed Save to commit these setting for the site.  

5. Upgrade the Apache SVN DAV module for SVN 1.5.x

Because we upgraded to SVN 1.5.x, we also need to upgrade Apache's DAV SVN Module.  The new version was installed with SVN 1.5.x.  First we backed up the old one (just in case!) and then copied the new one accross to the standard folder.

mv /usr/libexec/apache2/mod_dav_svn.so /usr/libexec/apache2/mod_dav_svn.so.1.4

cp /opt/subversion/lib/svn-apache/mod_dav_svn.so /usr/libexec/apache2

Then we enabled the svn module in Server Admin and saved the changes:

6. One More Thing...

Back at the command line we had to make a small change to hook up the dav svn module in such a way that Server Admin doesn't keep overwriting our settings.  First we created a new file in the /etc/apache2/sites folder:

sudo vi svn.conf.include

And we edited it's contents as follows:

<Location /main>
    DAV svn
    SVNPath /Library/Subversion/Repositories/main
</Location>

We then include this file in the config file for the virtual host for the site we set up.  We edited the file (which will be named something like 000x_any_80_websiteurl.conf by adding this line:

include "/etc/apache2/sites/svn.conf.include"

near the end of the file - just after some commented out Include statements and just above the line containing LogLevel warn.

One more restart of the Web Service in Server Admin and our new repository is up and running. :-)