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.

300 lines
7.1 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: scripts/Create-ErrList
  6. # Copyright (C) 2006 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. # Copyright (C) 1998 - 2003 Clifford Wolf
  9. #
  10. # More information can be found in the files COPYING and README.
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; version 2 of the License. A copy of the
  15. # GNU General Public License can be found in the file COPYING.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. config=default
  18. repstat=0
  19. showerr=0
  20. showtree=0
  21. showdepc=0
  22. delete=0
  23. remove=0
  24. fulldelete=0
  25. newdelete=0
  26. onlyupdated=0
  27. repository=""
  28. stages="[0123456789]"
  29. copydir=""
  30. movedir=""
  31. logdir=""
  32. while [ "$1" ] ; do
  33. case "$1" in
  34. -cfg)
  35. config=$2 ; shift ; shift ;;
  36. -repstat)
  37. repstat=1 ; shift ;;
  38. -showerr)
  39. showerr=1 ; shift ;;
  40. -showtree)
  41. showtree=1 ; shift ;;
  42. -showdepc)
  43. showdepc=1 ; shift ;;
  44. -repository)
  45. if [ $2 != '!' ] ; then
  46. repository=" $2 " ; shift ; shift
  47. while [ "$1" -a -d "package/$1" ] ; do
  48. repository="$repository $1 " ; shift
  49. done
  50. else
  51. shift ; shift ; repository=""
  52. for x in $( ls package/ ) ; do
  53. [ -d "package/$x" ] &&
  54. repository="$repository $x"
  55. done
  56. repository="$repository "
  57. while [ "$1" -a -d "package/$1" ] ; do
  58. repository="${repository// $1 / }" ; shift
  59. done
  60. fi
  61. ;;
  62. -stage)
  63. stages="[$2]" ; shift ; shift ;;
  64. -logdir)
  65. logdir=$2 ; shift ; shift ;;
  66. -copydir)
  67. copydir=$2 ; shift ; shift ;;
  68. -movedir)
  69. movedir=$2 ; shift ; shift ;;
  70. -delete)
  71. delete=1 ; shift ;;
  72. -remove)
  73. remove=1 ; shift ;;
  74. -fulldelete)
  75. fulldelete=1 ; shift ;;
  76. -newdelete)
  77. newdelete=1 ; shift ;;
  78. -updated)
  79. onlyupdated=1 ; shift ;;
  80. -dry-run)
  81. dryrun=1 ; shift ;;
  82. -*)
  83. x="${0//?/ }" ; x="${x# }"
  84. echo "Usage: $0 [ -cfg config ] [ -repository repository ] \\"
  85. echo " $x [ -copydir copydir | -movedir movedir ] [ -repstat ] \\"
  86. echo " $x [ -stage stage ] [ -logdir logdir ] [ -[full|new]delete ] \\"
  87. echo " $x [ -updated ] [ -showerr ] [ -showtree ] [ -showdepc ] \\"
  88. echo " $x [ -dry-run ] [-remove] [ <package> ]"
  89. exit 1 ;;
  90. *)
  91. break ;;
  92. esac
  93. done
  94. . lib/functions.in
  95. . lib/parse-config
  96. logdir="${logdir:-build/$SDECFG_ID/var/adm/logs}"
  97. pkgdir="${logdir%/*}/packages"
  98. if [ "$newdelete" = 1 ]; then
  99. while read pkg cksum1
  100. do
  101. cksum2=$( pkgchksum package/*/$pkg/ )
  102. if [ "$cksum1" != "$cksum2" ]; then
  103. echo "Scheduling package '$pkg' for rebuild ..."
  104. if [ ! "$dryrun" = "1" ]; then
  105. mine -rf -R build/$SDECFG_ID $pkg
  106. rm -f build/$SDECFG_ID/var/adm/*/?-$pkg.*
  107. fi
  108. fi
  109. done < <(
  110. grep -R '^\(ROCK Linux\|T2\|OpenSDE\) Package Source Checksum: ' \
  111. build/$SDECFG_ID/var/adm/packages/ |
  112. sed 's,.*/\([^:]*\):.*:,\1,'
  113. )
  114. exit 0
  115. fi
  116. if [ "$repstat" = 1 ] ; then
  117. {
  118. echo
  119. echo -e "Repository\tPkg Total\tPkg OK\tPkg Error"
  120. echo
  121. total_pkgt=0 ; total_pkgo=0 ; total_pkge=0
  122. for x in $( cd package ; echo [a-z0-9]* ) ; do
  123. pkgt=0 ; pkgo=0 ; pkge=0
  124. for y in $( cd package/$x ; echo [a-z0-9]* ) ; do
  125. if [ "$( ls $logdir/$stages-$y.err 2> /dev/null )" ]
  126. then (( pkge++ )) ; (( total_pkge++ ))
  127. elif [ "$( ls $logdir/$stages-$y.log 2> /dev/null )" ]
  128. then (( pkgo++ )) ; (( total_pkgo++ ))
  129. fi
  130. done
  131. (( pkgt = pkgo + pkge )) ; (( total_pkgt += pkgt ))
  132. [ $pkgt != 0 ] && echo -e "$x\t$pkgt\t$pkgo\t$pkge"
  133. done
  134. echo
  135. echo -e "total\t$total_pkgt\t$total_pkgo\t$total_pkge"
  136. echo
  137. } | {
  138. expand -t20,35,50 | sed 's,^, ,'
  139. }
  140. exit 0
  141. fi
  142. if [ "$1" ] ; then
  143. if [ "$fulldelete" = 1 ] ; then
  144. for x ; do
  145. rm -vf "$logdir"/$stages-$x.{err,log,out}
  146. rm -vf "$logdir"/../*/$x
  147. done
  148. elif [ "$remove" = 1 ] ; then
  149. for x ; do
  150. echo "Scheduling package '$x' for rebuild ..."
  151. mine -rf -R build/$SDECFG_ID $x
  152. rm -f build/$SDECFG_ID/var/adm/*/?-$x.*
  153. done
  154. elif [ "$delete" = 1 ] ; then
  155. for x ; do rm -vf "$logdir"/$stages-$x.err ; done
  156. else
  157. for x ; do less "$logdir"/$stages-$x.err ; done
  158. fi
  159. exit 0
  160. fi
  161. echo
  162. echo "Error logs from $SDECFG_ID:"
  163. [ $showerr = 0 ] && echo
  164. count_pkg=0
  165. count_err=0
  166. count_log=0
  167. for stagelevel in $( echo "$stages" | tr -d '[]' | sed 's,.,& ,g' ) ; do
  168. while read x x x tree pkg x ; do
  169. [ "$repository" -a \
  170. "${repository/ $tree /}" = "$repository" ] && continue
  171. this_is_error=0
  172. if [ $onlyupdated != 0 ] ; then
  173. [ "$( bash scripts/xfind.sh package/*/$pkg -newer "$logdir/$stagelevel-$pkg.err" -o -newer "$logdir/$stagelevel-$pkg.log" )" ] && this_is_error=1
  174. elif [ -f "$logdir/$stagelevel-$pkg.err" ] ; then
  175. this_is_error=1
  176. fi
  177. if [ $this_is_error = 1 ] ; then
  178. if [ $showerr = 0 ] ; then
  179. if [ $showdepc != 0 ]; then
  180. d=$( ./scripts/Check-Deps-3 $stagelevel \
  181. $pkg config/$config/packages | \
  182. cut -f3 -d' ' | sort -u | wc -l )
  183. d="$( printf " %3d" $d )"
  184. else
  185. d=""
  186. fi
  187. echo "[$stagelevel]$d ${tree:0:13}/${pkg:0:18}"
  188. else
  189. echo ; echo "== $stagelevel-$pkg.* =="
  190. tail -n 20 "$logdir/$stagelevel-$pkg".* | \
  191. tac | perl -e '
  192. my @lines;
  193. my $counter;
  194. while (<>) {
  195. chomp;
  196. $lines[$#lines+1] = $_;
  197. }
  198. for ($counter=0; $counter <= $#lines; $counter++) {
  199. $_=$lines[$counter];
  200. if ( /^checking for .*\.\.\. *Package / ||
  201. /configure: error:/ ) {
  202. for ($_=1; $_ <= $counter; $_++) {
  203. print "$lines[$_]\n";
  204. }
  205. exit 0;
  206. }
  207. }
  208. for ($counter=0; $counter <= $#lines; $counter++) {
  209. $_=$lines[$counter];
  210. if ( /^(make\S*): / ) {
  211. my $makeprefix=$1;
  212. my $output="$_\n";
  213. while ( defined
  214. ($_=$lines[$counter++]) ) {
  215. last unless /^(make\S*): /;
  216. $output="" if $1 ne $makeprefix;
  217. $makeprefix=$1;
  218. $output.="$_\n";
  219. }
  220. print $output; exit 0;
  221. }
  222. }
  223. foreach (@lines) {
  224. print "$_\n";
  225. }
  226. ' | tac | fold -s -w79
  227. depcheck() {
  228. echo "${1}\`---> $3"
  229. for x in `grep -lwi $3 $logdir/*.err | \
  230. sed 's,.*/.-,,; s,\.err,,' | sort -u`
  231. do
  232. [ "$x" = "$3" ] && continue
  233. [ "${2/ $x /}" != "$2" ] && continue
  234. depcheck "${1} " "$2 $3 " $x
  235. done
  236. }
  237. [ $showtree = 1 ] && depcheck "" "" $pkg
  238. fi
  239. if [ "$copydir" ] ; then
  240. mkdir -p "$copydir"
  241. cp "$logdir/$stagelevel-$pkg.err" "$copydir"
  242. fi
  243. if [ "$movedir" ] ; then
  244. mkdir -p "$movedir"
  245. mv "$logdir/$stagelevel-$pkg.err" "$movedir"
  246. fi
  247. if [ "$fulldelete" -eq 1 ] ; then
  248. rm -f "$logdir"/$stages-$pkg.{err,log,out}
  249. rm -f "$logdir"/../*/$pkg
  250. elif [ "$delete" -eq 1 ] ; then
  251. rm -f "$logdir/$stagelevel-$pkg.err"
  252. fi
  253. count_err=$(( $count_err + 1 ))
  254. elif [ -f "$logdir/$stagelevel-$pkg.log" ] ; then
  255. count_log=$(( $count_log + 1 ))
  256. fi
  257. count_pkg=$(( $count_pkg + 1 ))
  258. done < <( grep "^X [0-9-]*$stagelevel" config/$config/packages )
  259. done > >(
  260. if [ $showerr = 0 ] ; then
  261. paste - - | expand -t40 | sed 's,^, ,'
  262. else cat ; fi
  263. )
  264. sleep 1
  265. echo
  266. echo "$count_pkg builds total, $count_log completed fine," \
  267. "$count_err with errors."
  268. echo