Документ взят из кэша поисковой машины. Адрес оригинального документа : http://rtm-cs.sinp.msu.ru/manual/howto/CVS-RCS-HOWTO.html
Дата изменения: Thu May 4 19:04:08 2000
Дата индексирования: Mon Oct 1 21:08:29 2012
Кодировка:
CVS-RCS- HOW-TO document for Linux (Source Code Control System)

CVS-RCS- HOW-TO document for Linux (Source Code Control System)

Al Dev (Alavoor Vasudevan) alavoor@yahoo.com

v8.0, 21 April 2000


This document is a "practical guide" to very quickly setup CVS/RCS source code control system. This document also has custom shell scripts which are wrappers on top of CVS. These scripts provide a easy user interface for CVS. The information in this document applies to Linux and as well as to all other flavors of Unix liks Solaris, HPUX, AIX, SCO, Sinix, BSD, SCO, etc..

1. Introduction

2. Which one is for me? CVS or RCS

3. Setting up CVS

4. Shell Scripts

5. CVS Documentation

6. Emacs Editor

7. Problem Reporting System

8. Other Formats of this Document

9. Copyright


1. Introduction

Source code control system is a MUST to manage the changes occuring to software project during development. Developer needs a complete history of changes to backtrack to previous versions in case of any problems. Since source code is the most vital component of any software project and software development takes a huge amount of time and money, it is very important to spend some time in safe-guarding the source code by using the source code control systems like CVS and RCS.

CVS (Concurrent Version Control System) is a powerful tool which allows concurrent development of software by multiple users. It uses RCS underneath and has application layer interface as a wrapper on top RCS.

CVS can record the history of your files (usually, but not always, source code). CVS only stores the differences between versions, instead of every version of every file you've ever created. CVS also keeps a log of who, when and why changes occurred, among other aspects.

CVS is very helpful for managing releases and controlling the concurrent editing of source files among multiple authors. Instead of providing version control for a collection of files in a single directory, CVS provides version control for a hierarchical collection of directories consisting of revision controlled files.

These directories and files can then be combined together to form a software release.

CVS can be used for storing "C", "C++", Java, Perl, HTML and other files.


2. Which one is for me? CVS or RCS

CVS actually uses RCS underneath. CVS is a lot more powerful tool and can control a complete source code tree. It is very strongly recommended that you use CVS, because you can greatly customize CVS with scripting languages like PERL, korn and bash shells. See the sample korn shell scripts at Shell Scripts .

Advantages of CVS

Dis-Advantages of CVS

Advantages of RCS

Downside of RCS

This document also has shell scripts which provide simple commands to check-out, check-in, commit files. See shell scripts at Shell Scripts

For RCS see the RCS mini-howto on the linux cdrom -


cd /mnt/cdrom/Redhat/RPMS
ls -l howto-6.0-*.noarch.rpm
rpm -qpl howto-6* | grep -i rcs 

or visit

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.

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
#############################################################

#
# rcs2cvs - convert source tree from RCS to CVS
#

# project to convert
PROJECT='project'

# current RCS root
RCSROOT="$HOME/rcs"

if cd "$RCSROOT/$PROJECT"
then
        cd "$RCSROOT"
else
        echo >&2 "`basename "$0"`: can't change to RCS directory '$RCSROOT/$PROJECT'."
        exit 1
fi

# current CVS root
CVSROOT="$HOME/cvs"

# create new CVS directory for project 'project'
if mkdir "$CVSROOT/$PROJECT"
then
        :
else
        echo >&2 "`basename "$0"`: can't create CVS directory '$CVSROOT/$PROJECT'."
        exit 2
fi

# create CVS project tree from RCS tree
find "$PROJECT" -type d -name RCS -print |
while read RCS
do
        CVS="`dirname "$RCS"`"
        (if cd "$RCS"
        then
#               if find . -type f -name '*,v' -print | cpio -pdmv "$CVSROOT/$CVS"
                if find . -type f -print | cpio -pdmv "$CVSROOT/$CVS"
                then
                        :
                else
                        echo >&2 "`basename "$0"`: can't convert RCS subdirectory '$RCSROOT/$RCS' to CVS subdirectory '$CVSROOT/$CVS'."
                fi
        else
                echo >&2 "`basename "$0"`: can't change to RCS subdirectory '$RCSROOT/$RCS'."
        fi)
done

Now the RCS is migrated to CVS as 'project'. You can start using the CVS commands on module 'project'.

4. Shell Scripts

The following are wrappers around the basic CVS commands. The scripts are written for Korn shell since korn shell is always available on all flavors of unixes, but you can translate to bash or PERL if needed. You can customize these scrips to your taste. They are basically CVS commands but features are added to make it site specific. For example, sedit script provides locking so that users will know some-one is editing the file. Ofcourse users can directly use the CVS commands to by-pass these scripts. These scripts demonstrate as to how CVS can be customized to a great extent.

Copy these scripts to /usr/local/bin and this should be in the user's PATH environment.

  1. sget [-r revision_number] <file/directory name> To get a file or entire directory from CVS in READ ONLY mode. Click sget
  2. sedit [-r revision_number] <filename> To edit a file in order to make changes to code. This will lock the file so that nobody else can checkout. Ofcourse you can change the script to your requirement - make no locking, warning message or very strong locking. Click sedit
  3. scommit [-r revision_number] <filename> To commit the changes you made to filename or entire directory. Upload your changes to CVS Click scommit
  4. supdate <filename/directory> To update a filename or to update a entire directory by getting the latest files from CVS Click supdate
  5. sunlock [-r revision_number] <filename> To unlock the file got by sedit. Will release the lock. Click sunlock
  6. slist To see the list of files currently being edited by you. Does 'ls -l | grep | ...' command. Click slist
  7. sinfo <filename/directory> To get the information of changes/revisions to a file Click sinfo
  8. slog <filename> To get the history of changes/revisions to a file from CVS Click slog
  9. sdif <filename>

    sdif -r rev1 -r rev2 <filename> To get the diff of your file with CVS. Click sdif

    NOTE: sdif has only one 'f' because there is already another unix command called 'sdiff'

  10. sadd <filename> To add a new file to CVS repository Click sadd
  11. sdelete <filename> To delete a file from CVS repository Click sdelete
  12. sfreeze <revision name> <directory name> To freeze the code, that is make release of entire source tree. Click sfreeze
  13. saddtree <revision name> <directory name> To add a directory tree to CVS. Click saddtree

    For example :


            cd $HOME;   
            sfreeze REVISION_1_0  srctree  
    

    This will freeze code with tag REVISION_1_0 so that you can later checkout the entire tree by using with revision name

                ******************************************************

4.1 sget

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

Save this file as text file and chmod a+rx on it.


#!/bin/ksh

# CVS program sget
# Program to check out the file from CVS read-only

cmdname=`basename $0`

Usage()
{
        print "\nUsage: $cmdname [-r revision_number/symbolic_tag_name] <file/directory name> "
        print "The options -r are optional "
        print "For example - "
        print " $cmdname -r 1.1 foo.cpp"
        print " $cmdname foo.cpp "
        print " $cmdname some_directory "
        print "Extract by symbolic revision tag like - "
        print " $cmdname -r REVISION_1 some_directory "
        print " "
        exit
}

# Command getopt will not supported in next major release. 
# Use getopts instead. 
while getopts r: ii
do
        case $ii in
        r) FLAG1=$ii; OARG1="$OPTARG";;
        ?) Usage; exit 2;;
        esac
done
shift ` expr $OPTIND - 1 `

#echo FLAG1 = $FLAG1 , OARG1 = $OARG1

if [ $# -lt 1 ]; then
        Usage
fi

bkextn=sget_bak

hme=` echo $HOME | cut -f1 -d' '  `
if [ "$hme" = "" ]; then
        print "\nError: \$HOME is not set!!\n"
        exit
fi

# Check if file already exists....
if [ -f $1 ]; then
        user_perms=" "
        group_perms=" "
        other_perms=" "
        user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
        group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
        other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
        if [ "$user_perms" = "w" -o "$group_perms" = "w"  \
                -o "$other_perms" = "w" ]; then
                print "\nError: The file is writable. Aborting $cmdname ......"
                print "       You should either backup, scommit or delete the file and"
                print "       try $cmdname again\n"
                exit
        fi
fi

cur_dir=`pwd`
#echo $cur_dir

len=${#hme}
len=$(($len + 2))
#echo $len

subdir=` echo $cur_dir | cut -b $len-2000 `
#echo $subdir

if [ "$subdir" = "" ]; then
        fdname=$1
else
        fdname=$subdir"/"$1
fi

# Move the file
touch $1 2>/dev/null
\mv -f $1 $1.$bkextn

# Create subshell
(
cd $hme
#echo $fdname

# Use -A option to clear all sticky flags
if [ "$FLAG1" = "" ]; then
        cvs -r checkout -A $fdname
else
        cvs -r checkout -A -$FLAG1 $OARG1 $fdname
fi
)
#pwd

if [ -f $1 ]; then
        print "\nREAD-ONLY copy of the file $fdname obtained."
        print "Done $cmdname"
        #print "\nTip (Usage): $cmdname <file/directory name> \n"
fi

4.2 sedit

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

Save this file as text file and chmod a+rx on it.


#!/bin/ksh
# CVS program sedit
# Program to check out the file from CVS read/write mode with locking

cmdname=`basename $0`

Usage()
{
#       print "\nUsage: $cmdname [-r revision_number] [-F] <filename>"
#       print "The options -r, -F are optional "
#       print "The option -F is FORCE edit even if file is "
#       print "locked by another developer"

        print "\nUsage: $cmdname [-r revision_number] <filename>"
        print "The options -r are optional "

        print "For example - "
        print " $cmdname -r 1.1 foo.cpp"
        print " $cmdname foo.cpp "
#       print " $cmdname -F foo.cpp "
        print " "
}

# Command getopt will not supported in next major release. 
# Use getopts instead. 
#while getopts r:F ii
while getopts r: ii
do
        case $ii in
        r) FLAG1=$ii; OARG1="$OPTARG";;
#       F) FLAG2=$ii; OARG2="$OPTARG";;
        ?) Usage; exit 2;;
        esac
done
shift ` expr $OPTIND - 1 `

#echo FLAG1 = $FLAG1 , OARG1 = $OARG1

if [ $# -lt 1 ]; then
        Usage
        exit
fi

hme=` echo $HOME | cut -f1 -d' '  `
if [ "$hme" = "" ]; then
        print "\nError: \$HOME is not set!!\n"
        exit
fi

bkextn=sedit_bak

cur_dir=`pwd`
#echo $cur_dir

len=${#hme}
len=$(($len + 2))
#echo $len

subdir=` echo $cur_dir | cut -b $len-2000 `
#echo $subdir

if [ "$subdir" = "" ]; then
        fdname=$1
else
        fdname=$subdir"/"$1
fi

# If file is already checked out by another developer....
cvs_root=` echo $CVSROOT | cut -f1 -d' '  `
if [ "$cvs_root" = "" ]; then
        print "\nError: \$CVSROOT is not set!!\n"
        exit
fi
cldir=$CVSROOT/$subdir/Locks
mkdir $cldir 2>/dev/null
rcsfile=$CVSROOT/$subdir/$1,v
#echo $rcsfile

if [ ! -e $rcsfile ]; then
        print "\nError: File $1 does not exist in CVS repository!!\n"
        exit
fi

# Get the tip revision number of the file....
# Use tmpfile as the arg cannot be set inside the sub-shell
tmpfile=$hme/sedit-lock.tmp
\rm -f $tmpfile 2>/dev/null
if [ "$FLAG1" = "" ]; then
        (
        cd $hme
        cvs log $fdname | head -6 | grep head: | awk '{print $2}' > $tmpfile 
        )
        OARG1=`cat $tmpfile`
        \rm -f $tmpfile 2>/dev/null
fi

lockfile=$cldir/$1-$OARG1
#if [ -e $lockfile -a "$FLAG2" = "" ]; then
if [ -e $lockfile ]; then
        print "\nError: File $1 Revision $OARG1 already locked by another developer !!"
        aa=` ls -l $lockfile | awk '{print "Locking developers unix login name is = " $3}' `
        print $aa
        print "That developer should do scommit OR sunlock to release the lock"
        print " "
#       print "You can also use -F option to force edit the file even if"
#       print "the file is locked by another developer. But you must talk to"
#       print "other developer to work concurrently on this file." 
#       print "For example - this option is useful if you work on a seperate"
#       print "C++ function in the file which does not interfere with other"
#       print "developer."
#       print " "
        exit
fi

# Get read-only copy now....
if [ ! -e $1 ]; then
        (
        cd $hme
        cvs -r checkout $fdname 1>/dev/null
        )
fi

# Check if file already exists....
if [ -f $1 ]; then
        user_perms=" "
        group_perms=" "
        other_perms=" "
        user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
        group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
        other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
        if [ "$user_perms" = "w" -o "$group_perms" = "w"  \
                -o "$other_perms" = "w" ]; then
                print "\nError: The file is writable. Aborting $cmdname ......"
                print "       You must backup, scommit or delete file and"
                print "       try $cmdname again\n"
                exit
        fi
        #print "\nNote: The file $1 is read-only."
        #print "Hence I am moving it to $1.$bkextn ....\n"
        \mv -f $1 $1.$bkextn
        chmod 444 $1.$bkextn
elif [ -d $1 ]; then
        print "\nError: $1 is a directory and NOT a file. Aborting $cmdname ....\n"
        exit
fi

# Create subshell
print "\nNow getting the file $1 from CVS repository ...\n"
(
cd $hme
#echo $fdname
# Use -A option to clear the sticky tag and to get 
# the HEAD revision version
if [ "$FLAG1" = "" ]; then
        cvs -w checkout -A $fdname
else
        cvs -w checkout -A -$FLAG1 $OARG1 $fdname
fi
)

if [ -e $1 ]; then
        touch $lockfile
fi

#pwd

print "\nDone $cmdname"
#print "\nTip (Usage): $cmdname <filename> \n"

4.3 scommit

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

Save this file as text file and chmod a+rx on it.


#!/bin/ksh
# CVS program scommit
# Program to commit the changes and check in the file into CVS

cmdname=`basename $0`

Usage()
{
        print "\nUsage: $cmdname [-r revision_number] <filename>"
        print "The options -r are optional "
        print "For example - "
        print " $cmdname -r 1.1 foo.cpp"
        print " $cmdname foo.cpp "
        print " "
}

# Command getopt will not supported in next major release. 
# Use getopts instead. 
while getopts r: ii
do
        case $ii in
        r) FLAG1=$ii; OARG1="$OPTARG";;
        ?) Usage; exit 2;;
        esac
done
shift ` expr $OPTIND - 1 `

#echo FLAG1 = $FLAG1 , OARG1 = $OARG1

if [ $# -lt 1 ]; then
        Usage
        exit 2
fi

if [ -d $1 ]; then
        Usage
        exit 2
fi

hme=` echo $HOME | cut -f1 -d' '  `
if [ "$hme" = "" ]; then
        print "\nError: \$HOME is not set!!\n"
        exit
fi

# Find sub-directory
cur_dir=`pwd`
#echo $cur_dir
len=${#hme}
len=$(($len + 2))
#echo $len
subdir=` echo $cur_dir | cut -b $len-2000 `
#echo $subdir
if [ "$subdir" = "" ]; then
        fdname=$1
else
        fdname=$subdir"/"$1
fi

# If file is already checked out by another user....
cvs_root=` echo $CVSROOT | cut -f1 -d' '  `
if [ "$cvs_root" = "" ]; then
        print "\nError: \$CVSROOT is not set!!\n"
        exit
fi
cldir=$CVSROOT/$subdir/Locks
mkdir $cldir 2>/dev/null

# Get the working revision number of the file....
# Use tmpfile as the arg cannot be set inside the sub-shell
tmpfile=$hme/sedit-lock.tmp
\rm -f $tmpfile 2>/dev/null
if [ "$FLAG1" = "" ]; then
        (
        cd $hme
        cvs status $fdname 2>/dev/null | grep "Working revision:" | awk '{print $3}' >$tmpfile
        )
        OARG1=`cat $tmpfile`
        \rm -f $tmpfile 2>/dev/null
fi

if [ "$OARG1" = "" ]; then
        print "The file $fdname is NEW, it is not in the CVS repository"
else
        lockfile=$cldir/$1-$OARG1
        if [ -e $lockfile ]; then
                # Check if this revision is owned by you...
                aa=` ls -l $lockfile | awk '{print $3}' `
                userid=`id | cut -d'(' -f2 | cut -d')' -f1 `
                if [ "$aa" != "$userid" ]; then
                        print " "
                        print "The file $fdname is NOT locked by you!!"
                        print "It is locked by unix user name $aa and your login name is $userid"
#                       print "If you are working concurrently with other developer"
#                       print "and you used -F option with sedit."
                        print "You need to wait untill other developer does scommit"
                        print "or sunlock"
                        print "Aborting the $cmdname ...."
                        print " "
                        exit 2
                fi
        else
                if [ -f $CVSROOT/$subdir/$1,v ]; then
                        print "You did not lock the file $fdname with sedit!!"
                        print "Aborting the $cmdname ...."
                        exit 2 
                else
                        print "\nThe file $fdname does not exist in CVS repository yet!!"
                        print "You should have done sadd on $fdname ...."
                fi
        fi
fi

if [ -d $1 ]; then
        Usage
        exit 2
        # Do not allow directory commits for now ...
        #cvs commit
else
        cvs commit $1
        exit_status=$?
fi

if [ $exit_status -eq 0 ]; then
        print "\nDone $cmdname. $cmdname successful"
        #print "\nTip (Usage): $cmdname <filename/directory name>\n"
fi

4.4 supdate

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

Save this file as text file and chmod a+rx on it.


#!/bin/ksh

# CVS program supdate
# Program to update the file from CVS read/write mode

cmdname=`basename $0`

if [ $# -lt 1 ]; then
        print "\nUsage: $cmdname <filename>"
        exit
fi

# Check if file already exists....
if [ $# -gt 0 -a  -f $1 ]; then
        user_perms=" "
        group_perms=" "
        other_perms=" "
        user_perms=`ls -l $1 | awk '{print $1 }' | cut -b3-3 `
        group_perms=`ls -l $1 | awk '{print $1 }' | cut -b6-6 `
        other_perms=`ls -l $1 | awk '{print $1 }' | cut -b9-9 `
        if [ "$user_perms" = "w" -o "$group_perms" = "w"  \
                -o "$other_perms" = "w" ]; then
                while :
                do
                        print "\n$cmdname will backup your working file "
                        print "$1 to $1.supdate_bak before doing any merges."
                        print "Are you sure you want the merge the changes from"
                        print -n "CVS repository to your working file ? <y/n> [n]: "
                        read ans
                        if [ "$ans" = "y" -o "$ans" = "Y" ]; then
                                if [ -f $1.supdate_bak ]; then
                                        print "\nWarning : File $1.supdate_bak already exists!!"
                                        print "Please examine the file $1.supdate_bak and delete it"
                                        print "and than re-try this $cmdname "
                                        print "Aborting $cmdname ...."
                                        exit
                                else
                                        cp $1 $1.supdate_bak
                                        break
                                fi
                        elif [ "$ans" = "n" -o "$ans" = "N" -o "$ans" = "" -o "$ans" = " " ]; then
                                exit
                        fi
                done
        fi
fi

if [ -d $1 ]; then
        print "\nDirectory update is disabled as cvs update"
        print "merges the changes from repository to your working directory"
        print "So give the filename to update - as shown below: "
        print " Usage: $cmdname <filename>"
        exit
#       cvs update
else
        cvs update $1
fi

print "\nDone $cmdname. $cmdname successful"
#print "\nTip (Usage): $cmdname <filename/directory name>\n"

4.5 sunlock

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

Save this file as text file and chmod a+rx on it.


#!/bin/ksh
# CVS program sunlock
# Program to unlock the file to release the lock done by sedit

cmdname=`basename $0`

Usage()
{
        print "\nUsage: $cmdname [-r revision_number] <filename>"
        print " The options -r is optional "
        print "For example - "
        print " $cmdname -r 1.1 foo.cpp"
        print " $cmdname foo.cpp "
        print " "
}

# Command getopt will not supported in next major release. 
# Use getopts instead. 
while getopts r: ii
do
        case $ii in
        r) FLAG1=$ii; OARG1="$OPTARG";;
        ?) Usage; exit 2;;
        esac
done
shift ` expr $OPTIND - 1 `

if [ $# -lt 1 ]; then
        Usage
        exit
fi

hme=` echo $HOME | cut -f1 -d' '  `
if [ "$hme" = "" ]; then
        print "\nError: \$HOME is not set!!\n"
        exit
fi

cur_dir=`pwd`
#echo $cur_dir

len=${#hme}
len=$(($len + 2))
#echo $len

subdir=` echo $cur_dir | cut -b $len-2000 `
#echo $subdir

if [ "$subdir" = "" ]; then
        fdname=$1
else
        fdname=$subdir"/"$1
fi

# If file is already checked out by another user....
cvs_root=` echo $CVSROOT | cut -f1 -d' '  `
if [ "$cvs_root" = "" ]; then
        print "\nError: \$CVSROOT is not set!!\n"
        exit
fi
cldir=$CVSROOT/$subdir/Locks
rcsfile=$CVSROOT/$subdir/$1,v
#echo $rcsfile

if [ ! -e $rcsfile ]; then
        print "\nError: File $1 does not exist in CVS repository!!\n"
        exit
fi

# Get the tip revision number of the file....
# Use tmpfile as the arg cannot be set inside the sub-shell
tmpfile=$hme/sedit-lock.tmp
\rm -f $tmpfile 2>/dev/null
if [ "$FLAG1" = "" ]; then
        (
        cd $hme
        cvs log $fdname | head -6 | grep head: | awk '{print $2}' > $tmpfile 
        )
        OARG1=`cat $tmpfile`
        \rm -f $tmpfile 2>/dev/null
fi

lockfile=$cldir/$1-$OARG1
#echo lockfile is : $lockfile
if [ ! -e $lockfile ]; then
        print "\nFile $1 revision $OARG1 is NOT locked by anyone"
        print " "
        exit 
fi

ans=""
while :
do
        print "\n\n***************************************************"
        print "WARNING: $cmdname will release lock and enable other"
        print "         developers to edit the file. It is advisable"
        print "         to save your changes with scommit command"
        print "***************************************************"
        print -n "\nAre you sure you want to unlock the file <y/n>? [n]: "
        read ans
        if [ "$ans" = "" -o "$ans" = " " -o "$ans" = "n" -o "$ans" = "N" ]; then
                print "\nAborting $cmdname ...."
                exit
        fi
        if [ "$ans" = "y" -o "$ans" = "Y" ]; then
                print "\n\n\n\n\n "
                print "CAUTION: You may lose all the changes made to file!!"
                print -n "Do you really want to unlock the file <y/n>? [n]: "
                read ans
                if [ "$ans" = "y" -o "$ans" = "Y" ]; then
                        break
                else
                        exit
                fi
        else
                print "\n\nWrong entry. Try again..."
                sleep 1
        fi
done

if [ -e $lockfile ]; then
        \rm -f $lockfile
        print "\nDone $cmdname"
else
        print "\nFile $1 is NOT locked by anyone"
        print " "
fi

4.6 slist

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

Save this file as text file and chmod a+rx on it.


#!/bin/ksh

# CVS program slist
# Program to list all edited source files from CVS

#cmdname=`basename $0`

#echo "no of params : " $#
#echo "all args : " $@

recurse_flag=""

if [ "$1" = "" ]; then
        dir=.
        recurse_flag=""
else
        dir=$@
        recurse_flag=" -prune "
fi

FOUT=slist_temporary_file.out

\rm -f $FOUT

find $dir  $recurse_flag -type f -exec ls -ltr {} \; \
| grep -v "/CVS/" \
| grep ^\-rw \
| grep -v \\.o \
| grep -v \\.log \
| grep -v \\.out \
| grep -v \\.pid \
| awk '{ if ($NF != "tags") print $0 }' \
| awk '{ if ($NF != "a.out") print $0 }' \
| awk '{ if ($NF != "core") print $0 }' \
| awk '{ print $NF }' > $FOUT

aa=`cat $FOUT`
\rm -f $FOUT

for ii in $aa ; do
        ftype=" "
        ftype=`file $ii | awk '{print $2 }' `

        # find . -type f -exec file {} \;
        # 1)ELF 2)commands 3)[nt]roff, 4)c 5)English  6)executable
        # 7)ascii 8)current 9)empty
        # Binaries are ELF, lib.a are current
        #
        if [ "$ftype" = "ascii" -o "$ftype" = "commands" \
                -o "$ftype" = "[nt]roff," -o "$ftype" = "c" -o "$ftype" = "data" \
                -o "$ftype" = "English" -o "$ftype" = "executable" ]; then
                pcfile=` echo $ii | cut -d'.' -f1`
                pcfile=${pcfile}".pc"
                if [ ! -f $pcfile ]; then
                        ls -l $ii
                else
                        if [ "$ii" = "$pcfile" ]; then
                                ls -l $ii
                        fi
                fi
        fi
done;

#| grep -v ^\-rwx \

#ls -l | grep ^\-rw | grep -v \\.o
#ls -l | grep ^\-rw | grep -v \\.o | awk '{ if ($NF != "tags") print $0 }'
#ls -l | grep ^\-rw | grep -v ^\-rwx | grep -v \\.o |  awk '{ if ($NF != "tags") print $0 }' | awk '{ if ($NF != "core") print $0 }'

#print "\nDone $cmdname. $cmdname successful"
#print "\nTip (Usage): $cmdname <filename>\n"

4.7 sinfo

NOT