Create CVS Repo
This guide explains how to create a CVS repository.
Create commit group
First, you may want to create a new group with commit rights:
$ doas groupadd commit
For each existing user you want to give commit rights to:
$ doas usermod -G commit $USER
For each new user you want to create with commit rights:
$ doas useradd -G commit $USER
Replace $USER with the committer's user's name.
Setting CVSROOT
Before we begin, decide where you want the CVS files to be located. You will want to set CVSROOT.
You can set it for just the current shell:
$ export CVSROOT=/path/to/CVS
Replace /path/to/CVS
with the actual directory. /CVS is recommended:
$ export CVSROOT=/CVS
As a shortcut, you can add this to the bottom of your ~/.profile so you don't have to type it each time:
$ echo 'CVSROOT="/CVS"' >> ~/.profile
Once CVSROOT is set, log out and log in. From now on, you can omit the -d argument when working with cvs.
Create new repo
To create a new CVS repository, type:
$ doas mkdir $CVSROOT
$ doas chown $USER:commit $CVSROOT
$ cvs init
Replace $USER
with the maintainer of CVSROOT.
Import New Module
If you have existing code that you'd like to import to a CVS repository, first change
to the folder containing the source code, then type:
$ cvs import reponame vendortag releasetag
Replace reponame
, vendortag
, and releasetag
. CVS will put the source files inside a directory named reponame
inside the CVS root directory. vendortag
should be replaced with the vendor (the author) of the repository. releasetag
is the tag for the specific release.
For example:
$ cd ~/ircnowd/
$ cvs import ircnowd ircnow start
Note: CVS does not automatically transform the imported source code into a working directory. As a result, any changes you make to the original source code directory cannot be committed to the CVS repo.
To fix this, you will need to checkout the source code. Change your directory to somewhere else to place the new working directory, then type:
$ cd /path/to/new/directory/
$ cvs checkout -P reponame
Replace /path/to/new/directory/
with the directory you want the working directory to be in. Then, replace reponame
with the repository name.
Change directory to reponame
to make changes. Afterwards, use cvs to commit them:
$ cd reponame
... work on code ...
$ cvs commit
For example, suppose you create a new folder for working directories ~/code/ and then checkout the working directory for ircnowd:
$ mkdir ~/code/
$ cd ~/code/
$ cvs checkout -P ircnowd
$ cd ~/code/ircnowd/
... work on code ...
$ cvs commit
Now, ~/code/ircnowd will have the working directory for ircnowd. CVS will track changes so that you can commit changes to the CVS repo.
If checkout works properly, you can safely delete the old source code directory you imported from (since that one is not tracked by CVS).
$ rm -rf ~/ircnowd/
Granting commit access
You will want to change group ownership and provide group write permissions:
$ doas chown -R $USER:commit $CVSROOT
$ doas chmod -R g+w $CVSROOT
A sample directory should look like this:
# ls -lha /CVS
total 28
drwxr-xr-x 7 jrmu commit 512B Oct 9 06:19 .
drwxr-xr-x 10 root wheel 512B Oct 9 06:10 ..
drwxrwxr-x 3 jrmu commit 1.0K Apr 29 06:48 CVSROOT
drwxrwxr-x 9 jrmu commit 512B May 8 11:42 acopm
drwxrwxr-x 2 jrmu commit 1.0K Aug 26 04:17 botnow
drwxrwxr-x 8 jrmu commit 512B May 27 16:57 brogue-ce
drwxrwxr-x 6 jrmu commit 512B May 7 06:46 ircnowd
Optional: Prevent Shell Access
Optional: If your server is not used to provide shell accounts,
and all users who connect via ssh are admins, you can add the following to
prevent committers from having shell access:
First, we create /usr/bin/cvs-login.sh
:
#!/bin/sh
exec /usr/bin/cvs server
This simple shell script will be used as the login shell. Any time a committer
logs in, cvs will immediately be called.
We set it to be executable:
$ doas chown root:wheel /usr/bin/cvs-login.sh
$ doas chmod +x /usr/bin/cvs-login.sh
Next, edit /etc/ssh/sshd_config
:
Match Group commit,!wheel
AllowAgentForwarding no
AllowStreamLocalForwarding no
DisableForwarding yes
PermitListen none
PermitOpen none
PermitTunnel no
PermitUserRC no
X11Forwarding no
AllowTcpForwarding no
PermitTTY no
ForceCommand "/usr/bin/cvs-login.sh"
This will force all users in the commit group who are not in wheel (not
administrators) to use /usr/bin/cvs-login.sh. Committers therefore never
get shell access; they only get cvs access
Restart sshd to apply changes:
$ doas rcctl restart sshd
See Also: