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.

319 lines
7.7 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 - 2003 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 [ -cfg config ] [ -repository repository ] \\"
  93. echo " $x [ -copydir copydir | -movedir movedir ] [ -repstat ] \\"
  94. echo " $x [ -stage stage ] [ -logdir logdir ] [ -[full|new]delete ] \\"
  95. echo " $x [ -updated ] [ -showerr [ -showtree ] [ -showdepc ] | <package> ]"
  96. exit 1 ;;
  97. *)
  98. break ;;
  99. esac
  100. done
  101. . scripts/parse-config
  102. logdir="${logdir:-build/$ROCKCFG_ID/var/adm/logs}"
  103. pkgdir="${logdir%/*}/packages"
  104. if [ "$newdelete" = 1 ]; then
  105. while read xpkg cksum1
  106. do
  107. if [ ! -f package/*/$xpkg/$xpkg.desc ]; then
  108. pkg="`grep =$xpkg config/$config/packages \
  109. | awk '{ print $5; }'`"
  110. pkg="${pkg%=*}"
  111. else
  112. pkg=$xpkg
  113. fi
  114. cksum2=$( md5sum package/*/$pkg/* 2> /dev/null | \
  115. grep -v '\.cache$' | md5sum | cut -f1 -d' ' )
  116. if [ "$cksum1" != "$cksum2" ]; then
  117. echo "Scheduling package '$xpkg' for rebuild ..."
  118. if [ "$dryrun" = 0 ]; then
  119. mine -rf -R build/$ROCKCFG_ID $xpkg
  120. rm -f build/$ROCKCFG_ID/var/adm/*/?-$xpkg.*
  121. fi
  122. fi
  123. done < <(
  124. grep '^ROCK Linux Package Source Checksum: ' \
  125. build/$ROCKCFG_ID/var/adm/packages/* |
  126. tr '/:' ' ' | cut -f6,13 -d' '
  127. )
  128. exit 0
  129. fi
  130. if [ "$repstat" = 1 ] ; then
  131. {
  132. echo
  133. echo -e "Repository\tPkg Total\tPkg OK\tPkg Error"
  134. echo
  135. total_pkgt=0 ; total_pkgo=0 ; total_pkge=0
  136. for x in $( cd package ; echo [a-z0-9]* ) ; do
  137. pkgt=0 ; pkgo=0 ; pkge=0
  138. for y in $( cd package/$x ; echo [a-z0-9]* ) ; do
  139. if [ "$( ls $logdir/$stages-$y.err 2> /dev/null )" ]
  140. then (( pkge++ )) ; (( total_pkge++ ))
  141. elif [ "$( ls $logdir/$stages-$y.log 2> /dev/null )" ]
  142. then (( pkgo++ )) ; (( total_pkgo++ ))
  143. fi
  144. done
  145. (( pkgt = pkgo + pkge )) ; (( total_pkgt += pkgt ))
  146. [ $pkgt != 0 ] && echo -e "$x\t$pkgt\t$pkgo\t$pkge"
  147. done
  148. echo
  149. echo -e "total\t$total_pkgt\t$total_pkgo\t$total_pkge"
  150. echo
  151. } | {
  152. expand -t20,35,50 | sed 's,^, ,'
  153. }
  154. exit 0
  155. fi
  156. if [ "$1" ] ; then
  157. if [ "$fulldelete" = 1 ] ; then
  158. for x ; do
  159. rm -vf "$logdir"/$stages-$x.{err,log,out}
  160. rm -vf "$logdir"/../*/$x
  161. done
  162. elif [ "$remove" = 1 ] ; then
  163. for x ; do
  164. echo "Scheduling package '$x' for rebuild ..."
  165. mine -rf -R build/$ROCKCFG_ID $x
  166. rm -f build/$ROCKCFG_ID/var/adm/*/?-$x.*
  167. done
  168. elif [ "$delete" = 1 ] ; then
  169. for x ; do rm -vf "$logdir"/$stages-$x.err ; done
  170. else
  171. for x ; do less "$logdir"/$stages-$x.err ; done
  172. fi
  173. exit 0
  174. fi
  175. echo
  176. echo "Error logs from $ROCKCFG_ID:"
  177. [ $showerr = 0 ] && echo
  178. count_pkg=0
  179. count_err=0
  180. count_log=0
  181. for stagelevel in $( echo $stages | tr -d '[]' | sed 's,.,& ,g' ) ; do
  182. while read x x x tree pkg x ; do
  183. # strip base package name
  184. pkg="${pkg#*=}"
  185. [ "$repository" -a \
  186. "${repository/ $tree /}" = "$repository" ] && continue
  187. this_is_error=0
  188. if [ $onlyupdated != 0 ] ; then
  189. [ "$( bash scripts/xfind.sh package/*/$pkg -newer "$logdir/$stagelevel-$pkg.err" -o -newer "$logdir/$stagelevel-$pkg.log" )" ] && this_is_error=1
  190. elif [ -f "$logdir/$stagelevel-$pkg.err" ] ; then
  191. this_is_error=1
  192. fi
  193. if [ $this_is_error = 1 ] ; then
  194. if [ $showerr = 0 ] ; then
  195. if [ $showdepc != 0 ]; then
  196. d=$( ./scripts/Check-Deps-3 $stagelevel \
  197. $pkg config/$config/packages | \
  198. cut -f3 -d' ' | sort -u | wc -l )
  199. d="$( printf " %3d" $d )"
  200. else
  201. d=""
  202. fi
  203. echo "[$stagelevel]$d ${tree:0:13}/${pkg:0:18}"
  204. else
  205. echo ; echo "== $stagelevel-$pkg.* =="
  206. tail -n 20 "$logdir/$stagelevel-$pkg".* | \
  207. tac | perl -e '
  208. my @lines;
  209. my $counter;
  210. while (<>) {
  211. chomp;
  212. $lines[$#lines+1] = $_;
  213. }
  214. for ($counter=0; $counter <= $#lines; $counter++) {
  215. $_=$lines[$counter];
  216. if ( /^checking for .*\.\.\. *Package / ||
  217. /configure: error:/ ) {
  218. for ($_=1; $_ <= $counter; $_++) {
  219. print "$lines[$_]\n";
  220. }
  221. exit 0;
  222. }
  223. }
  224. for ($counter=0; $counter <= $#lines; $counter++) {
  225. $_=$lines[$counter];
  226. if ( /^(make\S*): / ) {
  227. my $makeprefix=$1;
  228. my $output="$_\n";
  229. while ( defined
  230. ($_=$lines[$counter++]) ) {
  231. last unless /^(make\S*): /;
  232. $output="" if $1 ne $makeprefix;
  233. $makeprefix=$1;
  234. $output.="$_\n";
  235. }
  236. print $output; exit 0;
  237. }
  238. }
  239. foreach (@lines) {
  240. print "$_\n";
  241. }
  242. ' | tac | fold -s -w79
  243. depcheck() {
  244. echo "${1}\`---> $3"
  245. for x in `grep -lwi $3 $logdir/*.err | \
  246. sed 's,.*/.-,,; s,\.err,,' | sort -u`
  247. do
  248. [ "$x" = "$3" ] && continue
  249. [ "${2/ $x /}" != "$2" ] && continue
  250. depcheck "${1} " "$2 $3 " $x
  251. done
  252. }
  253. [ $showtree = 1 ] && depcheck "" "" $pkg
  254. fi
  255. if [ "$copydir" ] ; then
  256. mkdir -p "$copydir"
  257. cp "$logdir/$stagelevel-$pkg.err" "$copydir"
  258. fi
  259. if [ "$movedir" ] ; then
  260. mkdir -p "$movedir"
  261. mv "$logdir/$stagelevel-$pkg.err" "$movedir"
  262. fi
  263. if [ "$fulldelete" -eq 1 ] ; then
  264. rm -f "$logdir"/$stages-$pkg.{err,log,out}
  265. rm -f "$logdir"/../*/$pkg
  266. elif [ "$delete" -eq 1 ] ; then
  267. rm -f "$logdir/$stagelevel-$pkg.err"
  268. fi
  269. count_err=$(( $count_err + 1 ))
  270. elif [ -f "$logdir/$stagelevel-$pkg.log" ] ; then
  271. count_log=$(( $count_log + 1 ))
  272. fi
  273. count_pkg=$(( $count_pkg + 1 ))
  274. done < <( grep "^X [0-9-]*$stagelevel" config/$config/packages )
  275. done > >(
  276. if [ $showerr = 0 ] ; then
  277. paste - - | expand -t40 | sed 's,^, ,'
  278. else cat ; fi
  279. )
  280. sleep 1
  281. echo
  282. echo "$count_pkg builds total, $count_log completed fine," \
  283. "$count_err with errors."
  284. echo