It has been a long time since I posted my last blog post. So here I am ‘populating’ my post with some information that could be of some worth to me and others in need. So without much delay, let me put down the ad hoc article on setting up svn repository. It also talks about creating a structured hierarchy for code management and also gives information on adding projects to SVN repository.
To create svn repository svnadmin command line tool is used.
$ svnadmin create /home/gaurav/new_repo
To add directories to the new repository …
$ svn mkdir file:///home/gaurav/new_repo/main_project
$ svn mkdir file:///home/gaurav/new_repo/main_project/branches
$ svn mkdir file:///home/gaurav/new_repo/main_project/tags
$ svn mkdir file:///home/gaurav/new_repo/main_project/trunk
When directories are added, it asks for the commit comments.
Once the repository structure is ready, import the code like this:
$ svn import /home/gaurav/my_new_app/ file:///home/gaurav/new_repo/main_project/trunk
Following command runs svn server @ port 4444 for localhost
-r is for the repository and should be passed the repository path
$ svnserve -d -r /home/gaurav/repository/ --listen-port 4444 --listen-host localhost
Once svn server starts as a daemon, checkout can be done as:
$ svn co svn://localhost:4444/momsworld/trunk mw_0718
Add users to your server
In order to authenticate our intended users, some changes are required to be made. Inside the new repo (c:\svn-repo or /home/gaurav svn-repo), there is a directory called conf. There you will find svnserve.conf.
You need to enable these lines in the file:
anon-access = read
auth-access = write
password-db = passwd
All other comments can be left untouched. For easy readability, I have only put the required section above.
With this setting, anyone would be able to read the files but only an authenticated user would be able to checkin. Also password-db tells server that a file named ‘passwd’ would be storing usernames and passwords.
Let’s create that file now. It should also be in the conf directory and look like this:
david = secret
Similarly many users could be added in the format NAME = PASSWORD. There are many other advanced ways to add password protection to Subversion but this one is the easiest I suppose. Subversion has good integration with Apache’s web server authentication so that could be utilized as well.