Tag Archives for mac
There’s an absence of information on how to get a Subversion server running on Mac OS X, and what information there is on the web gives the impression that it’s difficult. It’s not.
I used to run an application called Mac SVN Server – MAS, a standalone app with Apache and a Subversion server all built in, by Uli Kusterer. You just run it and you have an instant web based svn server. But it’s all packaged up, meaning it’s not that easy to upgrade to new versions of svn, and is pretty heavy weight considering it’s an entire Apache 2 web server.
Instead, contrary to what most web sites seem to say, you can just run svnserve, the Subversion custom server component with Mac OS X. Here’s how I did it:
- Download the Subversion package from Martin Ott’s .mac page and install it on the Mac running 10.5 (Leopard) or later, that you’re going to use as your Subversion server. This includes the svn client and the server. It’s a standard Mac package installer, so just run it and you’re done. All the binaries will end up in /usr/local/bin.
- Create a new user called “svnuser”.
- Create a directory for your repository. Use mkdir /Users/svnuser/svn, or if you need to, use sudo mkdir /Users/svnuser/svn.
- Create your repository. Use sudo svnadmin create /Users/svnuser/svn. Check the directory to make sure it has correct ownership for svnuser, and if not do a sudo chown -R /Users/svnuser/svn to set it correctly.
- If you have a repository from another Subversion server then you can simply copy it over the top of the new directory, and it will work fine, so long as the repository version is supported. For Subversion 1.5, it will also support a 1.4 repository. I copied my old 1.4 repository from MAS, and it’s worked perfectly. You may need to do another chown to make sure the ownership is correct.
The server is now installed. To run it, simply log in as svnuser and run the server with svnserve -d -r /Users/svnuser/svn. You can now access it from any client (1.4 is built into Mac OS X 10.5 so no need to install the client anywhere) by doing a standard svn check out: svn co svn://ipaddress-of-svnmac/repositorypath
But instead of running it manually, we can run it automatically when the server Mac starts up by using launchd. You can read up on Getting Started with launchd, but basically it’s the new startup process in Mac OS X 10.4 (Tiger). So, to start svnserve automatically, create the file /Library/LaunchDaemons/org.tigris.subversion.svnserve.plist, and put the following in it:
<?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>Label</key> <string>org.tigris.subversion.svnserve</string> <key>UserName</key> <string>svnuser</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/svnserve</string> <string>--inetd</string> <string>--root=/Users/svnuser/svn</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>
This automatically starts the server when it boots. It also switches it from a standalone daemon to running under inetd, but it makes no real difference. There are a lot of different versions of this plist out there, but this is the only one I got to work. Unfortunately I can’t remember the site I borrowed it from. Email me if it’s you.
Note that the UserName property defines the user to runs svnserve as, but launchd only allows this property when it is running as root. There are two launchds on the system, one running as root (process 1), and one running as each user. The one running as root loads its plists from /Library/LaunchDaemons.
Updated from comments over time.