cdesktopenv/cde/admin/BuildTools/tog/cc_checkedout

349 lines
8.4 KiB
Bash
Executable File

#!/bin/ksh
#
# cc_checkedout
#
########################################################################
# set -x
##########################################################################
#
# Script setup: THIS NEEDS TO BE FIRST
#
SCRIPTS_DIR="`dirname $0`"
PROG_NAME="`basename $0`"
if [ "" = "$SCRIPTS_DIR" ]; then
SCRIPTS_DIR=/project/dt/scripts
fi
if [ ! -f $SCRIPTS_DIR/script_setup.ksh ]; then
print -u2 "$PROG_NAME: File '$SCRIPTS_DIR/script_setup.ksh' NOT found!"
print -u2 "$PROG_NAME: Exiting ..."
exit 1
fi
. $SCRIPTS_DIR/script_setup.ksh
##########################################################################
#
# Script specific global variables
#
COMPONENTS_FILES=""
COMPONENTS=""
DEBUG="False"
DO_DELETE="True"
DO_LISTING="True"
DO_SUMMARY="True"
DO_TMPFILE="True"
HAVE_EVENTS="True"
CHECKEDOUT_LOG=""
LOG_PATH=""
MAIL_LIST=""
PROG_NAME="`basename $0`"
WHAT_TO_SEARCH="-avobs"
##########################################################################
#
# FUNCTION: do_executive_summary ()
#
do_executive_summary ()
{
AWK_EXEC_CO_SUMMARY='{printf("%-40s [CheckedOut= %-3s; Users= ", $1,$2)}'
AWK_EXEC_USER_SUMMARY='{printf("%s ", $1)}'
AWK_EXEC_TERM_SUMMARY='{printf("]\n")}'
COMPONENT=$1
if [ "True" = "$DEBUG" ]; then
print -u2 "summarizing events in $COMPONENT"
fi
TOTAL_CHECKEDOUT=`$EXTRACT_MSG -l $CHECKEDOUT_LOG $COMPONENT | wc -l |
awk '{printf("%s",$1)}'`
if [ $TOTAL_CHECKEDOUT -ne 0 ]; then
USERS=`$EXTRACT_MSG -l $CHECKEDOUT_LOG $COMPONENT |
awk '{ print $1 }' FS="::" | sort | uniq`
echo "$COMPONENT $TOTAL_CHECKEDOUT" | awk "$AWK_EXEC_CO_SUMMARY"
for u in $USERS
do
echo "$u" | awk "$AWK_EXEC_USER_SUMMARY"
done
echo "" | awk "$AWK_EXEC_TERM_SUMMARY"
fi
}
##########################################################################
#
# FUNCTION: usage ()
#
usage ()
{
cat <<eof
USAGE: $PROG_NAME
[-d | -debug] # Print output to stdout
[-h | -? | -help] # Print usage and exit
[{-l | -log_path} <file>] # Specifies the output file for the report.
[{-m | -mail | -mail_list} <user_name(s)>]
[{-t | -tmpfile} <file>] # Specifies the tmp file to be extracted from.
[{-w | -what | -what_to_search} <option or directory>]
# The default is: $WHAT_TO_SEARCH
[-no_delete]
[-no_listing]
[-no_summary]
# '$PROG_NAME' calls clearcase commands to determine which files
# are currently checked out and then delivers the report. The
# report can be sent to a list of mail recipients, or a log file
# or both. If neither is specified, the report is sent to stdout
# by default.
eof
}
######################################################################
#
# Exit if no view is set
#
$CLEAR_CASE_TOOL pwv | grep 'Set view' | grep NONE > /dev/null
if [ $? -eq 0 ]; then
print -u2 "$PROG_NAME: Exiting ... NO ClearCase view is set!"
exit 1
fi
##########################################################################
#
# Do command-line processing
#
while [ $# -gt 0 ]; do
case $1 in
-debug)
DEBUG="True"
shift 1 ;;
-h | -? | -help)
usage $PROG_NAME
do_exit 1 ;;
-l | -log_path)
if [ $# -lt 2 ]; then
print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
do_exit 1
fi
LOG_PATH=$2
shift 2 ;;
-m | -mail | -mail_list)
if [ $# -lt 2 ]; then
print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
do_exit 1
fi
MAIL_LIST=$2
shift 2 ;;
-t | -tmpfile)
if [ $# -lt 2 ]; then
print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
do_exit 1
fi
DO_TMPFILE="false"
CHECKEDOUT_LOG=$2
shift 2 ;;
-w | -what | -what_to_search)
if [ $# -lt 2 ]; then
print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
do_exit 1
fi
WHAT_TO_SEARCH=$2
shift 2 ;;
-no_listing)
DO_LISTING="False"
shift 1 ;;
-no_summary)
DO_SUMMARY="False"
shift 1 ;;
-no_delete)
DO_DELETE="False"
shift 1 ;;
*)
usage $PROG_NAME
do_exit 1 ;;
esac
done
if [ "True" = "$DO_TMPFILE" ]; then
CHECKEDOUT_LOG=/tmp/$PROG_NAME.checkedout.$$
CHECKEDOUT_LOG_PRIME=/tmp/$PROG_NAME.checkedout.1.$$
do_register_temporary_file $CHECKEDOUT_LOG
do_register_temporary_file $CHECKEDOUT_LOG_PRIME
#
# First get the list of files
#
$CLEAR_CASE_TOOL lsco -fmt "%u %n %f\n" $WHAT_TO_SEARCH > $CHECKEDOUT_LOG
#
# Since it is possible for more than one person to have a
# file checked-out must get all locks. Note that it also
# desireable to get each user's comments attached to the
# checkout.
#
cat $CHECKEDOUT_LOG | while read LINE; do
FILE="`echo $LINE | awk '{printf "%s", $2}'`"
$CLEAR_CASE_TOOL lsco -d -fmt "%u::%Ad::days::%Tf::(%Rf)::%n::%f\n" \
$FILE >> $CHECKEDOUT_LOG_PRIME
done
#
# Sort the files and remove dups.
#
sort $CHECKEDOUT_LOG_PRIME | uniq > $CHECKEDOUT_LOG
cp $CHECKEDOUT_LOG $CHECKEDOUT_LOG_PRIME
sed -e 's/\.cde-1/cde/
s/\.cde-2/cde/
s/\.cde-3/cde/
s/\.cde-test-1/cde-test/
s/\.cde-test-2/cde-test/
s/\.cde-test-3/cde-test/
s/\.motif-1/motif/
s/\.motif-2/motif/' $CHECKEDOUT_LOG_PRIME > $CHECKEDOUT_LOG
fi
PROJECTS="cde cde-contrib cde-cts cde-misc cde-test cde-test-misc
motif motif-cts motif-misc x11/misc x11/unsupported x11"
#
# Redirect output
#
if [ "$DEBUG" = "False" ]; then
EXECUTIVE_SUMMARY_LOG=/tmp/$PROG_NAME.execsum.$$
do_register_temporary_file $EXECUTIVE_SUMMARY_LOG
touch $EXECUTIVE_SUMMARY_LOG
exec 9>&1
exec > $EXECUTIVE_SUMMARY_LOG
fi
DATE=`date "$BTAG_DFMT"`
print -u1 " CLEARCASE CHECKEDOUT SUMMARY FOR: $DATE"
print -u1 " ++++++++++++++++++++++++++++++++++++++++++++++++++++"
print -u1
print -u1
if [ ! -s $CHECKEDOUT_LOG ]; then
if [ "$DEBUG" = "True" ]; then
print -u1 "Log file '$CHECKEDOUT_LOG' is empty"
fi
HAVE_EVENTS="False"
print -u1 "NO events were found."
fi
if [ "True" = "$DO_SUMMARY" -a "True" = "$HAVE_EVENTS" ]; then
for p in $PROJECTS
do
COMPONENTS_FILE=$SCRIPTS_DIR/$p.components
if [ -f $COMPONENTS_FILE ]; then
#
# Correct for the missing 'xc' subdirectory in x11.components
#
if [ "$p" = "x11" ]; then
p=x11/xc
fi
for c in `cat $COMPONENTS_FILE`
do
do_executive_summary /proj/$p/$c
done
else
do_executive_summary /proj/$p
fi
done
fi
if [ "True" = "$DO_LISTING" -a "True" = "$HAVE_EVENTS" ]; then
print -u1
print -u1
print -u1 " CLEARCASE CHECKEDOUT LISTING"
print -u1 " ++++++++++++++++++++++++++++"
print -u1
print -u1
cat $CHECKEDOUT_LOG | while read LINE; do
USER="`echo $LINE | awk '{FS="::"; printf "%s", $1}'`"
FILE="`echo $LINE | awk '{FS="::"; printf "%s", $6}'`"
echo $LINE | \
sed '/::1::days/s//::1:: day/' | \
sed '/\(unreserved\)/s//U/' | \
sed '/\(reserved\)/s//R/' | \
awk '{ FS="::"; printf "%-8s %3d %s %s %s\n %s@@%s\n", $1,$2,$3,$4,$5,$6,$7 }'
#
# Attach the WIP if present
#
WIP="`$CLEAR_CASE_TOOL lsco -d -user $USER -fmt '%[WIP]a' $FILE`"
if [ "" != "$WIP" ]; then
print -u1 " $WIP"
fi
#
# Attach the (possibly mult-line) comment
#
$CLEAR_CASE_TOOL lsco -d -user $USER -fmt "%c" $FILE \
| awk '{printf " %s\n", $0}'
done
fi
#####################################################################
#
# If no files were found, create a descriptive message; else
# tack on a legend
#
if [ ! -s $CHECKEDOUT_LOG ]; then
print -u1 "NO files are checked out!"
else
mv $CHECKEDOUT_LOG_PRIME $CHECKEDOUT_LOG
print -u1 "\n(R) = reserved checkout"
print -u1 "(U) = unreseved checkout"
fi
##########################################################################
#
# Complete the build summary and deliver it
#
if [ "" != "$MAIL_LIST" ]; then
mailx -s "$SUBJECT_CHECKOUTS (`date $SUBJECT_DATE`)" "$MAIL_LIST" < \
$EXECUTIVE_SUMMARY_LOG
fi
if [ "" != "$LOG_PATH" ]; then
cp $EXECUTIVE_SUMMARY_LOG $LOG_PATH
fi
if [ "$DEBUG" = "False" -a "" = "$MAIL_LIST" -a "" = "$LOG_PATH" ]; then
exec >&9
cat $EXECUTIVE_SUMMARY_LOG
fi
##########################################################################
#
# Clean up temporary files and exit
#
if [ "True" = "$DO_DELETE" ]; then
do_exit 0
fi
exit 0