#!/bin/ksh #========================================================== # Procedure: book.ksh # Shell script for booking in/out files # from SCCS source code control. # Syntax: bookin # bookout # bookread [version] # bookundo # bookinfo # booklist # bookhelp # (commands are Unix sym links to this file) # Author: Dennis Adams # Date: 19-Nov-1999 # Functions: # BOOKDIFF # does a 'diff' listing between the current file # BOOKHELP # displays syntax info. # BOOKIN # Allows users to "book in" a file to SCCS # If the first time, create an initial entry, # otherwise do a normal SCCS delget. # BOOKOUT # "bookout" a file for editing. # BOOKREAD # get out a read-only copy of a file # BOOKUNDO # undoes the existing editing feature. # BOOKINFO # display detailed file information # BOOKLIST # Lists file(s) in SCCS # # #========================================================== # # FUNCTION BOOKDIFF - difference listing between file and SCCS # function bookdiff { echo BOOKDIFF: differences between file and SCCS if [ -z "$1" ] then echo "Usage bookdiff " return fi myfile="$1" # check if it is already in SCCS... if [ -f $PROJECTDIR/SCCS/s.$myfile ] then # SCCS commands to do the difference listing echo $myfile found in SCCS $SCCSCMD diffs $myfile echo end of difference listing else echo $myfile does not exist in SCCS echo .. book it in first ! fi } # End of Function BOOKDIFF # # FUNCTION BOOKIN - Book in a file. # function bookin { echo BOOKIN: books a file into SCCS. if [ -z "$1" ] then echo "Usage bookin " return fi myfile="$1" # Look for the file ... if [ -f $myfile ] then : else echo $myfile not found - cannot book it in return fi # check if it has not already been done... if [ -f $PROJECTDIR/SCCS/s.$myfile ] then # SCCS commands to book in latest version echo $myfile already in SCCS echo Book in latest version ... $SCCSCMD delget $myfile else # SCCS commands to create first version... echo $myfile does not exist in SCCS echo Create new entry = version 1... $SCCSCMD create $myfile rm ,$myfile fi chmod +x $myfile echo File $myfile booked into SCCS control } # End of Function BOOKIN # # FUNCTION BOOKOUT - Book out a file. # function bookout { echo BOOKOUT: books a file out of SCCS. if [ -z "$1" ] then echo "Usage bookout " return fi myfile="$1" # check if it is already in SCCS... if [ -f $PROJECTDIR/SCCS/s.$myfile ] then # SCCS commands to book out latest version echo $myfile found in SCCS echo Book out latest version ... $SCCSCMD edit $myfile chmod +x $myfile echo File $myfile booked out of SCCS control else echo $myfile does not exist in SCCS echo .. book it in first ! fi } # End of Function BOOKOUT # # FUNCTION BOOKREAD - Get out a read-only copy of a file. # function bookread { echo BOOKREAD: gets a read-only copy of a file out of SCCS. if [ -z "$1" ] then echo "Usage bookread [version] " return fi myfile="$1" if [ -z "$2" ] then curver=1 else curver=$2 fi # check if it is being edited.. if [ -f $PROJECTDIR/SCCS/p.$myfile ] then echo $myfile is being edited ! echo do you really want to get a read-only copy as well ? read yn if [ "$yn" != "y" ] then return fi fi # check if it is already in SCCS... if [ -f $PROJECTDIR/SCCS/s.$myfile ] then # SCCS commands to book out latest read-only version echo $myfile found in SCCS echo Get out latest read-only copy... if [ "$curver" == "1" ] then $SCCSCMD get $myfile else $SCCSCMD get -r $curver $myfile fi chmod +x $myfile echo read-only $myfile created from SCCS copy else echo $myfile does not exist in SCCS fi } # End of Function BOOKREAD # # FUNCTION BOOKUNDO - Book in a file. # function bookundo { echo BOOKUNDO: aborts a current file SCCS edit session. if [ -z "$1" ] then echo "Usage bookundo " return fi myfile="$1" # check if it is in SCCS or not.. if [ ! -f $PROJECTDIR/SCCS/s.$myfile ] then echo $myfile does not exist in SCCS echo unable to abort session return fi # check if it is being edited if [ ! -f $PROJECTDIR/SCCS/p.$myfile ] then echo $myfile not being edited in SCCS echo unable to abort session return fi # SCCS commands to abort bookout echo $myfile found in SCCS echo Abort editing of latest version ... $SCCSCMD unedit $myfile chmod +x $myfile echo Readonly $myfile booked out of SCCS control } # End of Function BOOKUNDO # # # FUNCTION BOOKINFO - information on the SCCS stats for a file # function bookinfo { echo BOOKINFO: history information for a file in SCCS. if [ -z "$1" ] then echo "Usage bookinfo " return fi myfile="$1" # check if it is already in SCCS... if [ -f $PROJECTDIR/SCCS/s.$myfile ] then # SCCS commands to report on the file echo "Current Status:" echo "===============" if [ -f $PROJECTDIR/SCCS/p.$myfile ] then echo "- being edited: " cat $PROJECTDIR/SCCS/p.$myfile else echo "- booked in." fi echo "History :" echo "=========" $SCCSCMD prt $myfile | awk \ '{if ($0 != "") print $0}' else echo $myfile does not exist in SCCS fi } # End of Function BOOKINFO # # # FUNCTION BOOKLIST - List info # function booklist { echo BOOKLIST: SCCS info listing date echo Directory = $PROJECTDIR/SCCS echo Summary of Files in SCCS directory. echo =================================== ls $PROJECTDIR/SCCS/s.* | cut -d. -f2-7 # SCCS commands to list info echo SCCS info. echo ========== $SCCSCMD info echo End of listing } # End of Function BOOKLIST # # # FUNCTION BOOKHELP - syntax help # function bookhelp { echo "Syntax: " echo "bookdiff file" echo " - 'diff' listing between the current file and SCCS copy" echo "bookin file" echo " -allows users to 'book in' a file to SCCS" echo " -if the first time, create an initial entry, " echo " otherwise do a normal SCCS delget." echo "bookout file" echo " -'bookout' a file for editing." echo "bookundo file" echo " -abort the current file editing and get previous read-only version." echo "bookread file [version]" echo " get out a read-only copy of a file" echo "bookhelp" echo " -display syntax info" echo "bookinfo file" echo " -display detailed file information" echo "booklist " echo " -lists file(s) in SCCS " echo "[all commands are Unix sym links to book.ksh]" echo " " echo "book.ksh install" echo " - sets up the symbolic links required to run this" } # End of Function BOOKHELP # # # FUNCTION BOOKINSTALL - set up symbolic links # function bookinstall { echo Installing book.ksh... for bookalias in bookdiff bookin bookhelp bookinfo booklist bookout bookread bookundo do echo linking $bookalias to book.ksh... ln -s book.ksh $bookalias done echo ...Installation complete. } # End of Function BOOKINSTALL # #========================================================== # MAIN CODE #========================================================== echo SCCS Booking System: # # root filesystem for SCCS sub-directory # change this to your machine-wide value... PROJECTDIR=/usr/projects export PROJECTDIR # # command to run SCCS binary # your own system may have a different location... SCCSCMD=/usr/ccs/bin/sccs export SCCSCMD # # argument handling and dispatcher... cmd=`basename $0` case $cmd in book.ksh) if [ -z "$1" ] then bookhelp else if [ "$1" == "install" ] then bookinstall else bookhelp fi fi ;; bookdiff) bookdiff $*;; bookhelp) bookhelp ;; bookin) bookin $*;; bookinfo) bookinfo $*;; booklist) booklist ;; bookout) bookout $*;; bookread) bookread $*;; bookundo) bookundo $*;; esac exit #