123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- #!/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
|