sde-commit: Changed commit message generator to use pkg: instead of [pkg]
[opensde-nopast.git] / scripts / Create-ErrList
blob1bdcc652fb1b24d97c09822e1d1fdd245c36145f
1 #!/bin/bash
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: scripts/Create-ErrList
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
7 # Copyright (C) 2004 - 2006 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 Clifford Wolf
10 # More information can be found in the files COPYING and README.
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 ---
18 config=default
19 repstat=0
20 showerr=0
21 showtree=0
22 showdepc=0
23 delete=0
24 remove=0
25 fulldelete=0
26 newdelete=0
27 onlyupdated=0
29 repository=
30 stages="[0123456789]"
31 copydir=
32 movedir=
33 logdir=
35 while [ "$1" ] ; do
36 case "$1" in
37 -cfg)
38 config=$2 ; shift ; shift ;;
40 -repstat)
41 repstat=1 ; shift ;;
43 -showerr)
44 showerr=1 ; shift ;;
46 -showtree)
47 showtree=1 ; shift ;;
49 -showdepc)
50 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
71 -stage)
72 stages="[$2]" ; shift ; shift ;;
74 -logdir)
75 logdir=$2 ; shift ; shift ;;
77 -copydir)
78 copydir=$2 ; shift ; shift ;;
80 -movedir)
81 movedir=$2 ; shift ; shift ;;
83 -delete)
84 delete=1 ; shift ;;
86 -remove)
87 remove=1 ; shift ;;
89 -fulldelete)
90 fulldelete=1 ; shift ;;
92 -newdelete)
93 newdelete=1 ; shift ;;
95 -updated)
96 onlyupdated=1 ; shift ;;
98 -dry-run)
99 dryrun=1 ; shift ;;
102 x="${0//?/ }" ; x="${x# }"
103 echo "Usage: $0 [ -cfg config ] [ -repository repository ] \\"
104 echo " $x [ -copydir copydir | -movedir movedir ] [ -repstat ] \\"
105 echo " $x [ -stage stage ] [ -logdir logdir ] [ -[full|new]delete ] \\"
106 echo " $x [ -updated ] [ -showerr ] [ -showtree ] [ -showdepc ] \\"
107 echo " $x [ -dry-run ] [-remove] [ <package> ]"
108 exit 1 ;;
111 break ;;
112 esac
113 done
115 . lib/functions.in
116 . lib/parse-config
118 logdir="${logdir:-build/$SDECFG_ID/var/adm/logs}"
119 pkgdir="${logdir%/*}/packages"
121 if [ "$newdelete" = 1 ]; then
122 while read pkg cksum1
124 cksum2=$( pkgchksum package/*/$pkg/ )
125 if [ "$cksum1" != "$cksum2" ]; then
126 echo "Scheduling package '$pkg' for rebuild ..."
127 if [ ! "$dryrun" = "1" ]; then
128 mine -rf -R build/$SDECFG_ID $pkg
129 rm -f build/$SDECFG_ID/var/adm/*/?-$pkg.*
132 done < <(
133 grep -R '^\(ROCK Linux\|T2\|OpenSDE\) Package Source Checksum: ' \
134 build/$SDECFG_ID/var/adm/packages/ |
135 sed 's,.*/\([^:]*\):.*:,\1,'
137 exit 0
140 if [ "$repstat" = 1 ] ; then
142 echo
143 echo -e "Repository\tPkg Total\tPkg OK\tPkg Error"
144 echo
145 total_pkgt=0 ; total_pkgo=0 ; total_pkge=0
146 for x in $( cd package ; echo [a-z0-9]* ) ; do
147 pkgt=0 ; pkgo=0 ; pkge=0
148 for y in $( cd package/$x ; echo [a-z0-9]* ) ; do
149 if [ "$( ls $logdir/$stages-$y.err 2> /dev/null )" ]
150 then (( pkge++ )) ; (( total_pkge++ ))
151 elif [ "$( ls $logdir/$stages-$y.log 2> /dev/null )" ]
152 then (( pkgo++ )) ; (( total_pkgo++ ))
154 done
155 (( pkgt = pkgo + pkge )) ; (( total_pkgt += pkgt ))
156 [ $pkgt != 0 ] && echo -e "$x\t$pkgt\t$pkgo\t$pkge"
157 done
158 echo
159 echo -e "total\t$total_pkgt\t$total_pkgo\t$total_pkge"
160 echo
161 } | {
162 expand -t20,35,50 | sed 's,^, ,'
164 exit 0
167 if [ "$1" ] ; then
168 if [ "$fulldelete" = 1 ] ; then
169 for x ; do
170 rm -vf "$logdir"/$stages-$x.{err,log,out}
171 rm -vf "$logdir"/../*/$x
172 done
173 elif [ "$remove" = 1 ] ; then
174 for x ; do
175 echo "Scheduling package '$x' for rebuild ..."
176 mine -rf -R build/$SDECFG_ID $x
177 rm -f build/$SDECFG_ID/var/adm/*/?-$x.*
178 done
179 elif [ "$delete" = 1 ] ; then
180 for x ; do rm -vf "$logdir"/$stages-$x.err ; done
181 else
182 for x ; do less "$logdir"/$stages-$x.err ; done
184 exit 0
187 echo
188 echo "Error logs from $SDECFG_ID:"
189 [ $showerr = 0 ] && echo
191 count_pkg=0
192 count_err=0
193 count_log=0
195 for stagelevel in $( echo "$stages" | tr -d '[]' | sed 's,.,& ,g' ) ; do
196 while read x x x tree pkg x ; do
197 [ "$repository" -a \
198 "${repository/ $tree /}" = "$repository" ] && continue
200 this_is_error=0
201 if [ $onlyupdated != 0 ] ; then
202 [ "$( bin/find package/*/$pkg -newer "$logdir/$stagelevel-$pkg.err" -o -newer "$logdir/$stagelevel-$pkg.log" )" ] && this_is_error=1
203 elif [ -f "$logdir/$stagelevel-$pkg.err" ] ; then
204 this_is_error=1
207 if [ $this_is_error = 1 ] ; then
208 if [ $showerr = 0 ] ; then
209 if [ $showdepc != 0 ]; then
210 d=$( ./scripts/Check-Deps-3 $stagelevel \
211 $pkg config/$config/packages | \
212 cut -f3 -d' ' | sort -u | wc -l )
213 d="$( printf " %3d" $d )"
214 else
217 echo "[$stagelevel]$d ${tree:0:13}/${pkg:0:18}"
218 else
219 echo ; echo "== $stagelevel-$pkg.* =="
220 tail -n 20 "$logdir/$stagelevel-$pkg".* | \
221 tac | perl -e '
222 my @lines;
223 my $counter;
224 while (<>) {
225 chomp;
226 $lines[$#lines+1] = $_;
228 for ($counter=0; $counter <= $#lines; $counter++) {
229 $_=$lines[$counter];
230 if ( /^checking for .*\.\.\. *Package / ||
231 /configure: error:/ ) {
232 for ($_=1; $_ <= $counter; $_++) {
233 print "$lines[$_]\n";
235 exit 0;
238 for ($counter=0; $counter <= $#lines; $counter++) {
239 $_=$lines[$counter];
240 if ( /^(make\S*): / ) {
241 my $makeprefix=$1;
242 my $output="$_\n";
243 while ( defined
244 ($_=$lines[$counter++]) ) {
245 last unless /^(make\S*): /;
246 $output="" if $1 ne $makeprefix;
247 $makeprefix=$1;
248 $output.="$_\n";
250 print $output; exit 0;
253 foreach (@lines) {
254 print "$_\n";
256 ' | tac | fold -s -w79
257 depcheck() {
258 echo "${1}\`---> $3"
259 for x in `grep -lwi $3 $logdir/*.err | \
260 sed 's,.*/.-,,; s,\.err,,' | sort -u`
262 [ "$x" = "$3" ] && continue
263 [ "${2/ $x /}" != "$2" ] && continue
264 depcheck "${1} " "$2 $3 " $x
265 done
267 [ $showtree = 1 ] && depcheck "" "" $pkg
269 if [ "$copydir" ] ; then
270 mkdir -p "$copydir"
271 cp "$logdir/$stagelevel-$pkg.err" "$copydir"
273 if [ "$movedir" ] ; then
274 mkdir -p "$movedir"
275 mv "$logdir/$stagelevel-$pkg.err" "$movedir"
277 if [ "$fulldelete" -eq 1 ] ; then
278 rm -f "$logdir"/$stages-$pkg.{err,log,out}
279 rm -f "$logdir"/../*/$pkg
280 elif [ "$delete" -eq 1 ] ; then
281 rm -f "$logdir/$stagelevel-$pkg.err"
283 count_err=$(( $count_err + 1 ))
284 elif [ -f "$logdir/$stagelevel-$pkg.log" ] ; then
285 count_log=$(( $count_log + 1 ))
287 count_pkg=$(( $count_pkg + 1 ))
288 done < <( grep "^X [0-9-]*$stagelevel" config/$config/packages )
289 done > >(
290 if [ $showerr = 0 ] ; then
291 paste - - | expand -t40 | sed 's,^, ,'
292 else cat ; fi
295 sleep 1
296 echo
297 echo "$count_pkg builds total, $count_log completed fine," \
298 "$count_err with errors."
299 echo