Tag Archives: subversion

Setting up Subversion on Debian

So it’s time to setup Subversion; I’ve been using CVS almost forever for my larger projects, and relying on Time Machine for my smaller projects.  Which don’t get me wrong, works great, but CVS is getting a little dated, and there’s no Time Machine type app that I can find, for my new Windows laptop.

So, subversion.  Sure, I could use GIT, that’s what folks seem to be using these days, but it seems not-quite-suited to what I want it for – which is one person, developing using multiple machines.

So, I’ll be setting it up on my existing source-control VM.  I don’t think I need to bother with Webdav access – just svn+ssh will do nicely for remote access, and plain svn for servers within GS fetching their new releases.


My environment is almost 100% Debian, so first we install the subversion package

vorlon:~# apt-get install subversion<
Setting up libsvn1 (1.6.12dfsg-6) ... 
Setting up subversion (1.6.12dfsg-6) ... 

Then we want to create our new repository.  I’m going to have a repository per project, just to make it easy to hand a repository over to a client, should they ever move development inhouse, or the like.  Lets setup TremSearch

vorlon:~# mkdir /var/lib/subversion/tremsearch 
vorlon:~# svnadmin create /var/lib/subversion/tremsearch

Ok, our repository is created, but we need to add users!

cat >> /var/lib/subversion/tremsearch/conf/passwd << __END__ 
damien = <redacted> 
webserver = <redacted> 

And we need to give them access – edit conf/svnserve.conf:

damien = write 
webserver = read 
anon-access = none 
password-db = passwd 

‘Note the anon-access = none’ – The SVN documentation seems to say that ’read’ is the default for anonymous users!  That seems a little daft to me, but I’ll set it to none, just incase they’re for real!

Oh, Subversion for debian does not have a start script! So we’ll add one..

cat > /etc/init.d/subversion << __END__
# Provides:          svnserve
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     
# Default-Stop:      
# X-Interactive:     true
# Short-Description: Start/stop svnserve

svnserve -d -r /var/lib/subversion/
chmod u+x /etc/init.d/subversion
ln -s /etc/init.d/subversion /etc/rc2.d/S99subversion

Note that we’re locking base SVN url’s down to /var/lib/subversion.  We’ll see how this works below.

Start up the server (/etc/init.d/subversion) and we’re done!

Importing your code

Importing your code is fairly easy – change to the directory your code resides in, and import it.. And then, I move the original directory out of the way, and check it out:

damien@:/export/home/projects/tremsearch/www$ svn import -m "initial import" ./ svn://svnserver/tremsearch/www
Committed revision 1.
damien@:/export/home/projects/tremsearch/www$ cd ..
damien@:/export/home/projects/tremsearch$ mv www old-www
damien@:/export/home/projects/tremsearch$ svn checkout svn://svn.rendrag.net/tremsearch/www www
Checked out revision 1.

And done!. Now I can check it out on my laptops, and work with it! And the added bonus here, is that I don’t have to worry about SCP’ing changes up to the webserver anymore, and keeping track of changed files – I just jump into the www directory on the webserver, and ‘svn update’ 🙂