2
0

cc_submissions 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. #!/bin/ksh
  2. #
  3. # cc_submissions
  4. #
  5. ########################################################################
  6. # set -x
  7. ##########################################################################
  8. #
  9. # Script setup: THIS NEEDS TO BE FIRST
  10. #
  11. SCRIPTS_DIR="`dirname $0`"
  12. PROG_NAME="`basename $0`"
  13. if [ "" = "$SCRIPTS_DIR" ]; then
  14. SCRIPTS_DIR=/project/dt/scripts
  15. fi
  16. if [ ! -f $SCRIPTS_DIR/script_setup.ksh ]; then
  17. print -u2 "$PRG: File '$SCRIPTS_DIR/script_setup.ksh' NOT found!"
  18. print -u2 "$PRG: Exiting ..."
  19. exit 1
  20. fi
  21. . $SCRIPTS_DIR/script_setup.ksh
  22. ##########################################################################
  23. #
  24. # Script specific global variables
  25. #
  26. COMPONENTS_FILES=""
  27. COMPONENTS=""
  28. DEBUG="False"
  29. DO_DELETE="True"
  30. DO_LISTING="True"
  31. DO_TMPFILE="True"
  32. DO_SUMMARY="True"
  33. INCLUDE_ROOT="False"
  34. SUBMISSION_LOG=""
  35. MAIL_LIST=""
  36. NULLSUBDIRECTORY="__XXX__"
  37. HAVE_EVENTS="True"
  38. ##########################################################################
  39. #
  40. # FUNCTION: do_executive_summary ()
  41. #
  42. do_executive_summary ()
  43. {
  44. AWK_EXEC_EVENT_SUMMARY='{printf("%-40s [Events= %-3s; Users= ", $1,$2)}'
  45. AWK_EXEC_USER_SUMMARY='{printf("%s ", $1)}'
  46. AWK_EXEC_TERM_SUMMARY='{printf("]\n")}'
  47. COMPONENT=$1
  48. if [ "True" = "$DEBUG" ]; then
  49. print -u2 "summarizing events in $COMPONENT"
  50. fi
  51. TOTAL_EVENTS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT | wc -l |
  52. awk '{printf("%s",$1)}'`
  53. if [ $TOTAL_EVENTS -ne 0 ]; then
  54. USERS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT |
  55. awk '{ print $3 }' FS="|" | sort | uniq`
  56. # for u in $USERS
  57. # do
  58. # USER_EVENTS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT |
  59. # grep "$FS$u$FS" | wc -l`
  60. # echo "$u $USER_EVENTS" | awk "$AWK_EXEC_SUMMARY"
  61. # done
  62. echo "$COMPONENT $TOTAL_EVENTS" | awk "$AWK_EXEC_EVENT_SUMMARY"
  63. for u in $USERS
  64. do
  65. echo "$u" | awk "$AWK_EXEC_USER_SUMMARY"
  66. done
  67. echo "" | awk "$AWK_EXEC_TERM_SUMMARY"
  68. fi
  69. }
  70. ##########################################################################
  71. #
  72. # FUNCTION: do_listing_summary ()
  73. #
  74. do_listing_summary ()
  75. {
  76. AWK_LIST_SUMMARY='{printf("%s\n User=%-12s Event=%-16s DDTS=%8s \n Comment='%s'\n",$2,$3,$4,$5,$7)}'
  77. COMPONENT=$1
  78. if [ "True" = "$DEBUG" ]; then
  79. print -u2 "listing events in $COMPONENT"
  80. fi
  81. TOTAL_EVENTS=`$EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT | wc -l`
  82. if [ $TOTAL_EVENTS -ne 0 ]; then
  83. print -u1 "+"
  84. print -u1 "+ Events In: $COMPONENT"
  85. print -u1 "+"
  86. $EXTRACT_MSG -l $SUBMISSION_LOG $COMPONENT | \
  87. awk "$AWK_LIST_SUMMARY" FS="|"
  88. fi
  89. }
  90. ##########################################################################
  91. #
  92. # FUNCTION: usage ()
  93. #
  94. usage ()
  95. {
  96. cat <<eof
  97. USAGE: $1
  98. [-h | -? | -help] # Print usage and exit
  99. [{-m | -mail | -mail_list} <user_name(s)>]
  100. [{-t | -tmpfile} <file>] # Specifies the log file to be extracted from.
  101. [-include_root]
  102. [-no_delete]
  103. [-no_listing]
  104. [-no_summary]
  105. # '$PROG_NAME' calls clearcase commands to determine which files
  106. # were submitted in the last 24 hours and then delivers the report.
  107. # The report can be sent to a list of mail recipients, or a log file
  108. # or both. If neither is specified, the report is sent to stdout
  109. # by default.
  110. eof
  111. }
  112. ##########################################################################
  113. #
  114. # Do command-line processing
  115. #
  116. while [ $# -gt 0 ]; do
  117. case $1 in
  118. -debug)
  119. DEBUG="True"
  120. shift 1 ;;
  121. -h | -? | -help)
  122. usage $PROG_NAME
  123. do_exit 1 ;;
  124. -l | -log_path)
  125. if [ $# -lt 2 ]; then
  126. print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
  127. do_exit 1
  128. fi
  129. LOG_PATH=$2
  130. shift 2 ;;
  131. -m | -mail | -mail_list)
  132. if [ $# -lt 2 ]; then
  133. print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
  134. do_exit 1
  135. fi
  136. MAIL_LIST=$2
  137. shift 2 ;;
  138. -t | -tmpfile)
  139. if [ $# -lt 2 ]; then
  140. print -u2 "$PROG_NAME: $1 option missing value; exiting ..."
  141. do_exit 1
  142. fi
  143. DO_TMPFILE="false"
  144. SUBMISSION_LOG=$2
  145. shift 2 ;;
  146. -include_root)
  147. INCLUDE_ROOT="True"
  148. shift 1 ;;
  149. -no_listing)
  150. DO_LISTING="False"
  151. shift 1 ;;
  152. -no_summary)
  153. DO_SUMMARY="False"
  154. shift 1 ;;
  155. -no_delete)
  156. DO_DELETE="False"
  157. shift 1 ;;
  158. *)
  159. usage $PROG_NAME
  160. do_exit 1 ;;
  161. esac
  162. done
  163. if [ "True" = "$DO_TMPFILE" ]; then
  164. SUBMISSION_LOG=/tmp/$PROG_NAME.lshistory.$$
  165. SUBMISSION_LOG_PRIME=/tmp/$PROG_NAME.lshistory.1.$$
  166. do_register_temporary_file $SUBMISSION_LOG
  167. do_register_temporary_file $SUBMISSION_LOG_PRIME
  168. EVENT="EVENT"
  169. FS='|'
  170. FORMAT="$EVENT$FS%n$FS%u$FS%e$FS%1.FIXESa$FS%1.l$FS%1.Nc$FS\n"
  171. $CLEAR_CASE_TOOL lshistory -fmt $FORMAT \
  172. -avobs -nco -since yesterday.00:00 > $SUBMISSION_LOG
  173. #
  174. # Delete entries submitted by root
  175. #
  176. grep $EVENT $SUBMISSION_LOG | sort > $SUBMISSION_LOG_PRIME
  177. if [ "False" = $INCLUDE_ROOT ]; then
  178. SUBMISSION_LOG_TWO=/tmp/$PROG_NAME.lshistory.2.$$
  179. do_register_temporary_file $SUBMISSION_LOG_TWO
  180. egrep -v -e "${FS}root$FS" $SUBMISSION_LOG_PRIME > $SUBMISSION_LOG_TWO
  181. cp $SUBMISSION_LOG_TWO $SUBMISSION_LOG_PRIME
  182. fi
  183. sed -e 's/\.cde-1/cde/
  184. s/\.cde-2/cde/
  185. s/\.cde-3/cde/
  186. s/\.cde-test-1/cde-test/
  187. s/\.cde-test-2/cde-test/
  188. s/\.cde-test-3/cde-test/
  189. s/\.motif-1/motif/
  190. s/\.motif-2/motif/' $SUBMISSION_LOG_PRIME > $SUBMISSION_LOG
  191. fi
  192. PROJECTS="cde cde-contrib cde-cts cde-misc cde-test cde-test-misc
  193. motif motif-cts motif-misc x11/misc x11/unsupported x11"
  194. #
  195. # Redirect output
  196. #
  197. if [ "$DEBUG" = "False" ]; then
  198. EXECUTIVE_SUMMARY_LOG=/tmp/$PROG_NAME.execsum.$$
  199. do_register_temporary_file $EXECUTIVE_SUMMARY_LOG
  200. touch $EXECUTIVE_SUMMARY_LOG
  201. exec 9>&1
  202. exec > $EXECUTIVE_SUMMARY_LOG
  203. fi
  204. DATE=`date "$BTAG_DFMT"`
  205. print -u1 " CLEARCASE EVENT SUMMARY FOR: $DATE"
  206. print -u1 " +++++++++++++++++++++++++++++++++++++++++++++++"
  207. print -u1
  208. print -u1
  209. if [ ! -s $SUBMISSION_LOG ]; then
  210. HAVE_EVENTS="False"
  211. print -u1 "NO events were found."
  212. fi
  213. if [ "True" = "$DO_SUMMARY" -a "True" = "$HAVE_EVENTS" ]; then
  214. for p in $PROJECTS
  215. do
  216. COMPONENTS_FILE=$SCRIPTS_DIR/$p.components
  217. if [ -f $COMPONENTS_FILE ]; then
  218. #
  219. # Correct for the missing 'xc' subdirectory in x11.components
  220. #
  221. if [ "$p" = "x11" ]; then
  222. p=x11/xc
  223. fi
  224. for c in `cat $COMPONENTS_FILE`
  225. do
  226. do_executive_summary /proj/$p/$c
  227. done
  228. else
  229. do_executive_summary /proj/$p
  230. fi
  231. done
  232. fi
  233. if [ "True" = "$DO_LISTING" -a "True" = "$HAVE_EVENTS" ]; then
  234. print -u1
  235. print -u1
  236. print -u1 " CLEARCASE EVENT LISTING"
  237. print -u1 " +++++++++++++++++++++++"
  238. print -u1
  239. print -u1
  240. for p in $PROJECTS
  241. do
  242. COMPONENTS_FILE=$SCRIPTS_DIR/$p.components
  243. if [ -f $COMPONENTS_FILE ]; then
  244. #
  245. # Correct for the missing 'xc' subdirectory in x11.components
  246. #
  247. if [ "$p" = "x11" ]; then
  248. p=x11/xc
  249. fi
  250. for c in `cat $COMPONENTS_FILE`
  251. do
  252. do_listing_summary /proj/$p/$c
  253. done
  254. else
  255. do_listing_summary /proj/$p
  256. fi
  257. done
  258. fi
  259. ##########################################################################
  260. #
  261. # Complete the build summary and mail it or dump it to stdout
  262. #
  263. if [ "" != "$MAIL_LIST" ]; then
  264. mailx -s "$SUBJECT_SUBMISSIONS (`date $SUBJECT_DATE`)" "$MAIL_LIST" < \
  265. $EXECUTIVE_SUMMARY_LOG
  266. fi
  267. if [ "" != "$LOG_PATH" ]; then
  268. cp $EXECUTIVE_SUMMARY_LOG $LOG_PATH
  269. fi
  270. if [ "$DEBUG" = "False" -a "" = "$MAIL_LIST" -a "" = "$LOG_PATH" ]; then
  271. exec >&9
  272. cat $EXECUTIVE_SUMMARY_LOG
  273. fi
  274. ##########################################################################
  275. #
  276. # Clean up temporary files and exit
  277. #
  278. if [ "True" = "$DO_DELETE" ]; then
  279. do_exit 0
  280. fi
  281. exit 0