I set up Subversion on my home Mac Pro OS X 10.7.3 (Lion) and wrote down the steps for my reference.
Posting it here may help someone. Feedback is appreciated.
Lion already ships with Subversion 1.6.17, OpenSSH_5.6p1 and OpenSSL 0.9.8r. So we just need to use them.
First, let's create a group that will be given permissions to access the repositories, and anything else you may add in the future.
There is no groupadd and usermod in Mac so we'll use dscl to create a group (coders) and dseditgroup to add users to this group.
1. sudo dscl . create /groups/coders gid 1000
2. sudo dseditgroup -o edit -a <your_username> -t user coders
You can use the groups command to verify your account is a member of the coders group.
Create the directory structure for your repositories.
3. sudo mkdir /usr/local/svn
4. sudo mkdir /usr/local/svn/repos
And set the access permissions.
5. sudo chgrp coders /usr/local/svn/repos
6. sudo chmod g+w /usr/local/svn/repos
7. sudo chmod g+s /usr/local/svn/repos
We can now create our project repository, in the repos directory.
Set the file mode creation mask to give the group write permissions to the repository we are about to create.
8. umask 002
Create the repository for your project.
9. svnadmin create /usr/local/svn/repos/<project_name>
And set the user mask to the default value.
10. umask 022
You now have an empty repository, so let's create a working copy by checking out the current version to your home directory.
11. cd ~
12. svn co file:///usr/local/svn/repos/<project_name>
Create the basic structure and commit your changes to the repository.
13. cd <project_name>
14. svn mkdir branches tags trunk
15. svn ci -m "initial structures"
Now, let's enable remote access to the repository.
First, let's set up svnserve, the Subversion server program, so we can access the repository using the svn protocol.
(We're only going to access the repository securely, using svn+ssh, but it's nice to know svnserve is there if we ever need it.)
Create a passwords file that will be used across repositories.
16. sudo vi /usr/local/svn/passwd-coders
The structure of the file should be as follows:
<user_1> = <password_1>
<user_2> = <password_2>
<user_3> = <password_3>
Save the file and change its permissions, so it's only readable by the owner (root).
17. sudo chmod 600 /usr/local/svn/passwd-coders
Each Subversion repository has a configuration file that controls how it can be accessed by svnserve.
Edit this configuration file for the repository we created earlier.
18. vi /usr/local/svn/repos/<project_name>/conf/svnserve.conf
Paste the following after [general] (line 8):
anon-access = none
password-db = /usr/local/svn/passwd-coders
realm = coders
And save the file.
Stuff you might want to know (from the man pages):
The realm setting sets the authentication realm of the repository. If two repositories have the same password database, they should have the same realm, and vice versa; this association allows clients to use a single cached password for several repositories.
Let's launch svnserve as a foreground process (--foreground) so we can kill it after the test with Ctrl+C.
19. sudo svnserve -d --foreground -r /usr/local/svn/repos
You should be in your home directory (use pwd to check). If so, delete the working copy that was checked out previously or cd to another directory.
Now, checkout the pristine version using the svn protocol.
20. svn checkout svn://<server_ip>/<project_name> --username <user>
Replace <server_ip> with the IP address of your server or 127.0.0.1 if you are testing on the same machine.
You can go ahead and kill the svnserve process; we won't need it for svn+ssh.
We’re most of the way there, I promise. We just need to start our SSH server.
The only setup this requires, on a Mac, is to enable Remote Login from System Preferences > Sharing and add the coders group to the list of allowed users.
This will start sshd, the OpenSSH daemon, and set it to launch at startup.
Now you can checkout using svn+ssh and your login password.
21. svn checkout svn+ssh://<server_ip>/usr/local/svn/repos/<project_name> --username <user>