home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

  Previous section   Next section

2.2 Building Your First Repository

CVS relies on a file-based database called the CVS repository. The repository needs to be hosted on a machine with sufficient disk space to store your files and all the change data for your projects. The repository should be accessible to all the users from their workstations.

If the repository is on a remote computer, I recommend that users access the repository via SSH. Ensure that the server is running an SSH server and the workstations have a compatible SSH client. For more information on remote repositories and SSH, see Section 2.4 later in this chapter. Chapter 8 contains a full discussion of remote repositories.

For any one project, ensure there is enough disk space for three times the expected final size of that project. If you intend to store binary files, multiply by at least five. After your first project, you'll have a feel for how much space to allow.

A repository can store many projects. If you are creating a repository that may be required to handle several projects of unknown size, estimate what you can and ensure you can add more room later.

A CVS repository is user data, and it should be on a partition that is backed up and won't shut down the machine if it gets full. Repositories are often stored in /cvsroot, /var/lib/cvsroot, /home/cvsroot, or /usr/local/cvsroot. According to the Filesystem Heirarchy Standard (available at http://www.pathname.com/fhs/), the preferred location for a repository is /var/lib/cvsroot.

Another possibility is to put the repository in /cvsroot. This is easiest for users to remember.

Example 2-5 illustrates the steps involved in creating a repository. First, create the repository root directory on the CVS server. In Example 2-5, I create the /var/lib/cvsroot directory.

Example 2-5. Creating a repository
$ mkdir /var/lib/cvsroot
$ chgrp anthill /var/lib/cvsroot
$ ls -la /home
total 2
drwxr-xr-x    2 root     anthill      4096 Jun 28 16:31 cvsroot
$ chmod g+srwx /var/lib/cvsroot
$ ls -la /home
total 2
drwxrwsr-x    2 root     anthill      4096 Jun 28 16:33 cvsroot
$ cvs -d /var/lib/cvsroot init
$ ls -la /home
total 3
drwxrwsr-x    3 root     anthill      4096 Jun 28 16:56 cvsroot
$ ls -la /var/lib/cvsroot
total 12
drwxrwsr-x    3 root     anthill      4096 Jun 28 16:56 .
drwxrwsr-x   10 root     staff        4096 Jun 28 16:35 ..
drwxrwsr-x    3 root     anthill      4096 Jun 28 16:56 CVSROOT
$ chown -R cvs /var/lib/cvsroot

To allow others to use the repository, create a Unix group for CVS users and chgrp the repository's root directory to that group. Set the directory's SGID bit, so that files created in the directory have the same group ID as the directory's group ID (this can prevent trouble later). Make the directory group-writable, -readable, and -executable.

To minimize security risks, create a user named cvs to own the repository and the administrative files. chown the repository's root directory and administrative files to that username. Chapter 6 explains security.

Execute the following command to set up your chosen directory as a CVS repository:

cvs -d repository_root_directory init

CVS commands follow the format:

 cvs [cvs-options] command [command-options]

The CVS options modify the behavior of CVS as a whole, and the command options modify the behavior of a CVS command. This is explained more fully in Chapter 3.

Example 2-5 illustrates the entire process of creating a directory and then creating a CVS repository within that directory. In this case, the CVS option is -d repository_path, and the command is init. There is no command option. anthill is the name of the group with access to CVS, and cvs is the name of the CVS owner.

Debian Linux has a script, cvs-makerepos, that builds a repository based on preexisting Debian configuration scripts. See man cvs-makerepos for more information and man cvsconfig for an automated system for configuring a Debian CVS repository.

Setting up the repository produces a place to store projects and also adds the special CVSROOT directory. The CVSROOT directory contains configuration and metadata files. Chapter 6 explains this directory in more detail. Projects are stored in subdirectories of the repository root directory, which is /var/lib/cvsroot in our example.


  Previous section   Next section
Top