6.8. Distributed RepositoriesMany CVS systems use only a single, central repository, but not all. Many open source projects that rely on CVS use mirrored repositories to distribute the latest source, and many of those have a version of the repository available on the World Wide Web. Recently, write-proxying has been enabled for mirror repositories: this process allows the user to connect to the mirror as if the mirror were the central repository. 6.8.1. Mirroring a RepositoryMany project teams have public, read-only CVS repositories. If you want to do likewise, you can copy the repository, reserve the original repository for your project work, and use the copy (or mirror) repository as a public repository. The copy can be on the same computer as the original or on a different computer or even a different network. Having two or more copies of a repository allows you to put one copy on a trusted network for your developers and another on a more public part of your network for the general public.
Mirror a repository by copying the repository files. To avoid getting part of one release and part of another due to the copy overlapping with a commit, freeze the repository with read locks before mirroring and unfreeze it afterward. The Unix and Linux rsync program is a useful tool to use when mirroring. It allows you to recursively transfer only the changed files between any two directories and recovers properly if it's interrupted. It also has an optional CVS-exclusion mode, called with the --cvs-exclude option, which ignores the same files CVS ignores by default. By default, rsync uses SSH, but if your system is configured differently, you can use the -e ssh option to rsync to transfer using the SSH protocol. An rsync command or script can be triggered at either the central repository or the mirror. There is also a repository mirroring tool called CVSup. It's designed specifically for use with CVS, and parses the CVS data files to do the mirroring as efficiently as possible. It is triggered by the mirror, and is most often updated on a daily basis, triggered by an automation application such as cron. To keep a secondary repository up to date with all changes from the primary repository, trigger an rsync script in all four of the loginfo, postadmin, posttag, and postwatch scripting files. You can't as easily keep a CVSup'd mirror constantly up to date, because the CVSup system is designed to be triggered from the mirror rather than from the central repository. Example 6-10 shows a typical rsync line for the scripting files. Add this line to all four of the loginfo, postadmin, posttag, and postwatch files to generate an rsync attempt with the mirror repository in the directory /usr/local/cvs on the machine mirror1. Configure rsync and SSH so that they don't need a passwordsee your SSH documentation for details. Note that rsync has many useful options other than the ones I've included, which are to preserve permissions, group, and owner, and to use compression. Example 6-10. Mirroring with rsync
Because we're trying to mirror the repository, I've chosen not to use cvs-exclude and thus kept the CVS administrative files. The %p is an internal CVS variable (valid in recent versions only) and is explained in the section "Running Scripts" in Chapter 7. 6.8.2. Write ProxiesIn CVS version 1.12.10, the developers added the ability for CVS mirrors to act as write proxies for the central repository. The mirror (or secondary repository, in the proxy system) handles all read requests itself, but passes write requests to the central (primary) repository.
To configure a write proxy system, edit the CVSROOT/config files in your secondary repositories. The PrimaryServer configuration option must specify the repository path of the primary repository: be aware that at present, you must use the :ext: or :fork: connection methods. There is no mandatory configuration on the primary repository for write proxying itself, but almost all administrators will choose to configure a mirroring system of some sort.
6.8.3. Web-Viewable RepositoriesAn alternative way to distribute a repositoryfor read-only accessis across the Web. The current favorite tool for doing this is ViewVC (formerly ViewCVS), which generates HTML navigation for CVS and Subversion repositories, and is available at http://www.viewvc.org. A similar tool is CVSWeb, which has gone through several incarnations and is currently being maintained as FreeBSD-CVSWeb. Web distribution is very popular in open source projects, or in other projects where a variety of people using a variety of platforms will want read-only access to the documents stored in CVS. The INSTALL document included in the ViewVC source distribution is very clear and easy to read, and the installation is automated. Configuration is done by editing the file viewvc.conf, which itself contains clear and concise examples. |