Skip to main content

HOWTO: Setting up SVN and DAV in Fedora6

This Howto is based on a similar howto for FC4 by Ferdy Christant HERE

I've been trying to set-up a SVN repository for my university's usergroup to get some kickstart in Opensource development among my batch and friends, and UTP as a whole. With some googling, I managed to find some good guides in helping me to set-up up. (to newbies, just for your information, I'm using root user throughout this guide)

Step 1 : Getting the packages

To set up the repo, you'll need subversion, apache and mod_dav_svn.
yum install subversion mod_dav_svn httpd

Step 2 : Preparing the SVN repository root

After getting the required packages, set up a place for storing the SVN repos in a suitable place. In this howto, lets assume we store it in /var/svn/.
mkdir /var/svn/ 
mkdir /var/svn/permissions/ #where the permission settings will be stored
mkdir /var/svn/repos/ #where the repos will be stored
mkdir /var/svn/users/ #where the user htpasswd will be stored

We'll need to give apache access to the repository root, because it will be the application that read/write on it. Giving ownership is safer and easy to manage than chmod'ing the directories to 755.
chown -R apache:apache /var/svn/

Step 3 : Creating a test SVN repository

Lets create a repository in the directory for testing purposes
cd /var/svn/repos/
svnadmin create testrepo

chown it to apache
chown -R apache:apache testrepo

Step 4 : Setting up Apache and mod_dav_svn

The mod_dav_svn RPM already provided a prebuild configuration for this purpose, you can found it at /etc/httpd/conf.d/subversion.conf. For the lazy people, you can just uncomment the all the entries in the config, change the path settings and start/restart/reload httpd. But lets uncomment a few lines first to test whether the repository can work or not. Don't forget to change the SVNParentPath to your SVN repository parent. If you want, you can also change the Location setting (in this howto, I use /svn).

<Location /svn> 
DAV svn
SVNParentPath /var/svn/repos
# # Limit write permission to list of valid users.
# # Require SSL connection for password protection.
# # SSLRequireSSL
# AuthType Basic
# AuthName "Authorization Realm"
# AuthUserFile /path/to/passwdfile
# Require valid-user
# </LimitExcept>

Start/Reload apache for the settings to take effect.
service http reload

Then, try entering the repository by pointing your browser to the /svn/testrepo folder of the webserver (lets assume we are doing this on localhost). Open http://localhost/svn/testrepo/ . You should see a page with "Revision 0:/" as the header. If you can see the page it, if not, check if you've done something wrong (if you got error 403, check the folder permissions)

Step 6 : Securing the repository

To secure the repo and DAV, we rely on htpasswd protection, first, create a passwordfile to store the username and password
htpasswd -cb /path/to/passwdfile username password

htpasswd -cb /var/svn/users/passwords myuser mypasswd123

Then, uncomment these lines
<Location /svn> 
DAV svn
SVNParentPath /var/svn/repos
# # Limit write permission to list of valid users.
# # Require SSL connection for password protection.
# SSLRequireSSL
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /var/svn/users/passwords
Require valid-user

and reload httpd
service httpd reload

By now, when you want to open the repo URL, the browser will ask for a username and a password.

Allowing Read access to all visitors/users

You might want to allow all users read operation but limit write to known members, you can do this by rearranging entries in the config into this and reload httpd

<Location /svn>
DAV svn
SVNParentPath /svn/repos
SVNListParentPath on
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /svn/users/passwords
# SSLRequireSSL
# Limit write permission to list of valid users.
# # Require SSL connection for password protection.
# SSLRequireSSL
# AuthzSVNAccessFile /svn/permissions/svnauthz.conf
Require valid-user


If you want more advanced access control using per-directory permission, you can read the blog post at Ferdy Christant's blog or this Gentoo wiki entry. I'm only covering the base set-up of a SVN server on FC6. If you want a Web based SVN interface, consider looking into WebSVN.

Popular posts from this blog

Adding simple popup to Plone frontpage

Here is a little guide for those who want to add a simple popup to the Plone frontpage for some purpose (eg: announcements, advertisements, etc).

Create a basic html file containing the content you want to appear in the popup. Upload it into $PLONE_SITE/portal_skins/custom (as Page Template) and for the sake of this example, name it popup.html

Afterward, create a Javascript file with your Pop-Up loader script. For example , this script:

function popup(mylink, windowname)
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink.href;, windowname, 'width=220,height=400,scrollbars=no');
return false;

popup('popup.html', 'My Popup');

Also upload this file into $PLONE_SITE/portal_skins/custom (as Page Template too). For this example, name it as popup.js

Afterward, in $PLONE_SITE/portal_javascripts , add popup.js as a new script into portal_javascripts…

Tee'ing Python subprocess.Popen output

A little hack for python coders out there who wanted to have a functionality similar to the unix's tee command for redirecting output to multiple places.

import sys
from subprocess import Popen,PIPE
p = Popen(['put','command','and','arguments','here'],stdout=PIPE)

while True:
o = p.stdout.readline()
if o == '' and p.poll() != None: break
# the 'o' variable stores a line from the command's stdout
# do anything u wish with the 'o' variable here
# this loop will break once theres a blank output
# from stdout and the subprocess have ended

HOWTO: Mirroring Yum repositories using Yum-Utils

As promised before in one of my previous post, a Howto on how to mirror and manage yum repositories using some of the utilities in yum-utils.

The first step is, well, of course, is to get yum-utils from fedora repository
yum install yum-utils

Reposync is a utility for mirroring and synchronizing local copy of a yum/rpmmetadata repository.

This utility is very useful if you wanted to make a yum repository mirror. Before this, I used "wget -R -np -N" but this method is a little bit tedious and it doesnt work with repos that didn't use directory listing. Plus, it also download together additional site stuff that I don't need/want and it doesn't verify checksum of the downloaded packages.

Mirroring a repo using this utility is easy, just execute this command
reposync -r <repoid> -a <arch> -n
and the repo will be mirrored in a folder with the same name of the repoid in the directory you executed the command. Eg: you executed the command in /mnt/storage/mi…