How to install a stand-alone SVN Server on Mac OS X 10.6 (Snow Leopard)
(9 votes, average 4.44 out of 5)
Sunday, 04 October 2009 21:43

How to install a stand-alone SVN Server on Mac OS X 10.6 (Snow Leopard)

Introduction

I have a number of small projects lying around, to which I would like to bring some order. My main working machine is the stationary Mac, but I also use my Windows laptop quite often (when I am on the road). So I decided to have the main repository on the Mac (backed up using TimeMachine), and then have Subversion (SVN) take care of the version control. Mac OS X 10.6 comes with SVN pre-installed out of the box. But it is preconfigured to run locally only. What I want to do is to make the repository available on the network, so that I can check the projects in and out also from my Windows laptop. To accomplish this, there are mainly two paths to go down:

  • Either you configure the Apache web server to expose the SVN repository
  • Or you configure SVN directly using the launch daemon

Personally, I don't use the built in apache web server for anything. So, I have not started it anyway. For that reason I decided to go for the 2nd approach, which starts the stand-alone SVN server on the Mac.

Obtaining SVN

I installed the SVN server using fink. It gives easy access to most of my frequently used UNIX programs. Once you have fink installed, open the terminal and install SVN like this:

 

sudo fink install svn

 

This will download and unpack the SVN server, and put it by default into the /sw/bin directory.

 

Configure the server

You are ready to configure the SVN server as a stand-alone server. For doing so, you need to tell the launch daemon that you want to expose SVN on the network. The best way to do this is by creating a file with the following contents:

 

<?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>GroupName</key>
  <string>_svn</string>
  <key>UserName</key>
  <string>_svn</string>
  <key>Umask</key>
  <integer>2</integer>
  <key>inetdCompatibility</key>
  <dict>
   <key>Wait</key>
   <false/>
  </dict>
  <key>Label</key>
  <string>org.tigris.subversion.svnserve</string>
  <key>OnDemand</key>
  <true/>
  <key>Program</key>
  <string>/sw/bin/svnserve</string>
  <key>ProgramArguments</key>
  <array>
   <string>svnserve</string>
   <string>--inetd</string>
   <string>--root=/Volumes/Development/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>
</dict>
</plist>

 

 

The file must be called: /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist

 

Note for the first, that this will start (on demand only) the SVN server as a user _svn. You do not need to create the user on your system. It works also without. The reason why I would use the special _svn user for the SVN server is that it reduces the risk that someone can exploit SVN as a backdoor into your system, since the _svn user no privileges to access/modify any private files. Then also note the value for the Program key. It points at the SVN server program. If you install it like me using fink, it will be located on /sw/bin/svnserve. Make sure that the configuration points at the location where you installed the SVN server. And finally, note the path under ProgramArguments. The value that starts with --root points at a directory, where you want to create the SVN repository. I have located it on a separate hard drive. But you can just put it anywhere you want.

 

Now, make sure that the file is owned by root, since otherwise the configuration will be ignored by the launch daemon. Use the following command to align the ownership:

 

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

 

Create the repository

Before we now can start the SVN server, we must create a repository. Place it on an disk that is always attached, and which is regularly backed up. I placed it into a folder named svn on an internal disk called Development. For creating the repository, you should use svnadmin tool, which comes as part of the SVN distribution. Use it as follows:

 

sudo -u _svn svnadmin create /Volumes/Development/svn/trunk

 

Now, remember that the server will be started in the context of the _svn user. Change now the ownership of the repository to _svn, and make sure that _svn has the rights to manage its contents:

 

sudo chown -R _svn:_svn /Volumes/Development/svn
sudo chmod -R ug+rwX,o= /Volumes/Development/svn

 

Start the server

The SVN server will be available next time you restart the Mac. If there are any issues, you should inspect the system log for details. In my case, I wanted to see the error messages right away. So, before restarting, I tested if the launch daemon can stat the SVN server with the following commands:

 

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

 

If you didn't get any error messages, you should all should be fine. You can check out your repository (which does currently not contain anything) using the following command:

 

svn checkout svn://localhost/trunk trunk

 

So, that's it. You're ready to do some work :-)
Have fun!

 

Last Updated on Sunday, 18 April 2010 00:29
 

Comments  

 
+1 #1 2012-01-24 03:35
Thanks for the excellent tutorial. Everything works, but one caveat is that out of the box, fink doesn't contain all of the packages (including svn). You have to issue the recommended command in the terminal that prints right after the install of fink, which is also slightly non-standard.

Too bad fink binaries aren't available for OSX 10.6 and 10.7!!! I guess it's a minor issue, but maybe they'll catch up with the rest of the OS X universe someday.

Overall, my install took about 3 hours on an Intel XServe, but anyone could beat that.
Quote
 

Add comment


Security code
Refresh