Convergence 09 : Setup youe own SVN Repository

Uncategorized Voice your views  

Even if you work on your own small project, it is very important to keep track of your changes, here comes subversion, i use subversion over others because it is way simple to configure and use, and it has a lot of web browsing services that allow you to browse your repository using a web browser.

Step1: setup your svn repository

first of all you need to install subversion, use your package manager to do this:


Ubuntu: sudo apt-get install subversion
Slackware: slackpkg install subversion

Then create a folder where you want your svn repository to be, make sure you have write permission to the folder, /svn will be used in this example.


sudo mkdir /svn
sudo chown your_user_name:your_user_name /svn (example sudo chown foo:foo /svn)
svnadmin create /svn/projects

Of course you can create the svn folder in your home directory, then you don’t have to change its ownership.

Step2: Starting a new project


svn co --non-recursive file:///svn/projects projects
cd projects
svn mkdir new-project
svn commit -m "Initial import"

Once you have done the above step, you can start working on your project, here is some svn command that you will need to use.


/* to create a file */
touch main.c
svn add main.c

/* to see the diff log */
svn diff

/* information about the repository */
svn info

/* status of the current working directory */
svn stat


Step3: Configuring and Setting up a subversion server

To Configure your subversion server your should look in the conf directory created under your svn repository, in this example it is /svn/projects/conf. We need to edit two files, the svnserve.conf for the server configuration and the passwd for adding users with their passwords.

Uncomment and modify the following lines of svnserve.conf as follows:


anon-access = none
auth-access = write
password-db = passwd

Add users to passwd file, example:


[users]
foo = password_here

Start your subversion server with the following command:


svnserve -d

To autostart the svn server you could put the above command in your rc.local such way the server is automatically started after reboot.

Now you can checkout your subversion repository like:


svn co svn://localhost/svn/projects projects

Step4: Setting up a web-browsing view for the repository

There is a lot of subversion repository web browsing clients, what we are going to use here is SVN::Web perl, you need to install the SVN-Web, depending on your distro the name might be different, in ubuntu the package name is libsvn-web-perl .

steps here are very simple, we need to created a folder where we put the svn web server files, then we start the server


mkdir web-svn ( make the this directory where you like)
cd web-svn
svnweb-install


The above command svnweb-install will generate the necessary files for our repository web view, you need to edit the config.yaml configuration file to point to your svn directory example will be as follow:


repos:
RepoName: 'file:///svn/projects'

Instead of RepoName you can put whatever you like, it is just the repository name

Start the svn perl web server:


svnweb-server --root /svn/pojects

To View your the contents of your subversion repository use a web-browser with the following address, localhost:8080, also to start the perl web serving you could add the above command in your rc.local

What about if we want to get better name for our svn web view, something like domain-name.org/svn here are some hints for setting this up.

1)-Go to dyndns.com and register a domain name associated with your ip address.

2)-Enable the dyndns service in your router.

3)-Open and forward the ports 80 and 8080 to your subversion computer.

4)-Add the registered domain name to the subversion computer.

5)-Configure the apache2 web server and enable cgi scripts.

Some details concerning step4 and 5 on Ubuntu 8.10:

Edit /etc/hosts and add the ip address of the machine as well as your domain name.

hosts


xxx.xxx.x.xx your_domain_name.

example:
192.168.1.1 example-domain.org

Installing apache2


sudo apt-get install apache2 libapache2-mod-perl2 libapache2-request-perl
cd /etc/apache2/mods-enabled

/* Make sure that the following links exist, if not create them */
sudo ln -sv /etc/apache2/mods-available/cgi.load cgi.load
sudo ln -sv /etc/apache2/mods-available/apreq.load apreq.load
sudo ln -sv /etc/apache2/mods-available/perl.load perl.load

Now we need to edit apache2.conf which is in /etc/apache2 configuration file to enable the SVN-Web view.

Add the following lines in apache2.conf, change /svn/web to where you have created your svn-web directory.



AllowOverride None
Options None
SetHandler perl-script
PerlHandler SVN::Web



SetHandler default-hanlder


Alias /svnweb /svn/web

Restart apache2


sudo /etc/init.d/apache2 restart

Now you should be able to connect to your svn web from any machine using the address your_domain_name/svnweb, as an example it could be example-domain.org/svnweb, don’t hesitate to contact me if you have any question.

Step5:(For Ubuntu 8.10) Fix Ubuntu 8.10 SVN::Web perl installation:

In principle the above steps should be enough to set up a web view for your svn repository, but that’s in principle, in practice you may run in troubles, two main problems appear to complicate the setup of libsvn-web-perl under Ubuntu 8.10.

1) Missing dependencies for libsvn-web-perl.

2) svnweb-server needs a patch to avoid an assertion failure causing a svnweb-server crash.

For the second problem, this is affecting any Linux system using subversion 1.5.0 with a non patched SVN::Web.

We will start by installing the required packages, we will use dh-make-perl to build the package that is missing from the Ubuntu repositories.


sudo apt-get install libsvn-web-perl libtimedate-perl libnumber-format-perl dh-make-perl

mkdir /tmp/deb/
cd /tmp/deb/
/* Answer yes for all the questions out from this command */
dh-make-perl --build --cpan Template::Plugin::Number::Format
dpkg -i libtemplate-plugin-number-format-perl_1.02-1_all.deb
rm -rf /tmp/deb

Fix the libsvn-web-perl: you need to download SVN-Web version 0.53 as well as the patch, i have added the patch here, but if you don’t trust me, go to the SVN-Web bugzilla and get the patch from there.

svn-web-0.53-svn15.patch svn-web-0.53-svn15.patch
Size : 4 Kb
Type : patch

Follow these instructions:



tar -xvf SVN-Web-0.53.tar.gz
cd SVN-Web-0.53
patch -Np1 -i ../svn-web-0.53-svn15.patch
perl Makefile.PL
make
/* don't install anything we just need to copy the patched files */

cd lib/SVN/Web/
sudo cp Diff.pm Log.pm Revision.pm View.pm action.pm /usr/share/perl5/SVN/Web/.

now rerun svnweb-server and you should be able to surf your repository, still having troubles mail me.

Hopefully you found this small tutorial useful, as usual permission is garanteed to modify or copy the content of this document under the GNU General Public License GPL.

Add a Comment

%d bloggers like this: