Monday, May 31, 2010

SVN Configuration on Linux!

1. Install the Subversion

2. Create a new Repository:
Suppose to create a Repository at /usr/local/subversion/repository using fsfs database so execute the command:

mkdir -v /usr/local/subversion/
svnadmin create --fs-type fsfs /usr/local/subversion/repository

That should create a subversion repository under /usr/local/subversion/repository.

ls /usr/local/subversion/repository
conf/ dav/ db/ format hooks/ locks/ README.txt

Now, change the ownership of the newly created repository...
chown -R subversion:subversion /usr/local/subversion/repository/

Now, add the newly created member to the subversion group located in /etc/group

You should be able to see those files under the repository directory.

3. Edit the /home/svn/repository/conf/svnserve.conf and enable the following lines :
[general]
password-db = passwd
realm = repository_name

4. Edit the file /home/svn/repository/conf/passwd and add the following lines:
[users]
akshat=akshat

You can add as many users in the format USERNAME=PASSWORD. The passwords are not encrypted.

5. Set a text editor as the default SVN editor:
# export SVN_EDITOR=vim

Now that your Repository and authentication schemes are set, you need to import the development source tree to the server. You can use the file protocol or the SVN protocol to import the files. If you need to make the repository available in a network then you have to set up the svnserve.

Issue the command:
# svnserve -d -r /home/svn/
This will run the svn server in daemon mode.

6. You can now import the source tree with the following command:
$ svn import /usr/local/subversion/repository svn://yourhost/repository --username akshat
or
svn import /home/akshat/svn/IYA2009 svn://mutha/usr/local/subversion/IYA2009 --username akshat

7. You can checkout the source by using the command:
$ svn checkout svn://mutha/GMRTARchive
or
svn co svn+ssh://mutha/usr/local/subversion/IYA2009

Suppose we want to checkout a repository named GOSIP we need to do the following:

svn co svn://mutha/GOSIP
cd GOSIP/
mkdir Database ; cp /home/akshat/ncra.sql Database/ncra.sql
svn add Database

Where ncra.sql is file that is sitting under Database directory.

akshat@akshat-laptop:~/GOSIP$ svn commit Database
Authentication realm: GOSIP
Password for 'akshat': ******
Adding Database
Adding Database/ncra.sql
Transmitting file data .
Committed revision 3.

svn ci Database
svn -m 'first checkin of Databse' ci Database
cd Database/
vim ncra.sql

akshat@akshat-laptop:~/GOSIP/Database$ svn stat => for checking the editing status
M ncra.sql

M=> shows that the file has been modified.

akshat@akshat-laptop:~/GOSIP/Database$ svn up
At revision 3.
up=> update

If we want to revert to a specific version than we have to use the following command:
svn merge -rHEAD:4 .
svn commit -m "Reverted to revision 3."\

==Adding SVN users:==
Since we are using svn with an apache server, and an apache basic authentication method.

We need to create a password file with the htpasswd binary provided with a standard apache installation.

htpasswd -cmd /usr/local/subversion/repository/conf/svn-auth-file {user-name}

-c option creates a new htpasswd file.
-m encrypts the password with an MD5 algorithm.
-d encrypts the password with a CRYPT algorithm.

Where {user-name} stands for an actual user name that will be used for authentication.

Warning: We should not use the -c option once we have added the first user. Using so will create and replace all existing user within the file.

htpasswd -md /usr/local/subversion/repository/conf/svn-auth-file {user-name}

No comments:

Post a Comment