New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

HOWTO: Subversion

A collection of tips on howto tweak your Bubba.
DarrenBeck
Posts: 5
Joined: 03 May 2007, 04:02

HOWTO: Subversion

Post by DarrenBeck »

Hi all,

This is a quick guide on how to get a recent version (1.4.2) of Subversion working on a Bubba server. I've tried to include as much info as possible but if something is not clear just let me know.

For this first part we need to run as root, so ssh into Bubba using your user account and then su to root. The default root password is excito, make sure you change this if you haven't already.

Next we need to edit the /etc/apt/sources.list in order to enable the Debian repositories, the initial version of the file looks like this:

Code: Select all

#deb http://ftp.se.debian.org/debian/ sarge main
#deb http://security.debian.org/ sarge/updates main
#deb http://ftp.se.debian.org/debian/ sarge non-free

deb http://update.excito.net/ bubba main
To activate the Debian repositories we just need to uncomment the first three lines.

Unfortunately the standard repositories only contain version 1.1.4, this had some major issues for me and was incredibly slow. In order to get a more recent version we need add the Debian Sarge backports repository to our list, so we now have:

Code: Select all

deb http://ftp.uk.debian.org/debian/ sarge main
deb http://security.debian.org/ sarge/updates main
deb http://ftp.uk.debian.org/debian/ sarge non-free

deb http://www.uk.backports.org/ sarge-backports main contrib non-free

deb http://update.excito.net/ bubba main
You'll also notice I updated my repositories to local mirrors (I'm in the UK). For a full list of the backport mirrors go here: http://www.backports.org/debian/README.mirrors.html

Now that we have the required repositories we need to refresh the package cache:

Code: Select all

apt-get update
Now we can install Subversion:

Code: Select all

apt-get -t sarge-backports install subversion
The -t sarge-backports argument is required to enable the backport package (they're disabled by default).

Now that we have Subversion installed we need to get a server running. This guide only covers the svnserve server, not the WebDav Apache integration. For details on the two configurations and on how to set up the WebDav integration check out the Subversion book at: http://svnbook.red-bean.com/

Before we start the server we need something to serve. First we need to create a subversion user that will own the repositories. The reason for doing this is it prevents other users from messing with the repositories and also prevents them from looking at the passwd file (which stores the passwords in clear text). As root, run:

Code: Select all

groupadd svn
useradd -m -d /home/svn -s /bin/bash -g svn svn
passwd svn
Now su to svn or open another ssh session as svn. To keep things tidy we will create a root for all of our repositories, in /home/svn run:

Code: Select all

mkdir repositories <-- or whatever you want to call it.
We are now ready to create out test repository, still as svn, run:

Code: Select all

svnadmin create /home/svn/repositories/test
Obviously if you changed the repository root name then do the same in the command above. The final step in this process is to configure the repository. This is just a simple test repository so there isn't much to do, cd to the repository configuration folder, in this case:

Code: Select all

cd /home/svn/repositories/test/conf
There are two files we are interested in, svnserve.conf which contains the main server configuration, and passwd that contains the user accounts.

Edit the passwd file and remove the the two commented lines under the [users] section, add a new user and password e.g.

Code: Select all

[users]
testuser = topsecret
Now edit the svnserve.conf file, this already contains some example settings but they are commented out. The following lines should be uncommented:

Code: Select all

anon-access = read
auth-access = write
password-db = passwd
I personally always disable anonymous read access (change the read to none for the first line).

Right, now were ready to start the server. There are two mechanisms for running svnserve, as a daemon or through inetd. I prefer the inetd approach as it means the server is not running constantly and it also means I don't have to mess about with init scripts :)

Just to be awkward I use xinetd (an inetd replacement), this is available through the standard debian repositories, to install it run the following as root:

Code: Select all

apt-get install xinetd
If you don't want to use xinetd, the Subversion book covers the configuration for inetd (it doesn't cover xinetd).

Still as root, create a new file in the /etc/xinetd.d/ folder called svn, e.g:

Code: Select all

vi /etc/xinetd.d/svn
The contents should be:

Code: Select all

# Subversion server
# default: on

service svn
{
        socket_type = stream
        protocol = tcp
        user = svn
        wait = no
        disable = no
        server = /usr/bin/svnserve
        server_args = -i -r /home/svn/repositories
        port = 3690
}
The important parts in this file are the user we want to run the process as (svn in our case), the port to run on (3690 is the default for Subversion) and the server arguments (-i to run as an inetd process and -r to specify the repository root).

Restart the xinetd process:

Code: Select all

/etc/init.d/xinetd restart
Ok, we should now be ready to import something into the repository. To keep things simple all we are going to do is create a standard repository structure and a single file. As any user other than svn (just to be on the safe side) run the following in the users home directory (although you can do it anywhere you have access really):

Code: Select all

mkdir -p test/{trunk,branches,tags}
touch test/trunk/test.txt
Now to import it just run the following:

Code: Select all

svn import test svn://localhost/test --username testuser --password topsecret -m "Initial Import"
If everythng is set up correctly you should get something like:

Code: Select all

Adding         test/branches
Adding         test/tags
Adding         test/trunk
Adding         test/trunk/test/txt

Committed revision 1.
Now all that is left is to test checkout, so as the same user as before run:

Code: Select all

svn checkout svn://localhost/test/trunk test2
Because we are the same user we don't need to supply the username and password again as Subversion caches it. You should get something like:

Code: Select all

A      test2/test.txt
Checked out revision 1.
Obviously if you want to access the repository from another machine just substitute bubba (or whatever you've called it) for localhost in the URLs above.

Phew! Hopefully you found that useful, if you have any comments/corrections just let me know.

Cheers,

Darren.
yooakim
Posts: 43
Joined: 08 May 2007, 08:58

Example init.d script

Post by yooakim »

First off, thanks for a great HOWTO!

As I don't use the xinetd I needed an init script for the Subversion deamon, this is how I did it:

I created a file in the init.d directory that launches subversion (you can use any name you like but I think the name "subversion" fits well) :

Code: Select all

 sudo touch /etc/init.d/subversion

next make sure the file is executable

Code: Select all

 sudo chmod +x /etc/init.d/subversion

Now we have an emtpy file that can be executed, but we need to edit the file so that it can start and stop the Subversion daemon.

Code: Select all

 sudo jed /etc/init.d/subversion

NB: This command depends on which editor you use, I use jed

The script I use contaisn the following code:

Code: Select all

#!/bin/sh
# Start/stop the subversion daemon.

test -f /usr/bin/svnserve || exit 0

case "$1" in
start)	echo -n "Starting Subversion server"
        start-stop-daemon --start --chuid svn:svn --exec /usr/bin/svnserve --quiet -- -d -r /home/svn/repositories
        echo "." 
	;;
stop)	echo -n "Stopping Subversion server"
        start-stop-daemon --stop  --exec /usr/bin/svnserve --quiet
        echo "."
        ;;
restart) echo -n "Restarting Subversion"
        start-stop-daemon --stop  --retry 5 --exec /usr/bin/svnserve --quiet
        start-stop-daemon --start --chuid svn:svn --exec /usr/bin/svnserve --quiet -- -d -r /home/svn/repositories
        echo "."
        ;;
*)	echo "Usage: /etc/init.d/subversion start|stop|restart"
        exit 1 
        ;;
esac
exit 0

This will start the subversion server and make the repositories in the directory /home/svn/repositories/ available via the Subversion prtocol (svn) With the script complete you can start Subversion by issuing:

Code: Select all

/etc/init.d/subversion start 

or if you want to stop Subversion, issue:

Code: Select all

/etc/init.d/subversion stop

Once the script works the way you want it to you should create symbolik links to it so that it gets called when the system goes down or comes up.
The easiest way to do this is by using Debians command update-rc.d, this is how I did it:

Code: Select all

sudo update-rc.d /etc/init.d/subversion defaults

If you want to remove it so that it is not autostarted, issue:

Code: Select all

sudo update-rc.d /etc/init.d/subversion remove

And that's it! Now when you re-boot your BUBBA the Subversion deamon will be started without your intervention.

Cheers,
Joakim
squadra
Posts: 96
Joined: 19 Sep 2008, 09:02

Post by squadra »

Perfect on bubba2 with autostart feature. How do you place a symlink for a specific repository to "/home/www/svnrep?" so you will be able to show this repository online not with svn client but normal browser? Is that possible?

This is why. We make xhtml pages and would be nice to use the repository only and also able to view results online directly using all browsers at all clients to test further :-)
DarrenBeck
Posts: 5
Joined: 03 May 2007, 04:02

Post by DarrenBeck »

To use a browser as a client you need to integrate with Apache using WebDav. Unfortunately I don't have time to write something up on that right now but for reference here is a guide that covers the steps required (it repeats some of the stuff above so you can just skip those bits).

http://www.howtoforge.com/apache_subversion_repository
squadra
Posts: 96
Joined: 19 Sep 2008, 09:02

Post by squadra »

thanks to carl and DarrenBeck setup below
Last edited by squadra on 02 Nov 2008, 10:27, edited 3 times in total.
carl
Posts: 474
Joined: 07 May 2008, 04:41

Post by carl »

squadra wrote:Thanks for helping me, but i guess the svn dav is not available as a module.

Inside:
bubba:/etc/apache2/mods-enabled#
nano dav.load
LoadModule dav_module /usr/lib/apache2/modules/mod_dav.so

saved it. Then added in httpd.conf

bubba:/etc/apache2# cat httpd.conf
<Location /subversion>
DAV svn
SVNPath /home/svn/repositories/test/

AuthType Basic
AuthName "svn gard"
AuthUserFile /home/svn/repositories/test/conf/svnserve.conf
Require valid-user

</Location>

But the message:
Unknown DAV provider: svn apeared, on the internet it says also load module LoadModule mod_dav_svn but this is not in the modules list. And apt-get install mod_dav_svn gave me couldn't find package.

I will read further (new for me but nice) if it worked i will rewrite this post as an extra how to.
Thanks!
you should probably install the libapache2-svn package.

/Carl
/Carl Fürstenberg, Excito Software Developer
http://www.excito.com
support@excito.com
squadra
Posts: 96
Joined: 19 Sep 2008, 09:02

Post by squadra »

You people are quick!

Ok, here it is webdav for accessing your test repository on port 80 (handy when testing xhtml pages in your repository).

first:

Code: Select all

apt-get install the libapache2-svn

Code: Select all

bubba:/etc/apache2# cat httpd.conf 
<Location /subversion> 
DAV svn 
SVNPath /home/svn/repositories/test/ 

AuthType Basic 
AuthName "whatever" 
AuthUserFile /home/svn/repositories/test/conf/passwd 
Require valid-user 

</Location>
For firefox showing my html files as plain text i had to add something in my xhtml files itself (svn propset svn:mime-type text/html *.html ).

Very cool, only basic auth not fully working i guess passwords are not encrypted but plain in this passwd file, so i used another protect.

Thanks again all.
petter
Posts: 9
Joined: 20 Oct 2008, 05:13

New to Linux

Post by petter »

Hello!

I´m new to Linux and I just bought a Bubba Two server.

I want to install the SVN server part on my Bubba in order to check in my source code as I develop software.

From reading the guides above I can´t figure out if guide 1 by DarrenBeck demands me to manually re-start SVN after rebooting Bubba. I would really like SVN to start up automatically when I restart the server.

Guide 2 by yooakim mentions a software named "xinetd" is this software something that most Linux systems use? Should I install it or what do you Linux-guys recommend? :)
squadra
Posts: 96
Joined: 19 Sep 2008, 09:02

Post by squadra »

In the first post skip xinetd part and make a file you start with init.d exactly as mentioned below the first post. Then your svn server is always up (must be the case if you want others to submit) when bubba is.
Then proceed the other steps in post one (make trunk etc et).
petter
Posts: 9
Joined: 20 Oct 2008, 05:13

Make subversion accessible over the internet

Post by petter »

Ok, I got the subverison running in my own network now.

Next step: make my repository accessible over the internet.
I wanna connect to it from my PC using TortoiseSVN from wherever.
Has anyone solved this?

I've tried to open a port using the Bubba|Two web interface, but when I try to access the repository from outside I get a "No connection could be made because the target machine actively refused it." message.

It's as if the port forwarding feature does not work.

Is it possible to run Subversion using the svn-protocol over the internet or to I need to involve the Apache2 web server as well?
squadra
Posts: 96
Joined: 19 Sep 2008, 09:02

Post by squadra »

If your svn is up you only need to open port 3690. I have my router before bubba, so i only opened port 3690 on my router to my bubba and svn is working.
DarrenBeck
Posts: 5
Joined: 03 May 2007, 04:02

xinetd

Post by DarrenBeck »

petter: I think you misunderstood my original post, you don't need to restart svnserve when using xinetd. xinetd is just a newer version of inetd, they are designed to start services on demand, so you don't need it running all the time.

Hopefully that makes sense :)
Filip
Posts: 30
Joined: 06 Feb 2007, 12:27
Location: Lund, Sweden

Post by Filip »

Not working. Got the following error:

Code: Select all

bubba:/home/filip# apt-get -t sarge-backports install subversion
Reading package lists... Done
Building dependency tree... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.

Since you only requested a single operation it is extremely likely that
the package is simply not installable and a bug report against
that package should be filed.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
  subversion: Depends: libsvn0 (= 1.4.2dfsg1-2~bpo.1) but it is not going to be installed
              Depends: libapr0 (>= 2.0.54) but it is not installable
              Depends: libsvn0 (>= 1.4) but it is not going to be installed
E: Broken packages
Any ideas what could be wrong?
Filip
Posts: 30
Joined: 06 Feb 2007, 12:27
Location: Lund, Sweden

Post by Filip »

Filip wrote:Not working. Got the following error:

Code: Select all

bubba:/home/filip# apt-get -t sarge-backports install subversion
Reading package lists... Done
Building dependency tree... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.

Since you only requested a single operation it is extremely likely that
the package is simply not installable and a bug report against
that package should be filed.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
  subversion: Depends: libsvn0 (= 1.4.2dfsg1-2~bpo.1) but it is not going to be installed
              Depends: libapr0 (>= 2.0.54) but it is not installable
              Depends: libsvn0 (>= 1.4) but it is not going to be installed
E: Broken packages
Any ideas what could be wrong?
Now I got it working!
I used the other Debian Repository that already were in the sources.list without adding the http://www.uk.backports.org/
rdaneel
Posts: 34
Joined: 28 Jan 2009, 16:33

Re: HOWTO: Subversion

Post by rdaneel »

Hi,

this 'howto' seems to deal with debian 'sarge'.
Does this howto also apply to 'etch' ? I'm a bit afraid to wreck the system by following this tutorial knowing it is for a different core.
please advise.

rdg
Post Reply