User and Group Management
This topic is definitely one of the most commonly overlooked by those who venture to set up the repositories. For repository access via Apache's httpd, it is advisable for security reasons to create a special user or group (in lieu of a superuser (root)) and run "httpd" processes as this special user/group. This setup can be used in environments where access to the production repositories via http may be desirable. Additionally, users, who are required to access this storage using the http scheme, can be added to such special group(s) as well.
A sample user and group organization that enables playing with Subversion is shown below:
svnplaygrp:x:503:apached,svnroot,ram </Pre> <P> <h3>Subversion Installation </h3> <P> <P>From the <a href="http://subversion.tigris.org/project_packages.html">Download pages of Subversion project</a>, you can download the sources/binary packages of Subversion for various Linux distributions and also the dependency packages. <P> <P>The command output shown in the following sections was extracted from an environment where Subversion v1.4.3 has been installed from the sources in a path different from the default one (/usr/local). As with many of the distributions, Subversion is bundled as part of the default installation packages, so you don't have to choose during the installation of your Linux distro. However, it is perfectly okay to have multiple versions of Subversion installed on the same system, as shown below. <P> <pre class="brush: text; html: collapse;" style="font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; color: rgb(0, 0, 0); background-color: rgb(238, 238, 238); font-size: 12px; border: 1px dashed rgb(153, 153, 153); line-height: 14px; padding: 5px; overflow: auto; width: 100%;"> sh-3.1$ svn --version svn, version 1.3.0 (r17949) compiled Feb 12 2006, 04:42:41 Copyright (C) 2000-2005 CollabNet. Subversion is open source software, see http://subversion.tigris.org/ This product includes software developed by CollabNet (http://www.Collab.Net/).
The following RA modules are available:
- ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
- handles 'https' scheme
- ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
- ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
sh-3.1$ /opt/svn-1.4.3/bin/svn --version svn, version 1.4.3 (r23084) compiled Jan 31 2007, 23:25:04 Copyright (C) 2000-2006 CollabNet. Subversion is open source software, see http://subversion.tigris.org/ This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
- ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
- handles 'http' scheme
- handles 'https' scheme
- ra_svn : Module for accessing a repository using the svn network protocol.
- handles 'svn' scheme
- ra_local : Module for accessing a repository on local disk.
- handles 'file' scheme
However, extra care should be taken not to mix up the commands. It is easy to get trapped in a situation where the commands fail to work with the local WC or the repository. A possible reason for this is that the local WC and the repository have been created using commands from a specific version of Subversion, but the command used is from a Subversion available in a different path. This condition is shown here:
sh-3.1$ svn info /home/ram/svnarticle_draft/svn_article svn: This client is too old to work with working copy '/home/ram/svnarticle_draft'; please get a newer Subversion client sh-3.1$ /opt/svn-1.4.3/bin/svn info /home/ram/svnarticle_draft/svn_article Path: /home/ram/svnarticle_draft/svn_article Name: svn_article URL: file:///opt/samagdocs/trunk/svn_article Repository Root: file:///opt/samagdocs Repository UUID: d87b2b87-2545-461f-ae99-430b66f94c56 Revision: 35 Node Kind: file Schedule: normal Last Changed Author: ram Last Changed Rev: 35 Last Changed Date: 2007-01-13 17:27:01 +0530 (Sat, 13 Jan 2007) Text Last Updated: 2007-01-13 17:08:08 +0530 (Sat, 13 Jan 2007) Checksum: c68730a0fc6f5e9cdcecfebfb6fbde50
While installing Subversion from source, the correct path to "apr" and "apr-utils" must be provided; otherwise, it is possible that the repo access via "http" will not work properly even though Subversion was installed without errors. The "configure" script has options, --with-apr and --with-apr-util for this purpose. The inputs to both these options, preferably, should be the full path to "apr-config" and "apu-config" directories.
Of course, there are ways to check which libraries have been used as part of the installation and which are needed for proper functioning of Subversion. Some of these methods are given below:
- readelf --dynamic </path/to/subversion>/bin/svn>
- ldd </path/to/apache>/modules/mod_dav_svn.so | grep -i http
- ldd </path/to/apache>/bin/httpd | grep -i httpd
mod_dav_svn should have utilized the same apr and apr-utils libraries as that of httpd. Both Subversion and http are linked to the same APR libraries, as shown:
sh-3.1$ ldd /opt/http-2.2.3/bin/httpd | grep -i apr libaprutil-1.so.0 => /opt/http-2.2.3/lib/libaprutil-1.so.0 \ (0x00174000) libapr-1.so.0 => /opt/http-2.2.3/lib/libapr-1.so.0 (0x00bd0000) sh-3.1$ ldd /opt/http-2.2.3/modules/mod_dav_svn.so | grep -i apr libaprutil-1.so.0 => /opt/http-2.2.3/lib/libaprutil-1.so.0 \ (0x00501000) libapr-1.so.0 => /opt/http-2.2.3/lib/libapr-1.so.0 (0x00c6b000)
Creation and Setup of Repository
To specifically check which type of repository access mechanisms are available with your version of Subversion, run this command:
<path-to-Subversion>/bin/svn --version
The output may or may not look similar to the output sh-3.1$ svn --version shown above. By looking at the previous output, we see that the following access schemes are enabled:
- DAV: "http" and "https" have access to a repository via WebDAV (DeltaV) protocol.
- SVN: "svn" has access to a repository using the svn network protocol.
- Local: "file" has access to a repository hosted on local disk.
There are no shortcuts or abbreviations (e.g., svnversion --ver) available for the different switches to go with the various Subversion subcommands. They must be typed/scripted as full whole words, for example: --version.
How to Create a Repository
Probably the first thing to do, immediately after installing SVN, is to create a repository (a.k.a. repo). But, before setting up the repository, I also recommend these steps:
- Ensure that user and group assignments have been done properly.
- Create the directory in which the repository will be hosted. If you are planning to host multiple repositories, then it is advisable to create one parent/root dir, underneath which multiple repositories can be hosted.
In our case, the repository is created in the file system of the local hard disk, as:
sh-3.1$ ls -ld /lnx_data/repos_holder/ drwxrwxr-x 2 svnroot svnplaygrp 4096 Feb 27 00:28 /lnx_data/repos_holder/
Next, do <path-to-Subversion>/svnadmin create <path-to-your-repos-dir>:
sh-3.1$ /opt/svn-1.4.3/bin/svnadmin create /lnx_data/repos_holder/testrepo sh-3.1$ ls /lnx_data/repos_holder/testrepo/ conf dav db format hooks locks README.txt
Organize the directory structure of the code the way you would like it to be in the repository. It helps to organize the structure before starting to import into the repository. Three top-level directories (branches, tags, and trunk) are needed. The actual data goes into "trunk"; whereas, the other two are empty.
The following example has the directory "testrepo" created in the home dir "/home/ram":
sh-3.1$ ls -l testrepo/ total 12 drwxrwxr-x 2 ram ram 4096 Feb 27 00:44 branches drwxrwxr-x 2 ram ram 4096 Feb 27 00:44 tags drwxrwxr-x 2 ram ram 4096 Feb 27 00:45 trunk sh-3.1$ ls -l testrepo/trunk/ total 0 -rw-rw-r-- 1 ram ram 0 Feb 27 00:45 bar.pm -rw-rw-r-- 1 ram ram 0 Feb 27 00:45 foo.pl -rw-rw-r-- 1 ram ram 0 Feb 27 00:45 Makefile
At this point, we can import data from the local dir "testrepo" to the actual repository. With the current directory being my home dir, we run the svn import command to finish this task:
sh-3.1$ /opt/svn-1.4.3/bin/svn import testrepo/ \ file:///lnx_data/repos_holder/testrepo/ -m "initial import into \ the scratch pad repo" Adding testrepo/trunk Adding testrepo/trunk/bar.pm Adding testrepo/trunk/Makefile Adding testrepo/trunk/foo.pl Adding testrepo/branches Adding testrepo/tags Committed revision 1.