mirror of the now-defunct rocklinux.org
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.

357 lines
9.3 KiB

  1. #!/bin/bash
  2. #
  3. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  4. #
  5. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. # Please add additional copyright information _after_ the line containing
  7. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  8. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  9. #
  10. # ROCK Linux: rock-src/scripts/Create-ErrList
  11. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  12. #
  13. # This program is free software; you can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License, or
  16. # (at your option) any later version. A copy of the GNU General Public
  17. # License can be found at Documentation/COPYING.
  18. #
  19. # Many people helped and are helping developing ROCK Linux. Please
  20. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  21. # file for details.
  22. #
  23. # --- ROCK-COPYRIGHT-NOTE-END ---
  24. config=default
  25. repstat=0
  26. showerr=0
  27. showtree=0
  28. showdepc=0
  29. delete=0
  30. remove=0
  31. fulldelete=0
  32. newdelete=0
  33. dryrun=0
  34. onlyupdated=0
  35. repository=""
  36. stages="[0123456789]"
  37. copydir=""
  38. movedir=""
  39. logdir=""
  40. while [ "$1" ] ; do
  41. case "$1" in
  42. -cfg)
  43. config=$2 ; shift ; shift ;;
  44. -repstat)
  45. repstat=1 ; shift ;;
  46. -showerr)
  47. showerr=1 ; shift ;;
  48. -showtree)
  49. showtree=1 ; shift ;;
  50. -showdepc)
  51. showdepc=1 ; shift ;;
  52. -repository)
  53. if [ $2 != '!' ] ; then
  54. repository=" $2 " ; shift ; shift
  55. while [ "$1" -a -d "package/$1" ] ; do
  56. repository="$repository $1 " ; shift
  57. done
  58. else
  59. shift ; shift ; repository=""
  60. for x in $( ls package/ ) ; do
  61. [ -d "package/$x" ] &&
  62. repository="$repository $x"
  63. done
  64. repository="$repository "
  65. while [ "$1" -a -d "package/$1" ] ; do
  66. repository="${repository// $1 / }" ; shift
  67. done
  68. fi
  69. ;;
  70. -stage)
  71. stages="[$2]" ; shift ; shift ;;
  72. -logdir)
  73. logdir=$2 ; shift ; shift ;;
  74. -copydir)
  75. copydir=$2 ; shift ; shift ;;
  76. -movedir)
  77. movedir=$2 ; shift ; shift ;;
  78. -delete)
  79. delete=1 ; shift ;;
  80. -remove)
  81. remove=1 ; shift ;;
  82. -fulldelete)
  83. fulldelete=1 ; shift ;;
  84. -dry-run)
  85. dryrun=1 ; shift ;;
  86. -newdelete)
  87. newdelete=1 ; shift ;;
  88. -updated)
  89. onlyupdated=1 ; shift ;;
  90. -*)
  91. x="${0//?/ }" ; x="${x# }"
  92. echo "Usage: $0 [ -newdelete ] [ -dry-run ]"
  93. echo " $0 [ -repstat ]"
  94. echo " $0 [ -[full]delete ] [ -remove ] <package(s)>"
  95. echo " $0 [ -cfg <config> ] [ -dry-run ] \\"
  96. echo " $x [ -repository <repositories> ] [ -copydir <copydir> ] \\"
  97. echo " $x [ -movedir <movedir> ] [ -logdir <logdir> ] \\"
  98. echo " $x [ -stage <stage(s)> ] [ -[full]delete ] \\"
  99. echo " $x [ -updated ] [ -showdepc ] [ -showerr [ -showtree ] ]"
  100. echo
  101. echo " Create summaries of package builds, print statistics or schedule packages"
  102. echo " for a rebuild"
  103. echo
  104. echo " -newdelete schedule updated packages for a rebuild"
  105. echo " -dry-run don't delete anything; just print what"
  106. echo " would happen"
  107. echo " -repstat print some build statistics on repositories"
  108. echo " -delete delete logs of failed builds"
  109. echo " (for given packages)"
  110. echo " -fulldelete delete all build logs and log directory entries"
  111. echo " (for given packages)"
  112. echo " -remove schedule given packages for a rebuild"
  113. echo " -cfg <config> check this target build for errors;"
  114. echo " defaults to 'default'"
  115. echo " -repository <repositories> check only packages from the given"
  116. echo " repositories"
  117. echo " -copydir <copydir> copy logs of failed builds to this directory"
  118. echo " -movedir <movedir> move logs of failed builds to this directory"
  119. echo " -logdir <logdir> the log directory to use; defaults to "
  120. echo " build/<ROCKCFG-ID>/var/adm/logs"
  121. echo " -stage <stage> process package builds from the given stages;"
  122. echo " defaults to '0123456789' (all stages)"
  123. echo " -updated process updated instead of failed packages"
  124. echo " -showerr show the last build log lines for each"
  125. echo " processed package"
  126. echo " -showtree show a dependency tree"
  127. echo " -showdepc show the number of packages that depend on a"
  128. echo " processed package"
  129. echo
  130. echo " If packages are given without additional options, logs of failed builds are"
  131. echo " opened with 'less'."
  132. echo
  133. exit 1 ;;
  134. *)
  135. break ;;
  136. esac
  137. done
  138. . scripts/parse-config
  139. logdir="${logdir:-build/$ROCKCFG_ID/var/adm/logs}"
  140. pkgdir="${logdir%/*}/packages"
  141. if [ "$newdelete" = 1 ]; then
  142. while read xpkg
  143. do
  144. cksum1="$( grep '^ROCK Linux Package Source Checksum: ' \
  145. build/$ROCKCFG_ID/var/adm/packages/$xpkg | cut -f6 -d' '; )"
  146. if [ ! -f package/*/$xpkg/$xpkg.desc ]; then
  147. pkg="`grep "=$xpkg " config/$config/packages \
  148. | awk '{ print $5; }'`"
  149. pkg="${pkg%=*}"
  150. else
  151. pkg=$xpkg
  152. fi
  153. cksum2=$( md5sum package/*/$pkg/* 2> /dev/null | \
  154. grep -v '\.cache$' | md5sum | cut -f1 -d' ' )
  155. if [ "$cksum1" != "$cksum2" ]; then
  156. echo "Scheduling package '$xpkg' for rebuild ..."
  157. if [ "$dryrun" = 0 ]; then
  158. mine -rfs -R build/$ROCKCFG_ID $xpkg
  159. rm -f build/$ROCKCFG_ID/var/adm/*/?-$xpkg.*
  160. fi
  161. fi
  162. done < <(
  163. cd build/$ROCKCFG_ID/var/adm/packages && ls | grep -v ':'
  164. )
  165. exit 0
  166. fi
  167. if [ "$repstat" = 1 ] ; then
  168. {
  169. echo
  170. echo -e "Repository\tPkg Total\tPkg OK\tPkg Error"
  171. echo
  172. total_pkgt=0 ; total_pkgo=0 ; total_pkge=0
  173. for x in $( cd package ; echo [a-z0-9]* ) ; do
  174. pkgt=0 ; pkgo=0 ; pkge=0
  175. for y in $( cd package/$x ; echo [a-z0-9]* ) ; do
  176. if [ "$( ls $logdir/$stages-$y.err 2> /dev/null )" ]
  177. then (( pkge++ )) ; (( total_pkge++ ))
  178. elif [ "$( ls $logdir/$stages-$y.log 2> /dev/null )" ]
  179. then (( pkgo++ )) ; (( total_pkgo++ ))
  180. fi
  181. done
  182. (( pkgt = pkgo + pkge )) ; (( total_pkgt += pkgt ))
  183. [ $pkgt != 0 ] && echo -e "$x\t$pkgt\t$pkgo\t$pkge"
  184. done
  185. echo
  186. echo -e "total\t$total_pkgt\t$total_pkgo\t$total_pkge"
  187. echo
  188. } | {
  189. expand -t20,35,50 | sed 's,^, ,'
  190. }
  191. exit 0
  192. fi
  193. if [ "$1" ] ; then
  194. if [ "$fulldelete" = 1 ] ; then
  195. for x ; do
  196. rm -vf "$logdir"/$stages-$x.{err,log,out}
  197. rm -vf "$logdir"/../*/$x
  198. done
  199. elif [ "$remove" = 1 ] ; then
  200. for x ; do
  201. echo "Scheduling package '$x' for rebuild ..."
  202. mine -rf -s -R build/$ROCKCFG_ID $x
  203. rm -f build/$ROCKCFG_ID/var/adm/*/?-$x.*
  204. done
  205. elif [ "$delete" = 1 ] ; then
  206. for x ; do rm -vf "$logdir"/$stages-$x.err ; done
  207. else
  208. for x ; do less "$logdir"/$stages-$x.err ; done
  209. fi
  210. exit 0
  211. fi
  212. echo
  213. echo "Error logs from $ROCKCFG_ID:"
  214. [ $showerr = 0 ] && echo
  215. count_pkg=0
  216. count_err=0
  217. count_log=0
  218. for stagelevel in $( echo $stages | tr -d '[]' | sed 's,.,& ,g' ) ; do
  219. while read x x x tree pkg x ; do
  220. # strip base package name
  221. pkg="${pkg#*=}"
  222. [ "$repository" -a \
  223. "${repository/ $tree /}" = "$repository" ] && continue
  224. this_is_error=0
  225. if [ $onlyupdated != 0 ] ; then
  226. [ "$( bash scripts/xfind.sh package/*/$pkg -newer "$logdir/$stagelevel-$pkg.err" -o -newer "$logdir/$stagelevel-$pkg.log" )" ] && this_is_error=1
  227. elif [ -f "$logdir/$stagelevel-$pkg.err" ] ; then
  228. this_is_error=1
  229. fi
  230. if [ $this_is_error = 1 ] ; then
  231. if [ $showerr = 0 ] ; then
  232. if [ $showdepc != 0 ]; then
  233. d=$( ./scripts/Check-Deps-3 $stagelevel \
  234. $pkg config/$config/packages | \
  235. cut -f3 -d' ' | sort -u | wc -l )
  236. d="$( printf " %3d" $d )"
  237. else
  238. d=""
  239. fi
  240. echo "[$stagelevel]$d ${tree:0:13}/${pkg:0:18}"
  241. else
  242. echo ; echo "== $stagelevel-$pkg.* =="
  243. tail -n 20 "$logdir/$stagelevel-$pkg".* | \
  244. tac | perl -e '
  245. my @lines;
  246. my $counter;
  247. while (<>) {
  248. chomp;
  249. $lines[$#lines+1] = $_;
  250. }
  251. for ($counter=0; $counter <= $#lines; $counter++) {
  252. $_=$lines[$counter];
  253. if ( /^checking for .*\.\.\. *Package / ||
  254. /configure: error:/ ) {
  255. for ($_=1; $_ <= $counter; $_++) {
  256. print "$lines[$_]\n";
  257. }
  258. exit 0;
  259. }
  260. }
  261. for ($counter=0; $counter <= $#lines; $counter++) {
  262. $_=$lines[$counter];
  263. if ( /^(make\S*): / ) {
  264. my $makeprefix=$1;
  265. my $output="$_\n";
  266. while ( defined
  267. ($_=$lines[$counter++]) ) {
  268. last unless /^(make\S*): /;
  269. $output="" if $1 ne $makeprefix;
  270. $makeprefix=$1;
  271. $output.="$_\n";
  272. }
  273. print $output; exit 0;
  274. }
  275. }
  276. foreach (@lines) {
  277. print "$_\n";
  278. }
  279. ' | tac | fold -s -w79
  280. depcheck() {
  281. echo "${1}\`---> $3"
  282. for x in `grep -lwi $3 $logdir/*.err | \
  283. sed 's,.*/.-,,; s,\.err,,' | sort -u`
  284. do
  285. [ "$x" = "$3" ] && continue
  286. [ "${2/ $x /}" != "$2" ] && continue
  287. depcheck "${1} " "$2 $3 " $x
  288. done
  289. }
  290. [ $showtree = 1 ] && depcheck "" "" $pkg
  291. fi
  292. if [ "$copydir" ] ; then
  293. mkdir -p "$copydir"
  294. cp "$logdir/$stagelevel-$pkg.err" "$copydir"
  295. fi
  296. if [ "$movedir" ] ; then
  297. mkdir -p "$movedir"
  298. mv "$logdir/$stagelevel-$pkg.err" "$movedir"
  299. fi
  300. if [ "$fulldelete" -eq 1 ] ; then
  301. rm -f "$logdir"/$stages-$pkg.{err,log,out}
  302. rm -f "$logdir"/../*/$pkg
  303. elif [ "$delete" -eq 1 ] ; then
  304. rm -f "$logdir/$stagelevel-$pkg.err"
  305. fi
  306. count_err=$(( $count_err + 1 ))
  307. elif [ -f "$logdir/$stagelevel-$pkg.log" ] ; then
  308. count_log=$(( $count_log + 1 ))
  309. fi
  310. count_pkg=$(( $count_pkg + 1 ))
  311. done < <( grep "^X [0-9-]*$stagelevel" config/$config/packages )
  312. done > >(
  313. if [ $showerr = 0 ] ; then
  314. paste - - | expand -t40 | sed 's,^, ,'
  315. else cat ; fi
  316. )
  317. sleep 1
  318. echo
  319. echo "$count_pkg builds total, $count_log completed fine," \
  320. "$count_err with errors."
  321. echo