Installing SVN

Requirements for creating an SVN (Linux) repository

I assume you have an Apache server installed, since use this Web server to connect via http to our repositories.

Steps:

1. Install subversion and the svn module for apache.

$ sudo apt-get install subversion apache2 libapache2-mod-svn(old libapache2-svn) apache2-utils

$ sudo apt-get install subversion-tools

2. Groups and permissions: This is not strictly necessary, but 100% recommended for safety. Create a group, to which we will add our user and the Apache user (www-data):

$ sudo addgroup subversion

$ sudo usermod -a -G subversion user_name

$ sudo usermod -a -G subversion www-data

The next thing to create is the access file repository. This will create all users that will access the repository:

$ sudo htpasswd -c /etc/apache2/users_svn.passwd user_name

$ sudo htpasswd /etc/apache2/users_svn.passwd other_user_name

Note that from the second user, not the -c parameter is passed, since we already dav_svn.passwd is created. For each user we asked for a password, which does not have to match the password for the corresponding user in the system (if any).

3. Create the parent directory for our repositories:

$ sudo mkdir /var/SVN

$ sudo chown -R www-data:subversion /var/SVN/

4. Modify the configuration file: As root, you must edit the file to specify /etc/apache2/mods-available/dav_svn.conf our configuration data. The file is self-explanatory, but let the lines that interest me:

<VirtualHost *:80>

  ServerName svn.example.net

  ServerAdmin admin@example.com

  <Location /svn>

    DAV svn

    SVNParentPath "/var/SVN"

    SVNListParentPath On

    AuthType Basic

    AuthName "SVNSubversion"

    AuthUserFile /etc/apache2/users_svn.passwd

    Require valid-user

  </Location>

  ErrorLog ${APACHE_LOG_DIR}/subversion_error.log

  LogLevel warn

  CustomLog ${APACHE_LOG_DIR}/subversion_access.log combined

</VirtualHost>

If we remove the read mode to anyone, because our project is confidential or not want it to be seen from outside, just replace the section:

<LimitExcept GET PROPFIND OPTIONS REPORT>

    Require valid-user

</LimitExcept>

by:

Require valid-user

5. Restart the Apache server.

$ sudo /etc/init.d/apache2 stop

$ sudo /etc/init.d/apache2 start

6. Add projects:

$ sudo mkdir /var/SVN/myproject

$ sudo svnadmin create /var/SVN/myproject

$ sudo svn mkdir -m "created struct folder" file:///var/SVN/myproject/trunk file:///var/SVN/myproject/tags file:///var/SVN/myproject/branches

$ sudo chown -R www-data:subversion /var/SVN/myproject

$ sudo chmod -R g+rws /var/SVN/myproject -> To check if it's necessary

7. Start working: We enter the directory where we present our project files (can be on the same machine or another) and do a checkout:

$ svn co http://server.name/myproject/trunk

or if we're on the same machine, you can use:

$ svn co http://localhost/myproject/trunk

We add what we have to add (for example with a svn add *) and do the initial import:

$ sudo svn import -m "init" . file:///var/SVN/myproject/trunk

To make the initial import, I used "file: ///", this was because I was working on the server directly. If instead he had been in another machine on the network, I should use http and server IP address.

And that's it. Just as we created the "myproject" project we can create all you want. The rest is just work and use the svn commands you use regularly.

INSTALLING SVN ON QNAP


We are going to discribe the way of installing SVN on QNAP:

1. Install Entware-std QPKG from Qnap Store or this link: https://www.qnapclub.eu/en/qpkg/556

2. After installing this package reboot qnap, opkg will ba able in the next start.

3. Install the folowing packets with opkg:

# opkg install gzip bzip2 nano rsync tar

# opkg install subversion-server

4.  Execute svn server:

# svnserve -d --listen-port=3690 -r /share/HDA_DATA/SVN

5. Create a repository:

# svnadmin create "/share/HDA_DATA/SVN/repo_name"

6. Modify files passwd and svnserver.conf in /share/HDA_DATA/SVN/repo_name/conf folder:

passwd:

### This file is an example password file for svnserve.

### Its format is similar to that of svnserve.conf. As shown in the

### example below it contains one section labelled [users].

### The name and password for each user follow, one account per line.


[users]

user1= password1

user2= password2

svnserver.cong:

...

[general]

...

anon-access = read

auth-access = write

...

password-db = passwd

...

7. Add the following init script to the folder /share/HDA_DATA/.qpkg/Entware/etc/init.d/S50svnserve:

#!/bin/sh

#

# Start svnserve

#


SVNSERVE_BIN="/share/HDA_DATA/.qpkg/Entware/bin/svnserve"

SVN_PATH="/share/HDA_DATA/SVN"


start() {

    printf "Starting svnserve: "

    $SVNSERVE_BIN -d --listen-port=3690 -r $SVN_PATH

    if [ "$?" = "0" ]; then

        printf "OK\n"

    else

        printf "FAIL\n"

    fi

}


stop() {

    printf "Stopping svnserve: "

    killall svnserve

    if [ "$?" = "0" ]; then

        printf "OK\n"

    else

        printf "FAIL\n"

    fi

}


restart() {

    printf "Restarting svnserve...\n"

    stop

    start

}


case "$1" in

    start)

        start

        ;;

     stop)

        stop

        ;;

     restart|reload)

        restart

        ;;

     *)

         printf "Usage: $0 {start|stop|restart}\n" >&2

         exit 1

esac


exit $?


How to Enable Changing SVN Log Messages or History

1. SVN administrator need to rename file named pre-revprop-change.tmpl under [SVN_PATH]/hooks into pre-revprop-change (at the same directory without the tmpl extension):

[root@svn-server ~]# mv pre-revprop-change.tmpl pre-revprop-change

2. Change the file permission :

[root@svn-server ~]# chmod a+x pre-revprop-change


How to Enable auto properties

You have to add this line to the .../config/svnserve.conf:

...

[miscellany]

enable-auto-props = true

[auto-props]

*.mq5 = svn:keywords = "Author Revision Date"

...