Next Previous Contents

3. Setting up CVS

First you need to install the CVS package, on Redhat linux use


cd /mnt/cdrom/Redhat/RPMS
rpm -i rcs*.rpm
rpm -i cvs*.rpm
To see the list of files installed do -
rpm -qpl cvs*.rpm | less

and browse output using j,k, CTRL+f, CTRL+D, CTRL+B, CTRL+U or using arrow keys, page up/down keys. See 'man less'.

On other flavors of unix, you may need to download the RCS and CVS tar balls and follow README, INSTALL files to setup CVS. Visit http://www.cyclic.com and http://www.loria.fr/~molli/cvs-index.html

3.1 Environment variables

The following environment variables need to be setup in /etc/profile - default values required for all users. If not set in /etc/profile, than you should add these to your local profile file  /.bash_profile.


export EDITOR=/bin/vi
export CVSROOT=/home/cvsroot
export CVSREAD=yes

Create a directory to store the source code repository and give read, write access to unix group/user.


export CVSROOT=/home/cvsroot
mkdir $CVSROOT
chmod o-rwx $CVSROOT
chmod ug+rwx $CVSROOT

To initialize the CVS and to put in source code files do -
cvs init

# Change directory is a must
cd $HOME/my_source_code_dir

# Must give vendor tag and revision tag
cvs import my_source_code_dir V1_0 R1_0  

3.2 Migrate RCS to CVS

To migrate the existing RCS files to CVS, use the following script. Make sure that you installed korn shell package pdksh*.rpm from Linux contrib cdrom. After running the script move the resultant directory-tree to $CVSROOT/some_project_name

NOTE : Korn shell /bin/ksh is got by installing pdksh*.rpm from Linux contrib cdrom


#!/bin/ksh

#############################################################
# Program to Migrate the existing source code in RCS to CVS 
#
# Needs the korn shell RPM package  pdksh*.rpm from Linux 
# contrib cdrom
#############################################################

# Enter your current RCS file location here.
RCS_DIRECTORY=/usr/home/my_rcs_tree

# Temporary directory to hold the files
TMP_RCS_DIR=$HOME/tmp_rcs_directory

mkdir $TMP_RCS_DIR

# Copy the tree having RCS directory into temporary directory
cd $RCS_DIRECTORY
tar cvf -  ` find . -name RCS -print ` | ( cd $TMP_RCS_DIR; tar -xvf - )

cd $TMP_RCS_DIR

for ii in `find . -type f -print` ; 
do 
        # $ii will have like /home/foo/RCS/sample.c,v
        echo $ii

        # Get the dir name like /home/foo/RCS from ii
        kk=`dirname $ii`
        # echo $kk

        # Drop off RCS from kk - like /home/foo
        jj=`dirname $kk`
        #       echo $jj

        # Move file from RCS to upper leve like
        # mv /home/foo/RCS/sample.c,v  /home/foo
        mv $ii $jj
done

# Remove the empty directory RCS like -
# rmdir /home/foo/RCS
cd $TMP_RCS_DIR
find  . -type d -name RCS -exec rmdir {} \;

# The resultant directory is $TMP_RCS_DIR (which is $HOME/tmp_rcs_directory)
# Move the directory tmp_rcs_directory to $CVSROOT/some_project_name
# Now the RCS is migrated to CVS as 'some_project_name' .

The resultant directory is $TMP_RCS_DIR (which is $HOME/tmp_rcs_directory) Move the directory tmp_rcs_directory to $CVSROOT/some_project_name Now the RCS is migrated to CVS as 'some_project_name'. You can start using the CVS commands on module 'some_project_name'.
Next Previous Contents