Home | History | Annotate | Line # | Download | only in contrib
sandbox_status.sh revision 1.1
      1  1.1  christos #! /bin/sh
      2  1.1  christos #
      3  1.1  christos #  Copyright (C) 1995-2005 The Free Software Foundation, Inc.
      4  1.1  christos #
      5  1.1  christos #  This program is free software; you can redistribute it and/or modify
      6  1.1  christos #  it under the terms of the GNU General Public License as published by
      7  1.1  christos #  the Free Software Foundation; either version 2, or (at your option)
      8  1.1  christos #  any later version.
      9  1.1  christos #
     10  1.1  christos #  This program is distributed in the hope that it will be useful,
     11  1.1  christos #  but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  1.1  christos #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  1.1  christos #  GNU General Public License for more details.
     14  1.1  christos #
     15  1.1  christos # sandbox_status - identify files added, changed, or removed 
     16  1.1  christos #                  in CVS working directory
     17  1.1  christos #
     18  1.1  christos # Contributed by Lowell Skoog <fluke!lowell (at] uunet.uu.net>
     19  1.1  christos # 
     20  1.1  christos # This program should be run in a working directory that has been
     21  1.1  christos # checked out using CVS.  It identifies files that have been added,
     22  1.1  christos # changed, or removed in the working directory, but not "cvs
     23  1.1  christos # committed".  It also determines whether the files have been "cvs
     24  1.1  christos # added" or "cvs removed".  For directories, it is only practical to
     25  1.1  christos # determine whether they have been added.
     26  1.1  christos 
     27  1.1  christos name=sandbox_status
     28  1.1  christos changes=0
     29  1.1  christos 
     30  1.1  christos # If we can't run CVS commands in this directory
     31  1.1  christos cvs status . > /dev/null 2>&1
     32  1.1  christos if [ $? != 0 ] ; then
     33  1.1  christos 
     34  1.1  christos     # Bail out
     35  1.1  christos     echo "$name: there is no version here; bailing out" 1>&2
     36  1.1  christos     exit 1
     37  1.1  christos fi
     38  1.1  christos 
     39  1.1  christos # Identify files added to working directory
     40  1.1  christos for file in .* * ; do
     41  1.1  christos 
     42  1.1  christos     # Skip '.' and '..'
     43  1.1  christos     if [ $file = '.' -o $file = '..' ] ; then
     44  1.1  christos 	continue
     45  1.1  christos     fi
     46  1.1  christos 
     47  1.1  christos     # If a regular file
     48  1.1  christos     if [ -f $file ] ; then
     49  1.1  christos 	if cvs status $file | grep -s '^From:[ 	]*New file' ; then
     50  1.1  christos 	    echo "file added:      $file - not CVS committed"
     51  1.1  christos 	    changes=`expr $changes + 1`
     52  1.1  christos 	elif cvs status $file | grep -s '^From:[ 	]*no entry for' ; then
     53  1.1  christos 	    echo "file added:      $file - not CVS added, not CVS committed"
     54  1.1  christos 	    changes=`expr $changes + 1`
     55  1.1  christos 	fi
     56  1.1  christos 
     57  1.1  christos     # Else if a directory
     58  1.1  christos     elif [ -d $file -a $file != CVS.adm ] ; then
     59  1.1  christos 
     60  1.1  christos 	# Move into it
     61  1.1  christos 	cd $file
     62  1.1  christos 
     63  1.1  christos 	# If CVS commands don't work inside
     64  1.1  christos 	cvs status . > /dev/null 2>&1
     65  1.1  christos 	if [ $? != 0 ] ; then
     66  1.1  christos 	    echo "directory added: $file - not CVS added"
     67  1.1  christos 	    changes=`expr $changes + 1`
     68  1.1  christos 	fi
     69  1.1  christos 
     70  1.1  christos 	# Move back up
     71  1.1  christos 	cd ..
     72  1.1  christos     fi
     73  1.1  christos done
     74  1.1  christos 
     75  1.1  christos # Identify changed files
     76  1.1  christos changedfiles=`cvs diff | egrep '^diff' | awk '{print $3}'`
     77  1.1  christos for file in $changedfiles ; do
     78  1.1  christos     echo "file changed:    $file - not CVS committed"
     79  1.1  christos     changes=`expr $changes + 1`
     80  1.1  christos done
     81  1.1  christos 
     82  1.1  christos # Identify files removed from working directory
     83  1.1  christos removedfiles=`cvs status | egrep '^File:[ 	]*no file' | awk '{print $4}'`
     84  1.1  christos 
     85  1.1  christos # Determine whether each file has been cvs removed
     86  1.1  christos for file in $removedfiles ; do
     87  1.1  christos     if cvs status $file | grep -s '^From:[ 	]*-' ; then
     88  1.1  christos 	echo "file removed:    $file - not CVS committed"
     89  1.1  christos     else
     90  1.1  christos 	echo "file removed:    $file - not CVS removed, not CVS committed"
     91  1.1  christos     fi
     92  1.1  christos     changes=`expr $changes + 1`
     93  1.1  christos done
     94  1.1  christos 
     95  1.1  christos exit $changes
     96