Installing and Configuring SVN

Introduction

This document focuses on installing and configuring SVN on RedHat Linux as an SCM Repository. Subversion is the popular standard for version control and Software Configuration Management (SCM) for globally distributed organizations. CollabNet Subversion is an enterprise-ready distribution of Subversion that includes certified binaries, platform-specific installers, and certified plugins for Eclipse, HP Quality Center, and IBM Rational ClearCase.
SVN runs on most platforms, including Windows, Linux, AIX, and UNIX. However the most stable platform and the most used platform are Linux and Unix.
There are many variants of subversion available in market, below document is written based on CollabNet Subversion. Thousands of documents, tutorials are available over SVN but I tried to make this post as simple as possible which will help those who are going to use SVN for the first time for any small team size. Various securities, configuration can be set in SVN, which is not in scope of this article.
Follow below steps, user must have root privilege – Please check the latest version available
TortoiseSVN-1.6.8.19260-win32-svn-1.6.11.msi (windows client for SVN operation – download from http://tortoisesvn.net/downloads)

CollabNetSubversion-client-1.6.11-1.i386.rpm (command line client)
i. Import CollabNet GPG key

CollabNet Subversion RPMs are signed using our GPG key. As a one-time task,
import the CollabNet GPG key using the command:

sudo rpm –import /path/to/RPM-GPG-KEY-csvn.asc

The CollabNet GPG key is available for download at:
http://www.collab.net/nonav/downloads/subversion/gpg-key/RPM-GPG-KEY-csvn.asc

ii. First installation

The command to install the CollabNet Subversion RPM, if a previous version
has not already been installed, is:

sudo rpm -ivh /path/to/client.rpm

iii. Updating an existing installation

If you have a previous version of the CollabNet Subversion client RPM installed,
update to the new version by running this command:

sudo rpm -Uvh /path/to/client.rpm

If you also have a previous version of the CollabNet Subversion server RPM
installed, add the –force option to the command:

sudo rpm -Uvh –force /path/to/client.rpm

iv. Post-installation instructions

A. CollabNet Subversion installs into /opt/CollabNet_Subversion, which is
probably not on the executable search path for your system. Add the directory
/opt/CollabNet_Subversion/bin to your $PATH environment variable. In order to
make this change affect all users of your system and persists across reboots,
add the following line to /etc/profile:

PATH=/opt/CollabNet_Subversion/bin:$PATH

B. CollabNet Subversion provides man pages and localizations for several
languages. To take advantage of these features, update your MANPATH and/or
LOCPATH environment variables to include the CollabNet Subversion directories.
For example:

export MANPATH=/opt/CollabNet_Subversion/share/man:$MANPATH
export LOCPATH=/opt/CollabNet_Subversion/share/locale:$LOCPATH

 CollabNetSubversion-server-1.6.11-1.i386.rpm (subversion server)
i. First-time installation

Install the client RPM first. The client RPM includes all of the
Subversion libraries. (Refer to the readme for the client RPM before
continuing.) Once the client is installed, install the server RPM using
this command:

sudo rpm -ivh /path/to/server.rpm

ii. Updating an existing installation

Before updating an existing CollabNet Subversion server installation to the
latest version, follow these steps:

A. Stop the existing server if it is running:

sudo /etc/rc.d/init.d/collabnet_subversion stop

B. Back up local configuration files. The update process does not touch your
repositories at all, but it is possible for you to lose your local
configuration files, such as your Apache configuration or your list of
usernames/passwords. To be safe, copy the contents of this folder to a
safe location:

/etc/opt/CollabNet_Subversion/conf

C. Install the updates. You must update the client RPM first. Follow the
instructions in the readme for the client. Then install the server RPM
using this command:

sudo rpm -Uvh /path/to/server.rpm

D. Run the Configure-CollabNet-Subversion script. Just follow the
Post-installation instructions in the next section. When you run the
Configure script, select No when you are asked if you want to create
new repositories, users, and so on (unless you want to redo those steps).
At the end, the script restarts the server and, if you followed these
instructions, your previous configuration should still be in tact.

If you have problems, you can copy the files you saved in step B back to
their original location.

iii. Post-installation instructions

A. CollabNet Subversion installs into /opt/CollabNet_Subversion, which is
probably not on the executable search path for your system. Add the
directory /opt/CollabNet_Subversion/bin to your $PATH environment
variable. To make this change so it affects all users of your system
and persists across reboots, add the following line to /etc/profile:

PATH=/opt/CollabNet_Subversion/bin:$PATH

B. CollabNet Subversion provides an interactive script which allows you to
choose which Subversion server process you want to run (either Apache or
the custom svnserve daemon) and configure it. The script also walks you
through creating Subversion repositories and setting up of basic
Subversion authentication and authorization. Once you add CollabNet
Subversion to your system’s $PATH environment variable, run the following
script as superuser:

$ sudo Configure-CollabNet-Subversion

C. CollabNet Subversion provides man pages and localizations for several
languages. To take advantage of these features, update your MANPATH and/or
LOCPATH environment variables to include the CollabNet Subversion directories.
For example:

export MANPATH=/opt/CollabNet_Subversion/share/man:$MANPATH
export LOCPATH=/opt/CollabNet_Subversion/share/locale:$LOCPATH

CollabNetSubversion-extras-1.6.11-1.i386.rpm (subversion  extras – viewVC and python bindings)
i. First-time installation

Install the client and server RPM first. The client RPM includes all of the
Subversion libraries. (Refer to the readmes for the client and server RPM
before continuing.) Once the client and server are installed, you install
the extras RPM using this command:

sudo rpm -ivh /path/to/extras.rpm

ii. Updating an existing installation

You must update the client and server RPM first. Follow the instructions
in the readme for the client and server respectively. Then install the extras
RPM using this command:

sudo rpm -Uvh /path/to/extras.rpm

iii. Post-installation instructions

A. CollabNet Subversion installs into /opt/CollabNet_Subversion, which is
probably not on the executable search path for your system.  Add the directory
/opt/CollabNet_Subversion/bin to your $PATH environment variable. To make this
change affect all users of your system and persists across reboots, add the
following line to /etc/profile:

PATH=/opt/CollabNet_Subversion/bin:$PATH

B. CollabNet Subversion provides an interactive script which allows you to
choose which Subversion server process you want to run (either Apache or
the custom svnserve daemon) and configure it. The script also walks you
through creating Subversion repositories and setting up basic
Subversion authentication and authorization. Once you add CollabNet
Subversion to your system’s $PATH environment variable, run the following
script as superuser:

$ sudo Configure-CollabNet-Subversion

C. CollabNet Subversion provides man pages and localizations for several
languages. To take advantage of these features, update your MANPATH and/or
LOCPATH environment variables to include the CollabNet Subversion directories.
For example:

export MANPATH=/opt/CollabNet_Subversion/share/man:$MANPATH
export LOCPATH=/opt/CollabNet_Subversion/share/locale:$LOCPATH

iv. ViewVC configuration
(optional-this will give you browser based control of SVN to user)
ViewVC support currently requires that you use the Apache server option.
When you run the Configure-CollabNet-Subversion script, if you choose the
option to configure an Apache server and the extras RPM has been installed,
then you are asked if you want to configure ViewVC. Answer Yes and the script
adds ViewVC to the Apache configuration.

Start  SVN – /etc/rc.d/init.d/collabnet_subversion start
Stop SVN – /etc/rc.d/init.d/collabnet_subversion stop
SVN Status – /etc/rc.d/init.d/collabnet_subversion status
Default location for installation – /opt/CollabNet_Subversion/
Sample files for SVN Configuration (by default /etc/opt/CollabNet_Subversion/conf) –
The below configuration is required if you don’t use ViewVC and want users will do operations from SVN windows client (e.g. Tortoise). From browser you can only get read only (http download possible) view of all files in svn repositories.
httpd_csvn.conf
<IfDefine csvn_installed>
# CollabNet Subversion DAV settings
Include /etc/opt/CollabNet_Subversion/conf/collabnet_subversion_httpd.conf
</IfDefine>

<IfDefine viewvc_installed>
# CollabNet Subversion VIEWVC settings
Include /etc/opt/CollabNet_Subversion/conf/viewvc_httpd.conf
</ifDefine>

collabnet_subversion_httpd.conf (main configuration file SVN with user level access control – means when users will do check in or delete files it will ask for user name password, this helps for user tracking and their day to day operation on SVN)

ServerName 119.43.8.37:80
Listen 80

User csvn

Group csvn

<Location /svn>
DAV svn
SVNParentPath /admin/svn/repositories
AuthzSVNAccessFile /etc/opt/CollabNet_Subversion/conf/svn_access_file
Satisfy Any
Require valid-user
AuthType Basic
AuthName “Subversion repository”
AuthUserFile /etc/opt/CollabNet_Subversion/conf/svn_auth_file
</Location>

svn_auth_file (file stores the user name and password for authentication)
This file need to be created as administrator –
Steps –

i. touch svn_auth_file (this file must be present in conf directory, in this scenario – /etc/opt/CollabNet_Subversion/conf)

ii. htpasswd -b svn_auth_file username 123@svn (user ‘username’ will be added in svn_auth_file with encrypted password 123@svn)

svn_access_file (this file is used for configuring the folder level access to users by creating groups, users must be present svn_auth_file)

[groups]
servicepower = usera, userb,userc,userc
Admins = Keshab, Satya, Mike

[/KP]
Keshab= rw
Mike = rw
[/TI]
Keshab = rw
Satya = rw
[/DMPM]
Mike = rw
Satya = rw

[/]
keshab = rw
* = r

[KP:/EI]
keshab = rw
Mike= rw

[KP:/Power]
@servicepower = rw
[KP:/Power/Business_Req_Spec]
@power = rw
[KP:/Power/Database]
@power = rw

Add a user for SVN

Administrator can change the password by the following command after deleting the existing entry from svn_auth_file.

# htpasswd -b svn_auth_file username 123@svn_0

In this SVN server, users will be added to the linux system (they won’t be able to ssh login to the server) only for SVN authentication as valid user.
# useradd -d /home/cduser -s /sbin/nologin ohrid
To delete the user just delete the line (having entry of that user id) from the file svn_auth_file. Also remove that user’s id from svn_access_file (where ever it exists). Also delete that user from the linux system too by using command – deluser ohrid

Create Repository

# svnadmin create /admin/svn/repositories/repositoryname

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: