123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- #!/bin/ksh
- #
- # cc_submissions
- #
- ########################################################################
- # 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 "$PRG: File '$SCRIPTS_DIR/script_setup.ksh' NOT found!"
- print -u2 "$PRG: 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_TMPFILE="True"
- DO_SUMMARY="True"
- INCLUDE_ROOT="False"
- SUBMISSION_LOG=""
- MAIL_LIST=""
- NULLSUBDIRECTORY="__XXX__"
- HAVE_EVENTS="True"
- ##########################################################################
- #
- # FUNCTION: do_executive_summary ()
- #
- do_executive_summary ()
- {
- AWK_EXEC_EVENT_SUMMARY='{printf("%-40s [Events= %-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_EVENTS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT | wc -l |
- awk '{printf("%s",$1)}'`
- if [ $TOTAL_EVENTS -ne 0 ]; then
- USERS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT |
- awk '{ print $3 }' FS="|" | sort | uniq`
- # for u in $USERS
- # do
- # USER_EVENTS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT |
- # grep "$FS$u$FS" | wc -l`
- # echo "$u $USER_EVENTS" | awk "$AWK_EXEC_SUMMARY"
- # done
- echo "$COMPONENT $TOTAL_EVENTS" | awk "$AWK_EXEC_EVENT_SUMMARY"
- for u in $USERS
- do
- echo "$u" | awk "$AWK_EXEC_USER_SUMMARY"
- done
- echo "" | awk "$AWK_EXEC_TERM_SUMMARY"
- fi
- }
- ##########################################################################
- #
- # FUNCTION: do_listing_summary ()
- #
- do_listing_summary ()
- {
- AWK_LIST_SUMMARY='{printf("%s\n User=%-12s Event=%-16s DDTS=%8s \n Comment='%s'\n",$2,$3,$4,$5,$7)}'
- COMPONENT=$1
- if [ "True" = "$DEBUG" ]; then
- print -u2 "listing events in $COMPONENT"
- fi
- TOTAL_EVENTS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT | wc -l`
- if [ $TOTAL_EVENTS -ne 0 ]; then
- print -u1 "+"
- print -u1 "+ Events In: $COMPONENT"
- print -u1 "+"
- $EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT | \
- awk "$AWK_LIST_SUMMARY" FS="|"
- fi
- }
- ##########################################################################
- #
- # FUNCTION: usage ()
- #
- usage ()
- {
- cat <<eof
- USAGE: $1
- [-h | -? | -help] # Print usage and exit
- [{-m | -mail | -mail_list} <user_name(s)>]
- [{-t | -tmpfile} <file>] # Specifies the log file to be extracted from.
- [-include_root]
- [-no_delete]
- [-no_listing]
- [-no_summary]
- # '$PROG_NAME' calls clearcase commands to determine which files
- # were submitted in the last 24 hours 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
- }
- ##########################################################################
- #
- # 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"
- SUBMISSION_LOG=$2
- shift 2 ;;
- -include_root)
- INCLUDE_ROOT="True"
- shift 1 ;;
- -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
- SUBMISSION_LOG=/tmp/$PROG_NAME.lshistory.$$
- SUBMISSION_LOG_PRIME=/tmp/$PROG_NAME.lshistory.1.$$
- do_register_temporary_file $SUBMISSION_LOG
- do_register_temporary_file $SUBMISSION_LOG_PRIME
- EVENT="EVENT"
- FS='|'
- FORMAT="$EVENT$FS%n$FS%u$FS%e$FS%1.FIXESa$FS%1.l$FS%1.Nc$FS\n"
- $CLEAR_CASE_TOOL lshistory -fmt $FORMAT \
- -avobs -nco -since yesterday.00:00 > $SUBMISSION_LOG
- #
- # Delete entries submitted by root
- #
- grep $EVENT $SUBMISSION_LOG | sort > $SUBMISSION_LOG_PRIME
- if [ "False" = $INCLUDE_ROOT ]; then
- SUBMISSION_LOG_TWO=/tmp/$PROG_NAME.lshistory.2.$$
- do_register_temporary_file $SUBMISSION_LOG_TWO
- egrep -v -e "${FS}root$FS" $SUBMISSION_LOG_PRIME > $SUBMISSION_LOG_TWO
- cp $SUBMISSION_LOG_TWO $SUBMISSION_LOG_PRIME
- fi
- 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/' $SUBMISSION_LOG_PRIME > $SUBMISSION_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 EVENT SUMMARY FOR: $DATE"
- print -u1 " +++++++++++++++++++++++++++++++++++++++++++++++"
- print -u1
- print -u1
- if [ ! -s $SUBMISSION_LOG ]; then
- 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 EVENT LISTING"
- print -u1 " +++++++++++++++++++++++"
- print -u1
- print -u1
- 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_listing_summary /proj/$p/$c
- done
- else
- do_listing_summary /proj/$p
- fi
- done
- fi
- ##########################################################################
- #
- # Complete the build summary and mail it or dump it to stdout
- #
- if [ "" != "$MAIL_LIST" ]; then
- mailx -s "$SUBJECT_SUBMISSIONS (`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
|