allbery@uunet.UU.NET ( comp.sources.misc) (09/21/90)
Posting-number: Volume 14, Issue 101 Submitted-by: bts!bill Archive-name: sccs_b/part01 I have been using the following sccs scripts for at least a year with no changes or problems. These are intended to provide a simple front end to the basic sccs admin, edit, get and diff operations. I have added an install operation that just "makes sure" the desired file is present. Each script makes a backup source file copy prior to attempting any sccs operations. --------- cut here ----------------------------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: README Make_Templ Makefile sccs_admin sccs_delta sccs_edit # sccs_get sccs_install # Wrapped by bill@bts on Sun Sep 16 20:09:50 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(876 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' The following shell scripts are a simple, user friendly front end to SYS V.3 sccs. The assumed directory structure is as follows: X X ${PROJECTDIR:-./} X | SCCS X | src_backup X The directory SCCS contains all of the p.* and s.* files created by sccs. XEach source file is copied to the src_backup directory BEFORE any SCCS operations are attempted. Attempts to do an sccs operation that might result in a trashed sccs file are aborted with a message which identifies the problem and recommends corrective action. If an sccs operation does somehow trash the SCCS file, then the latest source version will always be available from the src_backup directory. X A template Makefile is included to illustrate the typical use of these sccs scripts X Bill Hatch Coleman Research Corporation X14504 Greenview Drive Suite 500 Laurel, Maryland 20708 Phone (301)470-3839 XFAX (301)776-5461 END_OF_FILE if test 876 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'Make_Templ' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Make_Templ'\" else echo shar: Extracting \"'Make_Templ'\" \(7067 characters\) sed "s/^X//" >'Make_Templ' <<'END_OF_FILE' X# @(#)Makefile. X# X# Makefile (a Makefile template) X# X# PROGRAM(s) : X# X# LIBRARY(s) : X# X# DATE : X# X# AUTHOR : W.Hatch X# X# PROJECT : WEH Software X# X# COMPANY : Coleman Research X# 14504 Greenview Drive Suite 500 X# Laurel, Maryland 20708 X# Phone (301)470-3839 X# FAX (301)776-5461 X# X# X# This Makefile template assumes that the following shell scripts X# are installed in one of the user's PATH directories X# X# sccs_admin arg1 arg2 ... X# sccs_get arg1 arg2 ... X# sccs_delta arg1 arg2 ... X# sccs_edit arg1 arg2 ... X# sccs_install arg1 arg2 .. X# X# where arg1 arg2 .... are the names of SRC, SCRIPT and HEADERS X# files on which the sccs operations will be performed. X# X# These scripts are used to "hide" the differences between System V.3 X# and BSD 4.3 SCCS utility interfaces. X#-------------------------------------------------------------------------- X X#-------------------------------------------------------------------------- X# 1. define symbolic constants X# X# root directory for this activity ROOT=/usr/local X# X# relocatable library directory LIBDIR=$(ROOT)/lib X# X# target directory for executables BIN=$(ROOT)/bin X# X# documentation target directory MAN=$(ROOT)/man MAN1=$(MAN)/man1 MAN3=$(MAN)/man3 X# X# target directory for header files INCLUDE=$(ROOT)/include X# X# list of relocatable libraries required in link step LIBS=$(ROOT)/lib/libdbug.a \ X /usr/local/lib/gcc-gnulib /lib/libm.a X# X# list of header files, subject to change, on which *.o depend HEADERS= X# X# list of source files to be compiled SRC= X# X# list of object files to be linked OBJ= X# X# compile options CC=cc X#CC=gcc AS=/bin/as X#LD=/bin/ld /lib/crt0.o X#LD=gcc LD=/bin/ld AR=/bin/ar GCFLAGS=-W -Wunused -Wcomment -Wshadow -c -g -I$(INCLUDE) -B/usr/local/lib/gcc- CFLAGS=-g -I$(INCLUDE) -I./ -DM_XENIX X# X# link/load flags LFLAGS= X# X# executable file to be created (assume only 1) XEXE= X# X# list of shell script files maintained with this makefile SCRIPT= X# X# list of manual pages MANPAGES= X# X# list of all junk files that might occur in this directory JUNK=core a.out JOURNAL LINT paste.txt error.log dbg_jnl* CHECK CCHK CFLOW \ X MCCABE KDSI *PRINT GLINT CXREF TJ *.s tr.* X X#pretty_printer= *** YOUR FAVORITE PRETTY PRINTER ***** X#-------------------------------------------------------------------------- X# 2. link and load to create the executable X#-------------------------------------------------------------------------- X$(EXE): $(OBJ) $(LIBS) X $(CC) -o $(EXE) $(OBJ) $(LIBS) X X#-------------------------------------------------------------------------- X# 3. install all objects of this make X#-------------------------------------------------------------------------- install: $(EXE) $(SCRIPT) X strip $(EXE) X for i in $(EXE) $(SCRIPT); do \ X chmod ugo+x $$i; \ X cp $$i $(BIN); \ X done X rm $(EXE) X X#-------------------------------------------------------------------------- X# 4. lint for syntax check on all C source, headers X#-------------------------------------------------------------------------- LINT: $(SRC) $(HEADERS) X lint -DM_XENIX -I./ -I$(INCLUDE) $(SRC) >LINT 2>LINT2 X cat LINT2 >> LINT X rm LINT2 X GLINT: $(SRC) $(HEADERS) X gcc $(GCFLAGS) $(SRC) >GLINT 2>GLINT2 X cat GLINT2 >> GLINT X rm -f GLINT2 X#-------------------------------------------------------------------------- X# 5. tidy up by getting rid of all junk files X#-------------------------------------------------------------------------- tidy: X rm -f $(JUNK) X X#-------------------------------------------------------------------------- X# 6. clean up by removing all vestiges of previous makes X#-------------------------------------------------------------------------- clean: tidy admin delta X rm -f $(EXE) X rm -f *.o *.s X X#-------------------------------------------------------------------------- X# 7. uninstall all installed targets of this make X# (remove any installed manual pages also) X#-------------------------------------------------------------------------- uninstall: clean X for i in $(EXE) $(SCRIPT); do; \ X rm -f $(BIN)/$$i; \ X done X for i in $(MANPAGES); do; \ X rm -f $(MAN1)/$$i; \ X done X X#-------------------------------------------------------------------------- X# 8. individual dependencies for C source files as per the following X# example: X# X# foobar.c: SCCS/s.foobar.c X# sccs_get foobar.c X# X#-------------------------------------------------------------------------- X X#-------------------------------------------------------------------------- X# 9. individual dependencies for relocatable object files as per X# the following example: X# X# foobar.o: foobar.c $(HEADERS) X# cc -O -c foobar.c X# X#-------------------------------------------------------------------------- X#.c.o: X# $(CC) $(CFLAGS) -c -S $< X# $(AS) $*.s X X$(SRC) $(HEADERS): X sccs_install $(SRC) $(HEADERS) X X#-------------------------------------------------------------------------- X# 10. individual dependencies for shell script and on line documentation X# as per the following example: X# X# textfile: SCCS/s.textfile X# sccs_get textfile X# X#-------------------------------------------------------------------------- X#-------------------------------------------------------------------------- X# 11. initialize SCCS administration of the source files X#-------------------------------------------------------------------------- admin: X sccs_admin $(SRC) $(HEADERS) $(SCRIPT) $(MANPAGES) X X X#-------------------------------------------------------------------------- X# 12. edit - get all of the source files ready to edit X#-------------------------------------------------------------------------- edit: X sccs_edit $(SRC) $(SCRIPT) $(HEADERS) $(MANPAGES) X X#-------------------------------------------------------------------------- X# 13. get - get all of source files in read only form X#-------------------------------------------------------------------------- get: X sccs_get $(SRC) $(SCRIPT) $(HEADERS) $(MANPAGES) X X#-------------------------------------------------------------------------- X# 14. delta - SCCS delta all source X#-------------------------------------------------------------------------- delta: X sccs_delta $(SRC) $(SCRIPT) $(HEADERS) $(MANPAGES) X X#-------------------------------------------------------------------------- X# 14. print all source files X#-------------------------------------------------------------------------- print: $(SRC) $(HEADERS) LINT CFLOW CXREF X ${pretty_printer} CFLOW $(HEADERS) $(SRC) Makefile CXREF LINT X X#-------------------------------------------------------------------------- X# 16. manual page installation X# copy manual pages to $(MAN1) and $(MAN3) X#-------------------------------------------------------------------------- manual: $(MANPAGES) X cp $(MANPAGES) $(MAN1) X X#-------------------------------------------------------------------------- X# 18. static analysis of code X#-------------------------------------------------------------------------- CFLOW: $(SRC) $(HEADERS) X cflow -I$(INCLUDE) -I./ -ix $(SRC) >CFLOW X CXREF: $(SRC) $(HEADERS) X cxref -I$(INCLUDE) -I./ -DM_XENIX $(SRC) >CXREF X END_OF_FILE if test 7067 -ne `wc -c <'Make_Templ'`; then echo shar: \"'Make_Templ'\" unpacked with wrong size! fi # end of 'Make_Templ' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(1890 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# sccsid="%W% %G% %U%"; X# X# Makefile.sccs X# X# PROGRAM(s) : sccs_admin, sccs_edit, sccs_get, sccs_delta, sccs_install X# AUTHOR : W. Hatch X# Coleman Research X# 14504 Greenview Drive Suite 500 X# Laurel, Maryland 20708 X# (301)470-3839 X# uunet!bts!bill X# DATE : 7/19/88 X# PROJECT : WEH Software X# X# This Makefile template assumes that the following shell scripts X# are installed in one of the user's PATH directories X# X#-------------------------------------------------------------------------- X X#-------------------------------------------------------------------------- X# 1. define symbolic constants X# X# root directory for this activity ROOT=/usr/local X# X# target directory for executables BIN=$(ROOT)/bin X# X# documentation target directory DOCINSTALL=$(ROOT)/doc X# X# list of shell script files maintained with this makefile SCRIPT= sccs_admin sccs_delta sccs_edit sccs_get sccs_install X# X# list of all junk files that might occur in this directory JUNK=core a.out JOURNAL LINT paste.txt error.log dbg_jnl* X X X#-------------------------------------------------------------------------- X# 4. install all objects of this make X#-------------------------------------------------------------------------- install: $(SCRIPT) $(DOC) X for i in $(SCRIPT); do \ X chmod ugo+x $$i; \ X cp $$i $(BIN); \ X done X #cp $(DOC) $(DOCINSTALL) X X#-------------------------------------------------------------------------- X# 8. uninstall all installed targets of this make X#-------------------------------------------------------------------------- uninstall: X for i in $(SCRIPT); do; \ X rm -f $(BIN)/$$i; \ X done X #for i in $(DOC); do; \ X # rm -f $(DOCINSTALL)/$$i; \ X #done X X#-------------------------------------------------------------------------- X# 15. print all source X#-------------------------------------------------------------------------- print: X pf $(SCRIPT) Makefile END_OF_FILE if test 1890 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'sccs_admin' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sccs_admin'\" else echo shar: Extracting \"'sccs_admin'\" \(2507 characters\) sed "s/^X//" >'sccs_admin' <<'END_OF_FILE' X#!/bin/sh X#+++ X# NAME : sccs_admin X# PURPOSE : create SCCS files if they do not already exist X# AUTHOR : W. Hatch X# Coleman Research X# 14504 Greenview Drive Suite 500 X# Laurel, Maryland 20708 X# (301)470-3839 X# uunet!bis!bill X# DATE : 7/18/88 X# PROJECT : WEH SOFTWARE X# USAGE : sccs_admin file1 file2 .... X# RESTRICTIONS : file name length <= 12 characters for Unix V.3 X#--- X#------------------------------------------------------------------------ X# if no command line arguments then abort with usage instructions X#------------------------------------------------------------------------ usage=" " case $# in X 0) echo $usage X exit;; esac X#------------------------------------------------------------------------ X# if project directory is not defined then make it the current directory X#------------------------------------------------------------------------ PROJECTDIR=${PROJECTDIR-.} X#------------------------------------------------------------------------ X# define sccs and source backup directories relative to project directory X#------------------------------------------------------------------------ SCCS=$PROJECTDIR/SCCS BACKUP=$PROJECTDIR/src_backup export SCCS PROJECTDIR BACKUP X#------------------------------------------------------------------------ X# make sure sccs and source backup directories exist X#------------------------------------------------------------------------ if test ! -d $SCCS then X mkdir $SCCS else X echo "$SCCS directory exists." fi if test ! -d $BACKUP then X mkdir $BACKUP else X echo "$BACKUP directory exists." fi X#------------------------------------------------------------------------ X# for each source file not already under sccs put it under sccs X#------------------------------------------------------------------------ for i do X if test ! -f $SCCS/s.$i X then X #------------------------------------------------------- X # if file $i does not exist then abort X #------------------------------------------------------- X if test ! -s $i X then X echo "$i does not exist or is zero length; " X echo "sccs_admin $i aborted" X echo "look in src_backup or elsewhere for $i source" X exit 1 X fi X #------------------------------------------------------- X # backup before sccs removes original source file X #------------------------------------------------------- X cp $i $BACKUP/$i X admin -i$i $SCCS/s.$i X rm $i X echo "admin of $i OK." X else X echo "$SCCS/s.$i exists; admin for $i aborted" X echo "$i is already under sccs." X fi done END_OF_FILE if test 2507 -ne `wc -c <'sccs_admin'`; then echo shar: \"'sccs_admin'\" unpacked with wrong size! fi chmod +x 'sccs_admin' # end of 'sccs_admin' fi if test -f 'sccs_delta' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sccs_delta'\" else echo shar: Extracting \"'sccs_delta'\" \(2728 characters\) sed "s/^X//" >'sccs_delta' <<'END_OF_FILE' X#!/bin/sh X#+++ X# NAME : sccs_delta X# PURPOSE : introduce changes to a file under SCCS X# AUTHOR : W. Hatch X# Coleman Research X# 14504 Greenview Drive Suite 500 X# Laurel, Maryland 20708 X# (301)470-3839 X# uunet!bis!bill X# DATE : 7/18/88 X# PROJECT : WEH SOFTWARE X# USAGE : sccs_delta file1 file2 .... X# RESTRICTIONS : file name lengths must be <= 12 characters X#--- X#------------------------------------------------------------------------ X# if no command line arguments then abort with usage instructions X#------------------------------------------------------------------------ usage="sccs_delta file1 file2 .... " case $# in X 0) echo $usage X exit;; esac X#------------------------------------------------------------------------ X# if project directory is not defined then make it the current directory X#------------------------------------------------------------------------ PROJECTDIR=${PROJECTDIR-.} X#------------------------------------------------------------------------ X# define sccs and source backup directories relative to project directory X#------------------------------------------------------------------------ SCCS=$PROJECTDIR/SCCS BACKUP=$PROJECTDIR/src_backup export SCCS PROJECTDIR BACKUP X#------------------------------------------------------------------------ X# verify existence of sccs and source backup directories X#------------------------------------------------------------------------ if test ! -d $SCCS then X echo "$SCCS does not exist ; " X echo "use sccs_admin to create $SCCS" X exit 1 fi if test ! -d $BACKUP then X echo "$BACKUP does not exist;" X echo "use sccs_admin to create $BACKUP." X exit 1 fi X X#------------------------------------------------------------------------ X# perform delta for each requested file that is under sccs X#------------------------------------------------------------------------ for i do X if test -s $i X then X if test -f $SCCS/s.$i X then X #------------------------------------------------------- X # backup before sccs removes original source file X #------------------------------------------------------- X if test -w $i X then X cp $i $BACKUP/$i X echo "delta -y $SCCS/s.$i" X delta -y"" $SCCS/s.$i X else X echo "no writable $i exists; abort sccs_delta" X fi X else X echo "$SCCS/s.$i does not exist; " X echo "you can not delta a file that is not under sccs control." X echo "use assc_admin to place $i under sccs control." X fi X else X echo "$i does not exist or is zero size; abort sccs_delta" X echo "see rmdel(1) to remove previous deltas and " X echo "reconstruct the file from SCCS/s.$i or get a" X echo "copy of the file from src_backup. " X echo "BE CAREFUL not to blow away all copies of $i" X fi X done X END_OF_FILE if test 2728 -ne `wc -c <'sccs_delta'`; then echo shar: \"'sccs_delta'\" unpacked with wrong size! fi chmod +x 'sccs_delta' # end of 'sccs_delta' fi if test -f 'sccs_edit' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sccs_edit'\" else echo shar: Extracting \"'sccs_edit'\" \(2542 characters\) sed "s/^X//" >'sccs_edit' <<'END_OF_FILE' X#!/bin/sh X#+++ X# NAME : sccs_edit X# PURPOSE : get read/write version of files under SCCS X# AUTHOR : W. Hatch X# Coleman Research X# 14504 Greenview Drive Suite 500 X# Laurel, Maryland 20708 X# (301)470-3839 X# uunet!bis!bill X# DATE : 7/18/88 X# PROJECT : WEH SOFTWARE X# USAGE : sccs_edit file1 file2 .... X# RESTRICTIONS : file name lengths must be <= 12 characters X#--- X#------------------------------------------------------------------------ X# if no command line arguments then abort with usage instructions X#------------------------------------------------------------------------ usage="sccs_edit file1 file2 .... " case $# in X 0) echo $usage X exit;; esac X#------------------------------------------------------------------------ X# if project directory is not defined then make it the current directory X#------------------------------------------------------------------------ PROJECTDIR=${PROJECTDIR-.} X#------------------------------------------------------------------------ X# define sccs and source backup directories relative to project directory X#------------------------------------------------------------------------ SCCS=$PROJECTDIR/SCCS export SCCS PROJECTDIR X#------------------------------------------------------------------------ X# verify existence of sccs directory X#------------------------------------------------------------------------ if test ! -d $SCCS then X echo "$SCCS does not exist ; " X echo "use sccs_admin to create $SCCS." X exit 1 fi X#------------------------------------------------------------------------ X# get each requested file in editable form if it exists under sccs X#------------------------------------------------------------------------ for i do X if test -s $SCCS/s.$i X then X #------------------------------------------------------- X # do not sccs_edit $i if a writable version exists X #------------------------------------------------------- X if test -w $i X then X echo "writable $i exists; sccs_edit $i aborted" X else X #------------------------------------------------- X # if a (non-writable) version exists then remove it X #------------------------------------------------- X if test -f $i X then X rm -f $i X fi X echo "get -p -e -t $SCCS/s.$i > $i" X get -p -e -t $SCCS/s.$i > $i X fi X else X echo "sccs_edit of $i ABORTED" X echo "$SCCS/s.$i does not exist or is zero length; " X echo "if SCCS/s.$i exists then delete it and retrieve $i" X echo "from src_backup or elsewhere and" X echo "use sccs_admin to place $i under sccs administration." X fi done END_OF_FILE if test 2542 -ne `wc -c <'sccs_edit'`; then echo shar: \"'sccs_edit'\" unpacked with wrong size! fi chmod +x 'sccs_edit' # end of 'sccs_edit' fi if test -f 'sccs_get' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sccs_get'\" else echo shar: Extracting \"'sccs_get'\" \(2593 characters\) sed "s/^X//" >'sccs_get' <<'END_OF_FILE' X#!/bin/sh X#+++ X# NAME : sccs_get X# PURPOSE : get read only version of files under SCCS X# AUTHOR : W. Hatch X# Coleman Research X# 14504 Greenview Drive Suite 500 X# Laurel, Maryland 20708 X# (301)470-3839 X# uunet!bis!bill X# DATE : 7/18/88 X# PROJECT : WEH SOFTWARE X# USAGE : sccs_get file1 file2 .... X# RESTRICTIONS : file name lengths must be <= 12 characters X#--- X#------------------------------------------------------------------------ X# if no command line arguments then abort with usage instructions X#------------------------------------------------------------------------ usage="sccs_get file1 file2 .... " case $# in X 0) echo $usage X exit;; esac X#------------------------------------------------------------------------ X# if project directory is not defined then make it the current directory X#------------------------------------------------------------------------ PROJECTDIR=${PROJECTDIR-.} X#------------------------------------------------------------------------ X# define sccs and source backup directories relative to project directory X#------------------------------------------------------------------------ SCCS=$PROJECTDIR/SCCS BACKUP=$PROJECTDIR/src_backup export SCCS PROJECTDIR BACKUP X#------------------------------------------------------------------------ X# verify existence of sccs and source backup directories X#------------------------------------------------------------------------ if test ! -d $SCCS then X echo "$SCCS does not exist ; " X echo "use sccs_admin to create $SCCS" X exit 1 fi if test ! -d $BACKUP then X echo "$BACKUP does not exist;" X echo "use sccs_admin to create $BACKUP." X exit 1 fi X#------------------------------------------------------------------------ X# get each requested file in read only form if it exists under sccs X#------------------------------------------------------------------------ for i do X #---------------------------------------------------------------- X # abort the get if a writable version exists X # otherwise the file in $PROJECTDIR is trashed X #---------------------------------------------------------------- X if test -w $i X then X echo "$i exists for editing; abort sccs_get of $i" X echo "make sure $i is not zero length and" X echo "use sccs_admin or sccs_delta on writable version of $i" X echo "before attempting another sccs_get." X else X if test -s $SCCS/s.$i X then X echo "get -p $SCCS/s.$i > $i; chmod ugo-w $i" X get -p $SCCS/s.$i > $i X chmod ugo-w $i X else X echo "$SCCS/s.$i does not exist or is zero length; " X echo "use sccs_admin to place $i under sccs." X X fi X fi done X END_OF_FILE if test 2593 -ne `wc -c <'sccs_get'`; then echo shar: \"'sccs_get'\" unpacked with wrong size! fi chmod +x 'sccs_get' # end of 'sccs_get' fi if test -f 'sccs_install' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sccs_install'\" else echo shar: Extracting \"'sccs_install'\" \(838 characters\) sed "s/^X//" >'sccs_install' <<'END_OF_FILE' X#!/bin/sh X#+++ X# NAME : sccs_install X# X# PURPOSE : check for presence of a file and, if not present then X# sccs_get to install a read only version of the file X# if file is present then do nothing X# X# USAGE : sccs_install file1 file2 .... X# X# DATE : Sat Mar 10 15:17:21 EST 1990 X# X# AUTHOR : W. Hatch X# X# PROJECT : WEH Software X# X# COMPANY : Coleman Research X# 14504 Greenview Drive Suite 500 X# Laurel, Maryland 20708 X# Phone (301)470-3839 X# FAX (301)776-5461 X# X#------------------------------------------------------------------------ X# if no command line arguments then abort with usage instructions X#------------------------------------------------------------------------ usage="sccs_install file1 file2 .... " case $# in X 0) echo $usage X exit;; esac X for i do X if [ ! -f $i ] X then X sccs_get $i X fi done END_OF_FILE if test 838 -ne `wc -c <'sccs_install'`; then echo shar: \"'sccs_install'\" unpacked with wrong size! fi chmod +x 'sccs_install' # end of 'sccs_install' fi echo shar: End of shell archive. exit 0