1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#! /bin/sh
#
# cvsrmvend - 'cvs rm' vendor removed files
#
# (c) Copyright 1998 by Greg A. Woods <woods@planix.com>
#
# Freely redistibutable.
# All other rights reserved.
# Return all fixes/modifications to <woods@planix.com>.
#
#ident "@(#)LOCAL:cvsrmvend.sh 1.2 98/07/02 23:08:31 (woods)"
# This should find the VENDOR-BRANCH-TAG:
#
# cvs -q log -h | sed -n -e 's/^ *\([^:]*\): 1\.1\.1$/\1/p' | head -1
#
# This might find the most recent VENDOR-RELEASE-TAG, if we knew
# "a-file"'s name, i.e. a file that was sure to be vendor branched,
# which of course would be the one in which the VENDOR-BRANCH-TAG was
# found above...:
#
# cvs log -h a-vendor-file | sed -n 's/^ \([^:]*\): .*$/\1/p' | head -1
DEBUG=false
VERBOSE=false
DOCOMMIT=false
SPEWREMOVED=false
argv0=`basename $0`
USAGE="Usage: $argv0 [-clv] VENDOR-BRANCH-TAG VENDOR-RELEASE-TAG"
HELP="$USAGE
-c do the commit of the removed files too.
-l print the list of removed files on stdout.
-v be verbose.
eg:
cvs import -I ! 'new foobar-1.3 release' misc/foobar FOOBAR FOOBAR-1_3
cd work.d/foobar
cvs update
cvsrmvend FOOBAR FOOBAR-1_3
and if you didn't use '-c' above:
cvs commit -m 'removed prior to FOOBAR-1_3'
"
while getopts "cdlhv" OPTCHAR ; do
case $OPTCHAR in
c)
DOCOMMIT=true
;;
d)
DEBUG=true
;;
l)
SPEWREMOVED=true
;;
v)
VERBOSE=true
;;
h)
echo "$HELP"
exit 0
;;
\?)
echo "$USAGE" 1>&2
exit 2
;;
esac
done
shift `expr $OPTIND - 1`
if [ $# != 2 ] ; then
echo $USAGE
exit 2
fi
VENDBR=$1
VENDREL=$2
$DEBUG || trap "RC=$?; rm /tmp/cvsrm.*.$$; exit $RC" 0 1 2 15
$VERBOSE && echo "$argv0: creating list of locally added files..." 1>&2
cvs -nq tag $VENDBR |
sed -e '/^W /d' -e 's/^D //' -e 's/^T //' |
sort > /tmp/cvsrm.localfiles.$$
$VERBOSE && echo "$argv0: creating list of files removed by vendor..." 1>&2
cvs -nq tag -F -r $VENDBR $VENDREL |
sed -e 's/^T //' |
sort |
comm -23 - /tmp/cvsrm.localfiles.$$ > /tmp/cvsrm.removedfiles.$$
if [ -s /tmp/cvsrm.removedfiles.$$ ] ; then
$VERBOSE && echo "$argv0: doing 'cvs rm' for all files removed by vendor..." 1>&2
$DEBUG || xargs cvs rm -f < /tmp/cvsrm.removedfiles.$$
RC=$?
if [ $RC -ne 0 ] ; then
trap 0 1 2 15
$VERBOSE && echo "$argv0: file lists left in /tmp/cvsrm.*.$$" 1>&2
exit $RC
fi
if $DOCOMMIT ; then
$VERBOSE && echo "$argv0: committing removed files..." 1>&2
$DEBUG || xargs cvs commit -m "removed prior to vendor release tagged $VENDREL" < /tmp/cvsrm.removedfiles.$$
RC=$?
if [ $RC -ne 0 ] ; then
trap 0 1 2 15
$VERBOSE && echo "$argv0: file lists left in /tmp/cvsrm.*.$$" 1>&2
exit $RC
fi
fi
if $SPEWREMOVED ; then
$VERBOSE && echo "$argv0: list of vendor removed files follows..." 1>&2
cat /tmp/cvsrm.removedfiles.$$
fi
else
$VERBOSE && echo "$argv0: no files to remove" 1>&2
fi
exit 0
|