* mark python sqlite DEP opt and update .cache
[t2sde.git] / scripts / Create-ErrList
blob29689df9e796663a6d01e531dabbd3634b7263ce
1 #!/usr/bin/env bash
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # T2 SDE: scripts/Create-ErrList
5 # Copyright (C) 2004 - 2023 The T2 SDE Project
6 # Copyright (C) 1998 - 2003 ROCK Linux Project
7 #
8 # This Copyright note is generated by scripts/Create-CopyPatch,
9 # more information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License version 2.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 config=default
16 repstat=0
17 showerr=0
18 showtree=0
19 showdepc=0
20 delete=0
21 remove=0
22 fulldelete=0
23 newdelete=0
24 newresched=0
25 onlyupdated=0
27 repository=""
28 stages="[0123456789]"
29 copydir=""
30 movedir=""
31 logdir=""
33 # uninstall sysroot package
34 uninstall_pkg() {
35 pushd $1 > /dev/null
36 cut -d ' ' -f 2- var/adm/flists/$2 | tac | while read fn; do
37 if [ -d "$fn" ]; then rmdir "$fn"
38 else rm -f "$fn"; fi
39 done
40 popd > /dev/null
43 while [ "$1" ]; do
44 case "$1" in
45 -cfg)
46 config=$2 ; shift; shift ;;
48 -repstat)
49 repstat=1 ; shift ;;
51 -showerr)
52 showerr=1 ; shift ;;
54 -showtree)
55 showtree=1 ; shift ;;
57 -showdepc)
58 showdepc=1 ; shift ;;
60 -repository)
61 if [ $2 != '!' ]; then
62 repository=" $2 "; shift; shift
63 while [ "$1" -a -d "package/$1" ]; do
64 repository="$repository $1 "; shift
65 done
66 else
67 shift; shift; repository=""
68 for x in $(ls package/); do
69 [ -d "package/$x" ] &&
70 repository="$repository $x"
71 done
72 repository="$repository "
73 while [ "$1" -a -d "package/$1" ]; do
74 repository="${repository// $1 / }"; shift
75 done
79 -stage)
80 stages="[$2]" ; shift; shift ;;
82 -logdir)
83 logdir=$2 ; shift; shift ;;
85 -copydir)
86 copydir=$2 ; shift; shift ;;
88 -movedir)
89 movedir=$2 ; shift; shift ;;
91 -delete)
92 delete=1 ; shift ;;
94 -remove)
95 remove=1 ; shift ;;
97 -fulldelete)
98 fulldelete=1 ; shift ;;
100 -newdelete)
101 newdelete=1 ; shift ;;
103 -newresched|-newreschedule)
104 newresched=1 ; shift ;;
106 -updated)
107 onlyupdated=1 ; shift ;;
109 -dry-run)
110 dryrun=1 ; shift ;;
113 x="${0//?/ }" x="${x# }"
114 echo "Usage: $0 [ -cfg config ] [ -repository repository ] \\"
115 echo " $x [ -copydir copydir | -movedir movedir ] [ -repstat ] \\"
116 echo " $x [ -stage stage ] [ -logdir logdir ] [ -remove ] [ -[full]delete -new[delete|resched] \\"
117 echo " $x [ -updated ] [ -showerr ] [ -showtree ] [ -showdepc ] \\"
118 echo " $x [ -dry-run ] [ <package> ]"
119 exit 1 ;;
122 break ;;
123 esac
124 done
126 . scripts/parse-config
127 . scripts/functions.in
129 logdir="${logdir:-build/$SDECFG_ID/var/adm/logs}"
131 if [ "$newdelete" = 1 -o "$newresched" = 1 ]; then
132 while read pkg cksum1; do
133 cksum2=$(pkgchksum package/*/$pkg/)
134 if [ "$cksum1" != "$cksum2" ]; then
135 if [ "$newdelete" = 1 ]; then
136 echo "Removing package '$pkg' ..."
137 [ "$dryrun" = "1" ] || uninstall_pkg build/$SDECFG_ID $pkg
138 [ "$dryrun" = "1" ] || rm -f build/$SDECFG_ID/var/adm/*/?-$pkg.*
139 else
140 echo "Scheduling package '$pkg' for rebuild ..."
141 [ "$dryrun" = "1" ] || rm -f build/$SDECFG_ID/var/adm/*/?-$pkg.*
144 done < <(
145 grep -R '^\(ROCK Linux\|T2\) Package Source Checksum: ' \
146 build/$SDECFG_ID/var/adm/packages/ |
147 sed 's,.*/\([^:]*\):.*:,\1,'
149 exit 0
152 if [ "$repstat" = 1 ]; then
154 echo
155 echo -e "Repository\tPkg Total\tPkg OK\tPkg Error"
156 echo
157 total_pkgt=0 total_pkgo=0 total_pkge=0
158 for x in $(cd package; echo [a-z0-9]*); do
159 pkgt=0 pkgo=0 pkge=0
160 for y in $(cd package/$x; echo [a-z0-9]*); do
161 if [ "$(ls $logdir/$stages-$y.err 2> /dev/null)" ]
162 then ((pkge++)); ((total_pkge++))
163 elif [ "$(ls $logdir/$stages-$y.log 2> /dev/null)" ]
164 then ((pkgo++)); ((total_pkgo++))
166 done
167 ((pkgt = pkgo + pkge)); ((total_pkgt += pkgt))
168 [ $pkgt != 0 ] && echo -e "$x\t$pkgt\t$pkgo\t$pkge"
169 done
170 echo
171 echo -e "total\t$total_pkgt\t$total_pkgo\t$total_pkge"
172 echo
173 } | {
174 expand -t20,35,50 | sed 's,^, ,'
176 exit 0
179 if [ "$1" ]; then
180 if [ "$fulldelete" = 1 ]; then
181 for x; do
182 rm -vf "$logdir"/$stages-$x.{err,log,out}
183 rm -vf "$logdir"/../*/$x
184 done
185 elif [ "$remove" = 1 ]; then
186 for x; do
187 echo "Scheduling package '$x' for rebuild ..."
188 uninstall_pkg build/$SDECFG_ID $x
189 rm -f build/$SDECFG_ID/var/adm/*/$stages-$x.{err,log,out}
190 done
191 elif [ "$delete" = 1 ]; then
192 for x; do rm -vf "$logdir"/$stages-$x.{err,log,out}; done
193 else
194 for x; do less "$logdir"/$stages-$x.err; done
196 exit 0
199 echo
200 echo "Error logs from $SDECFG_ID:"
201 [ $showerr = 0 ] && echo
203 count_pkg=0
204 count_err=0
205 count_log=0
207 for stagelevel in $(echo "$stages" | sed 's,[][],,g; s,.,& ,g'); do
208 while read x x x tree pkg x; do
209 [ "$repository" -a \
210 "${repository/ $tree /}" = "$repository" ] && continue
212 this_is_error=0
213 if [ $onlyupdated != 0 ]; then
214 [ "$(bash scripts/xfind.sh package/*/$pkg -newer "$logdir/$stagelevel-$pkg.err" -o -newer "$logdir/$stagelevel-$pkg.log")" ] && this_is_error=1
215 elif [ -f "$logdir/$stagelevel-$pkg.err" ]; then
216 this_is_error=1
219 if [ $this_is_error = 1 ]; then
220 if [ $showerr = 0 ]; then
221 if [ $showdepc != 0 ]; then
222 d=$(scripts/Check-Deps-3 $stagelevel \
223 $pkg config/$config/packages |
224 cut -f3 -d' ' | sort -u | wc -l)
225 d="$(printf " %3d" $d)"
226 else
227 d=""
229 echo "[$stagelevel]$d ${tree:0:13}/${pkg:0:18}"
230 else
231 echo; echo "== $stagelevel-$pkg.* =="
232 tail -n 20 "$logdir/$stagelevel-$pkg".* |
233 tac | perl -e '
234 my @lines;
235 my $counter;
236 while (<>) {
237 chomp;
238 $lines[$#lines+1] = $_;
240 for ($counter=0; $counter <= $#lines; $counter++) {
241 $_=$lines[$counter];
242 if (/^checking for .*\.\.\. *Package / ||
243 /configure: error:/) {
244 for ($_=1; $_ <= $counter; $_++) {
245 print "$lines[$_]\n";
247 exit 0;
250 for ($counter=0; $counter <= $#lines; $counter++) {
251 $_=$lines[$counter];
252 if (/^(make\S*): /) {
253 my $makeprefix=$1;
254 my $output="$_\n";
255 while (defined
256 ($_=$lines[$counter++])) {
257 last unless /^(make\S*): /;
258 $output="" if $1 ne $makeprefix;
259 $makeprefix=$1;
260 $output.="$_\n";
262 print $output; exit 0;
265 foreach (@lines) {
266 print "$_\n";
268 ' | tac | fold -s -w79
269 depcheck() {
270 echo "${1}\`---> $3"
271 for x in `grep -lwi $3 $logdir/*.err |
272 sed 's,.*/.-,,; s,\.err,,' | sort -u`
274 [ "$x" = "$3" ] && continue
275 [ "${2/ $x /}" != "$2" ] && continue
276 depcheck "${1} " "$2 $3 " $x
277 done
279 [ $showtree = 1 ] && depcheck "" "" $pkg
281 if [ "$copydir" ]; then
282 mkdir -p "$copydir"
283 cp "$logdir/$stagelevel-$pkg.err" "$copydir"
285 if [ "$movedir" ]; then
286 mkdir -p "$movedir"
287 mv "$logdir/$stagelevel-$pkg.err" "$movedir"
289 if [ "$fulldelete" -eq 1 ]; then
290 rm -f "$logdir"/$stages-$pkg.{err,log,out}
291 rm -f "$logdir"/../*/$pkg
292 elif [ "$delete" -eq 1 ]; then
293 rm -f "$logdir/$stagelevel-$pkg.err"
295 ((count_err++))
296 elif [ -f "$logdir/$stagelevel-$pkg.log" ]; then
297 ((count_log++))
299 ((count_pkg++))
300 done < <(grep "^X [0-9-]*$stagelevel" config/$config/packages)
301 done > >(
302 if [ $showerr = 0 ]; then
303 paste - - | expand -t40 | sed 's,^, ,'
304 else cat; fi
307 sleep 0
308 echo
309 echo "$count_pkg builds total, $count_log completed fine," \
310 "$count_err with errors, $((count_pkg - count_log - count_err)) to go."
311 echo