You are currently looking at an older section of the website.
Please check the new version of the site at for updated content.

wincent knowledge base

« Building pwgen on Mac OS X 10.3 | Main | Building ee/aee on Mac OS X 10.3 »

November 21, 2004

Building Subversion 1.1.0 on Mac OS X 10.3

I've recently had to do a clean install and so I decided to take the opportunity to set up a new Subversion version control repository, this time using Apache 2.0 as part of the backend so that I will be able to access the repository from other machines in the future should I need to. This article shows the steps I went through to get this working on Mac OS X 10.3.

As per usual, these instructions assume that you've got the Xcode Tools installed, as well as wget.

My first step was to grab the latest version (4.3.21) of Berkley DB. Little did I know that Subversion doesn't yet support the latest version! It was only later on when all of this didn't work that I realized this was a problem. While using Google to try and find a solution, I stumbled across Fred Sanchez's blog, and out of curiosity looked at the "dobuild" in is public iDisk. Lo, there was the comment that revealed the trouble of my woes: "# Latest is 4.3.21, but SVN is not ready". It's a shame I had to stumble across the answer like that instead of finding it on the Subversion website!

Anyway, for the record, here is how to build Berkley DB 4.3.21. This and the older version, 4.2.52, can happily coexist on the same system.

tar xzvf db-4.3.21.tar.gz 
cd db-4.3.21/build_unix/
sudo make install

Now here's how to build 4.2.52, after you've obtained the patches from here. This assumes you've expanded the source archive, downloaded the patches, and copied them into the directory that appears when you expand the archive.

patch -p0 < patch.
patch -p0 < patch.
cd build_unix/
sudo make install

Now onto Apache 2. I downloaded 2.0.52, which is the latest at the time of writing. Note that I build Apache with SSL support in case I ever want to put the repository out on the Internet. For now I only intend to use the server "in house", behind a firewall (in fact, I'll be connecting to it on "localhost") so I haven't set up SSL just yet.

tar zxvf httpd-2.0.52.tar.gz 
cd httpd-2.0.52
./configure --enable-dav --enable-so --enable-ssl
sudo make install

With these prerequisites in place I moved onto Subversion itself:

tar xzvf subversion-1.1.0.tar.gz 

# replace this with the path to the Apache source on your machine cd ../httpd/httpd-2.0.52/srclib/ cp -R -v apr apr-util subversion-1.1.0/
cd subversion-1.1.0/ sh ./ ./configure make sudo make install

I then wanted to make Apache 2 start up at boot time, but without interfering with the existing Apache installed by default on Mac OS X. I took the standard Apache startup item, copied it, and made appropriate customizations. The following steps show the copying, but I haven't shown the customizations.

cd /System/Library/StartupItems/
cp -r Apache /Library/StartupItems/Apache2
cd /Library/StartupItems/Apache2

Once customized you will need to add a line like "WEBSERVER2=-YES-" (I used "WEBSERVER2" to distinguish the Apache 2 webserver from the default Apache 1 server which appears as "WEBSERVER") to the /etc/hostconfig file (which needs root privileges).

I then made some changes to the /usr/local/apache2/conf/httpd.conf configuration file. To avoid clashes with the default server, I changed the "Listen 80" directive to read "Listen 8080". I am not sure what the standard port to use for this purpose is, because I've seen 8080, 8800 and 8008 recommended in different places on the web. The truth is it doesn't have a lot of importance.

I also changed:

User nobody
Group #-1

To read:

User svn
Group svn

And edited the "ServerAdmin" directive to match my email address. Finally, I added some lines to the bottom of the file. As you can see, my repository is for now located at "/Users/wincent/Developer/svnrep":

# prevent normal access; this server is for Subversion only
<Directory /usr/local/apache2/htdocs>
    Order deny,allow        
    Deny from all           

DavLockDB /usr/local/apache2/var/dav/DavLock
<Location /svnrep>
DAV svn SVNParentPath /Users/wincent/Developer/svnrep
AuthType Basic AuthName "Subversion repository" AuthUserFile /Users/wincent/Developer/svnrep-auth Require valid-user Order deny,allow Allow from all

I then needed to set up the svn user and group. I found out about neat way to do this from the command line:

echo 'svn::200:200::0:0:Subversion:/var/empty:/usr/bin/false' |\
sudo niload -v passwd /
echo 'svn:*:200:svn' | sudo niload -v group /

I also had to create the authentication file:

/usr/local/apache2/bin/htpasswd -cm ~/Developer/svnrep-auth wincent

I used pwgen to cook up a suitable password:

pwgen -1

Finally, I had to create the "/usr/local/apache2/var/dav/" and ensure that the svn user/group could write to it:

sudo mkdir -p /usr/local/apache2/var/dav
chown svn:svn /usr/local/apache2/var/dav

Things work just like my old Subversion repository, except that now I access things using "http://localhost:8080/svnrep" URLs instead of "file:///usr/local/svnrep" URLs. Apache is the arbiter of access to the repository itself, the parent directory is owned by the svn user and group, so I can't write to the repository by mistake if I use a file:/// URL. Xcode integration continues to work fine with the new set-up.

Posted by wincent at November 21, 2004 03:51 AM