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
|
#!/bin/sh
#
# $XORP: xorp/devnotes/update_cvsroot.sh,v 1.4 2008/04/29 01:53:44 pavlin Exp $
#
#
# This is a script to update the CVS/Root files.
# It must be run from the top directory of a checked-out copy
# of the source code, otherwise it may overwrite something else.
#
# Note: Before running the script you might want to modify the
# ANON_CVS_ROOT or DEVEL_CVS_ROOT strings.
#
#
# XXX: MODIFY THIS AS APPROPRIATE!
#
ANON_CVS_ROOT=":pserver:xorpcvs@anoncvs.xorp.org:/cvs"
DEVEL_CVS_ROOT="cvs.xorp.org:/cvsroot"
#
# Local variables
#
NEW_CVS_ROOT=""
TMP_CVS_ROOT_FILENAME=/tmp/xorp_cvsroot.$$
#
# Print usage and exit
#
usage()
{
cat <<EOF
Usage: $0 [-a | -d | -h]
-a Set CVS Root to the anonymous CVS
Default: ${ANON_CVS_ROOT}
-d Set CVS Root to the developer CVS
Default: ${DEVEL_CVS_ROOT}
-h Print usage
EOF
exit 1
}
#
# Cleanup function
#
cleanup_atexit()
{
rm -f "${TMP_CVS_ROOT_FILENAME}"
}
#
# Test the number of the command-line arguments
#
if [ $# -lt 1 ] ; then
usage
fi
#
# Parse the command-line arguments
#
for i in "$@"
do
case "$i" in
-a)
NEW_CVS_ROOT="${ANON_CVS_ROOT}"
;;
-d)
NEW_CVS_ROOT="${DEVEL_CVS_ROOT}"
;;
-h)
usage
;;
*)
usage
;;
esac
done
if [ -z "${NEW_CVS_ROOT}" ] ; then
echo "New CVS Root is empty!"
usage
fi
echo "New CVS Root is ${NEW_CVS_ROOT}"
#
# Trap some signals to cleanup state
#
trap "cleanup_atexit" 0 2 3 15
#
# Write a temporary copy of the new CVS Root file
#
echo "${NEW_CVS_ROOT}" > "${TMP_CVS_ROOT_FILENAME}"
#
# Do the file update.
# If both old and new CVS Root are identical, then don't overwrite anything.
#
find . -name CVS -and -type d -print |
while read DIRNAME
do
FOUND_CVS_ROOT_FILENAME="${DIRNAME}/Root"
if [ ! -f "${FOUND_CVS_ROOT_FILENAME}" ] ; then
continue
fi
cmp -s "${TMP_CVS_ROOT_FILENAME}" "${FOUND_CVS_ROOT_FILENAME}"
if [ $? -eq 0 ] ; then
# Old and new CVS Root are identical
echo "Ignoring ${FOUND_CVS_ROOT_FILENAME}"
continue
fi
# Copy the file
echo "Updating ${FOUND_CVS_ROOT_FILENAME}"
cp -p "${TMP_CVS_ROOT_FILENAME}" "${FOUND_CVS_ROOT_FILENAME}"
done
|