OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
4.6 KiB

  1. #!/bin/sh
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: misc/archive/AuditBuild.sh
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. MATRIX=http://www.t2-project.org/packages
  16. config=default
  17. enabled='X'
  18. repositories=
  19. VERBOSE=
  20. HTMLDIR=
  21. root=
  22. show_usage() {
  23. cat<<-EOT
  24. usage: $0 [-v] [-cfg <config>] [--no-enabled-too] [-repository <repositories>]
  25. EOT
  26. }
  27. while [ $# -gt 0 ]; do
  28. case "$1" in
  29. -cfg) config="$2"; shift ;;
  30. -v) VERBOSE=1 ;;
  31. -w) HTMLDIR="$2"; shift ;;
  32. --help) show_usage; exit 1 ;;
  33. -R) root="$2"; shift ;;
  34. --no-enabled-too)
  35. enabled=. ;;
  36. -repository)
  37. shift; repositories="$*"
  38. break ;;
  39. *) show_usage; exit 2 ;;
  40. esac
  41. shift
  42. done
  43. if [ ! -f config/$config/packages ]; then
  44. echo "ERROR: '$config' is not a valid config"
  45. exit 1
  46. fi
  47. eval `grep 'SDECFG_ID=' config/$config/config 2> /dev/null`
  48. if [ "$root" ]; then
  49. LOGSDIR=$root/var/adm/logs
  50. else
  51. LOGSDIR=build/$SDECFG_ID/var/adm/logs
  52. fi
  53. if [ -z "$SDECFG_ID" -o ! -d $LOGSDIR ]; then
  54. echo "ERROR: 'build/$SDECFG_ID/' is not a valid build root (sandbox)"
  55. exit 1
  56. fi
  57. if [ "$HTMLDIR" ]; then
  58. mkdir -p $HTMLDIR/$config.$$/{diff,log}
  59. fi
  60. expand_stages() {
  61. local array="$1" stage=
  62. while [ "$array" ]; do
  63. stage=${array:0:1}
  64. array=${array:1}
  65. if [ "$stage" != "-" ]; then
  66. echo -n "$stage "
  67. fi
  68. done
  69. }
  70. audit_package() {
  71. local pkg="$1" repo="$2" ver="$3" enabled="$4"
  72. local stages= svndiff= oldver= newver= lchanges= stage=
  73. local svnst= lstatus= lbuild= file=
  74. shift 4; stages="$*"
  75. svnst=`svn st package/$repo/$pkg`
  76. if [ "$svnst" ]; then
  77. svndiff=`svn diff package/$repo/$pkg`
  78. if [ "$svndiff" ]; then
  79. lchanges="CHANGED"
  80. oldver=`echo "$svndiff" | grep '^-\[V\]' | cut -d' ' -f2`
  81. newver=`echo "$svndiff" | grep '^+\[V\]' | cut -d' ' -f2`
  82. if [ "$oldver" ]; then
  83. ver="$oldver -> $newver"
  84. lchanges="UPDATED"
  85. elif [ "$newver" ]; then
  86. lchanges="ADDED"
  87. fi
  88. fi
  89. if [ "$HTMLDIR" ]; then
  90. {
  91. echo "$svnst"
  92. echo ""
  93. echo "$svndiff"
  94. } > $HTMLDIR/$config.$$/diff/$pkg.diff.txt
  95. lchanges="<a href=\"diff/$pkg.diff.txt\">$lchanges</a>"
  96. fi
  97. fi
  98. if [ "$enabled" == "O" ]; then
  99. for stage in $stages; do
  100. lbuild="$lbuild NO($stage)"
  101. done
  102. lstatus=3
  103. else
  104. for stage in $stages; do
  105. file=`ls -1 $LOGSDIR/$stage-$pkg.{err,log,out} 2> /dev/null`
  106. lstatus=
  107. if [ "$file" ]; then
  108. case "$file" in
  109. *.log) [ "$lstatus" ] || lstatus=1
  110. lbuild="$lbuild OK($stage)" ;;
  111. *.out) [ "$lstatus" != "2" ] || lstatus=0
  112. lbuild="$lbuild NO($stage)" ;;
  113. *) lstatus=2
  114. if [ "$HTMLDIR" ]; then
  115. lbuild="$lbuild <a href=\"log/$stage-$pkg.err.txt\">ERR($stage)</a>"
  116. cp $file $HTMLDIR/$config.$$/log/$stage-$pkg.err.txt
  117. else
  118. lbuild="$lbuild ERR($stage)"
  119. fi ;;
  120. esac
  121. else
  122. lbuild="$lbuild NO($stage)"
  123. [ "$lstatus" ] || lstatus=0
  124. fi
  125. done
  126. fi
  127. case "$lstatus" in
  128. 3) lstatus=DISABLED ;;
  129. 2) lstatus=FAILED ;;
  130. 1) lstatus=SUCCESSFUL ;;
  131. *) lstatus=PENDING ;;
  132. esac
  133. if [ "$HTMLDIR" ]; then
  134. cat <<EOT
  135. <tr><td>package/$repo/<a href="$MATRIX/$pkg.html" name="$pkg">$pkg</a></td><td>$lchanges</td><td>(${ver//>/&gt;})</td><td>$lbuild</td><td>$lstatus</td></tr>
  136. EOT
  137. else
  138. echo -e "package/$repo/$pkg\t$lchanges\t($ver)\t$lbuild\t$lstatus"
  139. fi
  140. }
  141. if [ "$HTMLDIR" ]; then
  142. cat <<EOT
  143. <html>
  144. <head><title>Audit Build $config over revision $( svn info | grep Revision | cut -d' ' -f2 )</title>
  145. <body>
  146. $( [ "$repositories" ] && echo "<h3>$repositories</h3>" )
  147. <table><tr>
  148. <th>Package</th>
  149. <th>SVN Status</th>
  150. <th>Version</th>
  151. <th>Build Status</th>
  152. <th>Result</th>
  153. </tr>
  154. EOT
  155. fi
  156. if [ "$repositories" ]; then
  157. for repo in $repositories; do
  158. repo=${repo#package/}; repo=${repo%/}
  159. if [ -d package/$repo/ ]; then
  160. grep -e "^$enabled.* $repo " config/$config/packages | while \
  161. read e stages x repo pkg ver x; do
  162. audit_package $pkg $repo $ver $e `expand_stages $stages`
  163. done
  164. fi
  165. done
  166. else
  167. grep -e "^$enabled" config/$config/packages | while \
  168. read e stages x repo pkg ver x; do
  169. audit_package $pkg $repo $ver $e `expand_stages $stages`
  170. done
  171. fi
  172. if [ "$HTMLDIR" ]; then
  173. echo "<body><html>"
  174. if [ -d "$HTMLDIR/$config" ]; then
  175. mv $HTMLDIR/$config $HTMLDIR/$config.$$-old
  176. fi
  177. mv $HTMLDIR/$config.$$ $HTMLDIR/$config/
  178. rm -rf $HTMLDIR/$config.$$-old
  179. fi