What is subversion(svn):
Subversion is an open source version control system used for keep track of change to source code. Subversion manages files and directories over time an increments revision made to the file system. A tree of file is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to your files and directories. This allows you to recover older version of your date or examine the history of how your data changed.
Subversion can access its repository across networks, which allows it to be used by people on different computers. At some level, the ability for various people to modify and manage the same set of data from their respective locations fosters collaboration.
Installation:
There are two types of installation:
- Installation from pre-compiled packages
- Installation from source code
Installation from packages:
For RedHat Linux(or other Linux distributions which supports RPM) download subversion RPM package and install. See manual of rpm utility for installation.
For Debian Linux issue apt-get install subversion
and by confirming the installation you are done. I also recommend to install subversion-tools by issuing apt-get install subversion-tools
.
Installation from source:
Installation from source code is slightly tricky. First of all download latest version of subversion code from http://subversion.tigris.org.
Now extract source to your preferred directory (lets assume /home/testuser/svncode/
), and issue the following command in sequence after switching to svncode directory:
- ./configure
- make
- make install
./configure
will create Makefile
make
makes Subversion form the just-created Makefile
make install
install Subversion if make
is successfullyAnd you are done….
Issue svnadmin create /home/testuser/repository
to create a new repository, this should create a directory structure like:
drwxrwxrwx 7 root root 4096 2006-11-07 17:18 .
drwxrwxrwx 14 root root 4096 2006-11-07 17:18 ..
drwxrwxrwx 2 root root 4096 2006-11-07 17:18 con
drwxrwxrwx 2 root root 4096 2006-11-07 17:18 dav
drwxrwxrwx 2 root root 4096 2006-11-07 17:18 db
-rwxrwxrwx 1 root root 2 2006-11-07 17:18 format
drwxrwxrwx 2 root root 4096 2006-11-07 17:18 hooks
drwxrwxrwx 2 root root 4096 2006-11-07 17:18 locks
-rwxrwxrwx 1 root root 379 2006-11-07 17:18 README.txt
Now we need to allow remote access to it so that users can import their files. By editing conf/svnserve.conf
we can set user accounts, permissions.
Initially svnserve.conf looks like:
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.tigris.org/ for more information.
### [general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
### anon-access = write
### auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### The format of the password database is similar to this file.
### It contains one section labelled [users]. The name and
### password for each user follow, one account per line. The
### format is
### USERNAME = PASSWORD
### Please note that both the user name and password are case
### sensitive. There is no default for the password file.
### password-db = passwd
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
### realm = My First Repository
Uncomment line containing [general]
, anon-access
, auth-access
and password-db
with suitable permissions. Also add file named passwd parallel to svnserve.conf containing
[users]SVNUSERNAME = SVNUSERPASSOWRD
You can add as many users you want. Now you are done with user accounts and permissions.
Next you have to start the svnserver by issuing svnserve -d -r /home/testuser/repository
.
Now you are ready with your subversion server, you can access your repository from svn://yourdomain.com/repository/
On some systems (like Debian GNU/Linux) this requires to write an init script so that the server starts up every time the system is rebooted. This could be done by creating a file called svnserve
in the /etc/init.d
directory, and then editing it to look like the following example file:
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/svnserve NAME=svnserve DESC="SVN Repository Server Daemon"
test -x $DAEMON || exit 0
OPTIONS="-d -r /cvs/src"
# Get lsb functions
#. /lib/lsb/init-functions
. /etc/default/rcS start() { echo "Starting $DESC... "
# echo "Starting $DESC: "
if ! start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS
>/dev/null 2>&1; then
status=$?
echo $status
return $status
fi log_end_msg 0
return 0
}
case "$1" in
start)
start
;;
stop)
echo "Stopping $DESC: "
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
echo $?
;;
restart|force-reload)
$0 stop
sleep 1
start
#echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac exit 0
This script also allows to manually start and stop the svnserver service whenever needed. Note: be sure and change the OPTIONS
line to reflect the location of your repository; in our previous example this location was /home/testuser/repository
. Once this file is created and edited to look like the previous example, you need to chmod
the script to be executable by issuing chmod +x /etc/init.d/svnserve
and also set it to startup at boot time by issuing update-rc.d svnserve defaults
Now simply start/stop the service by issuing:
/etc/init.d/svnserve start/stop
Please refer Subversion book for more help and usage.