Skip to main content

Trip and Tick: svnserve on linux et al

Posted by evanx on July 9, 2007 at 11:27 AM PDT

I spotted this handy blog entry and so decided to give it a go, on a brand new $15 linux VDS. Here are my notes, which are consequently a rehash of that blog.

useradd svn

Let's decide that svnserve will run as user svn, and access repositories off its home directory i.e. /home/svn.

So we create the user svn with useradd, which creates its home directory /home/svn.

# useradd svn

svnadmin create

We create repository using svnadmin e.g. /home/svn/aptframework.

# useradd svn
# su - svn
$ svnadmin create aptframework

If this host is aptframework.net, then this repository's URL will be svn://aptframework.net/aptframework.

vi svnserve.conf

In the svnserve.conf for our repository, we uncomment as follows.

$ vi /home/svn/aptframework/conf/svnserve.conf
anon-access = read
auth-access = write
password-db = passwd

We might want to have anon-access set to none e.g. for private stuff.

In the specified passwd-db file, we add usernames and passwords for ourselves.

$ vi /home/svn/aptframework/conf/passwd
evanx = sshssh

If we want to use a common password file for multiple repositories e.g. /home/svn/passwd, then...

$ mv /home/svn/aptframework/conf/passwd /home/svn/passwd
$ vi /home/svn/aptframework/conf/svnserve.conf
password-db = /home/svn/passwd

where we specify the absolute path for password-db in svnserve.conf.

xinetd

We add an svn config for xinetd in subdirectory /etc/xinetd.d/ as follows

# vi /etc/xinetd.d/svn
service svn {
  port = 3690
  socket_type = stream
  protocol = tcp
  wait = no
  user = svn
  server = /usr/bin/svnserve
  server_args = -i -r /home/svn
}

where svnserve runs as user svn, and serves repositories off /home/svn.

We restart xinetd for the changes to take effect.

# /etc/init.d/xinetd restart

svn checkout

Now we can checkout a "working copy" of repository using svn://aptframework.net/aptframework URL.

Let's add and commit the standard (although optional) directories trunk, branches and tags.

# cd /tmp
# svn co svn://aptframework.net/aptframework aptframework --username evanx
# cd aptframework
# mkdir trunk
# mkdir branches
# mkdir tags
# svn add trunk
# svn add branches
# svn add tags
# svn commit -m "" --username evan

svn import

Finally we can import our source as follows, e.g. from /projects/aptframework/src.

# cd /projects/aptframework
# svn import src svn://aptframework.net/aptframework/trunk/src -m "" --username evanx

Or for the whole shebang, e.g. src, lib and what-have-you...

# cd /projects
# svn import aptframework svn://aptframework.net/aptframework/trunk -m "" --username evanx

We can do a test checkout to a tmp directory to make sure it looks ok, e.g. we checkout just the src directory as follows.

# svn co svn://aptframework.net/aptframework/trunk/src /tmp/aptframework-src --username evanx

And again...

When things don't go as planned, we just recreate the repository from scratch as follows.

# su - svn
$ rm -rf aptframework
$ svnadmin create aptframework
$ vi aptframework/conf/svnserve.conf
$ vi aptframework/conf/passwd

To re-import source, we'll need to search and destroy all those .svn hidden directories e.g. in our src, innit.

Conclusion

Setting up and serving a subversion repository is quite trivial. We create an svn user, configure svnserve in xinetd, and use svnadmin to create repositories.