auf.kante
Gunnar macht sich selbststaendig und fliegt auf
die Schnauze
wird erfolgreich. Wer mag darf zuschauen.
Gunnar is starting his business. He will certainly
fail succeed. You may watch.
auf.kante
Website sections
Home
Subversion
Last changed: 2006-08-10 [14:17]
Content:

Notes on using subversion on Gentoo
 
Back to Personal Wiki
Table of contents
Introduction
Configuring subversion
Per-repository access
Replicating subversion repositories
Tips
Links

Introduction

This represents my subversion setup on Gentoo.

Configuring subversion

Fix /etc/apache2/conf/modules.d/47_mod_dav_svn.conf to hold

SVNParentPath /var/svn/repos

instead of

SVNPath /var/svn/repository

This allows to have several repositories in that path.

To set up very basic authentication you can use the /var/svn/conf/svnusers file:

htpasswd2 -c /var/svn/conf/svnusers wrobel

Finally add some apache start options to /etc/conf.d/apache2:

APACHE2_OPTS="-D SSL -D DAV -D SVN"

Per-repository access

Add this section to the repository Location configuration:

	<IfDefine SVN_AUTHZ>
		<IfModule !mod_authz_svn.c>
			LoadModule authz_svn_module	modules/mod_authz_svn.so
		</IfModule>
		AuthzSVNAccessFile /var/svn/conf/svnaccess
	</IfDefine>

The SVN_AUTHZ flag needs to be added to the apache startup options:

APACHE2_OPTS="-D SSL -D DAV -D SVN -D SVN_AUTHZ"

And the /var/svn/conf/svnaccess file needs to be created with sensible settings:

[/]
wrobel = rw

[webapp-config:/]
wrobel = rw
rl03 = rw
stuart = rw

This allows access for me on all repositories and read/write access to rl03 and stuart on the webapp-config repository.

Replicating subversion repositories

SVN::Mirror is a nice package to replicate repositories.

echo "dev-perl/File-chdir ~x86" >> /etc/portage/package.keywords
echo "dev-perl/SVN-Simple ~x86" >> /etc/portage/package.keywords
echo "dev-perl/SVN-Mirror ~x86" >> /etc/portage/package.keywords
emerge SVN-Mirror

This is a short script (/usr/bin/svm-start) that can be used to initialize one or several directories on the receiving end:

#!/bin/bash

WEBLOC="https://www.mysubversionserver.com/svn/"

for REPOSITORY in $@
  do
  # No trailing slash here!
  export SVMREPOS=/var/svn/repos/${REPOSITORY}
  svnadmin create ${REPOSITORY}
  # No trailing slash here!
  svm init / ${WEBLOC}/${REPOSITORY}
done

The variable WEBLOC needs to be modified to hold the value of the primary subversion server.

A second script (/usr/bin/svm-replicate) does the actual mirroring:

#!/bin/bash

for REPOSITORY in $@
  do
  echo "Syncing ${REPOSITORY} ..."
  export SVMREPOS=/var/svn/repos/${REPOSITORY}
  svm-expanded unlock / force
  svm-expanded sync /
  echo "Sync finished ..."
done

I had trouble with repositories that got locked by svm so I added a new function to the script:

sub unlock {
    my $path = shift;
    my $what = shift;
    my $pool = SVN::Pool->new_default;
    my $m = SVN::Mirror->new(target_path => $path, target => $repospath,
			     pool => $pool, auth => $auth,
			     get_source => 1);

    $m->unlock($what);

}

A repository can then be unlocked with:

swm unlock / force

This example demonstrates how to start the mirroring process. First the initial repositories need to be created. Their names need to match the repository names on the primary server.

cd /var/svn/repositories
svm-start repo1 repo2 repo3
svm-replicate `ls`

If the primary subversion repository needs authentication this example might fail in case svn does not know the correct user and password yet. In order to store these it is easiest to check one of the repositories out manually.

svn co https://www.mysubversionserver.com/svn/repo1
rm -rf repo1

After that svm-start should run fine.

If the primary server received new commits the can now be replicated by further calls to svm-replicate.

svm-replicate `ls /var/svn/repositories`

Tips

Setting svn:ignore recursively

For a python project you can use the following command to recusively ignore the .pyc files:

<pre class="example"> echo &quot;.pyc" > .svn.ignore.global find . -type d | grep -v '.svn' | xargs svn propset svn:ignore -F .svn.ignore.global svn add .svn.ignore.global svn commit -m "Propset fix"

Links

Same section in del.icio.us
  • SVN-replicate
  • GEntoo Wiki - Howto configure apache with subversion
  • Subversion Project Page
  • FlexySVN - a XUL SVN browser
Back to Personal Wiki
Creative Commons-Lizenzvertrag
The content of this site is licensed under a Creative Commons 2.5 License [attribution, share-alike]