Automatic Subversion root parameter
Q I have an old box that's running Ubuntu Server 8.04 and has a working installation of Subversion. It currently has a single repository under /svn, but I'm experimenting with having two separate repositories with a common parent directory. I created the repositories with svnadmin and they seem to work fine if I use svn checkout file: ///full/path/to/repo/, but if I use svn checkout svn:///relative/path/to/checkout then I need to tell svnserve where the root of the two repositories lies. After some research online, I've found that I can do that by passing the root as a parameter to svnserve - how can I do that when svnserve is started automatically during the boot process?
A Are the two repositories under the same directory? If so, you can use the --root option with svnserve and include the repository name in the request. For example, if you are using /full/path/to/repo1 and /full/path/to/repo2, start svnserve with
svnserve --root /full/path/to
Then you can access them as svn://repo1/path/to/file or svn://repo2/path/to/other/file. The alternative is to use a separate server for each repository, running them on different ports or hostnames to differentiate between the two. For example, the following:
svnserve --daemon --root /full/path/to/repo1
svnserve --daemon listen-port=3691 --root /full/path/to/repo2
will run one server on the standard port (3690) and one on port 3691. Requests to the second server would use a URI of the form svn://hostname:3691/path/to/file. This works, but it's clunky for users of the second repository since they have to include the port number each time. You could use different hostnames instead by editing /etc/hosts to make the second hostname an alias of the first. The lines in /etc/hosts look like:
ip-address hostname aliases
where you can have any number of aliases (each one should be separated by a space). Add an alias to your second hostname in here, and then on the other computers on your network (unless you run a local DNS server, in which case you need only make the changes there). After that's done, you can start the two instances of svnserve with
svnserve --daemon listen-host=myhost --root /full/path/to/repo1
svnserve --daemon listen-host=newhost --root /full/path/to/repo2
Now you can use the appropriate hostname for each repository without all the unpleasant business of mucking about with port numbers. Also note that Ubuntu doesn't include an init script for svnserve, so you should put these commands in /etc/rc.local before the final line containing exit 0.
Follow us on Identi.ca or Twitter