12 suppressrepeatedemails=false
13 arch=`dpkg --print-architecture`
15 for config in "$@"; do
17 *=*) eval "$config" ;;
23 echo >&2 'disabled because config inadequate (no disable=false)'
27 : ${destdirtail:=$distro-$target}
28 : ${destdirfin:="$destdircommon$destdirtail"}
37 descx="${target#binary-}"
40 echo >&2 'target must be source or binary-*'
45 printf >&3 "starting "
53 echo '(log diverted to stdout)' >>"$tmp"/_log_raw
55 exec >>"$tmp"/_log_raw
60 echo "++++++ $1 ++++++"
64 progress "fetching $1"
68 gurl "$mirror/dists/$distro/$suite/$target/$sources.gz" "$tmp"/_$sources.gz
69 zcat "$tmp"/_$sources.gz >"$tmp"/_$sources-in
71 lastinfo="$var"/lastinfo-$target
72 : "${scorelog:="$var"/scores-$target}"
79 if test $target = source; then
80 blacklist="$blacklistsourcepackages"
82 blacklist="$blacklistbinarypackages"
85 if [ "x$pkg" = x ]; then
90 $vre= "[-+.0-9a-zA-Z:~]+";
92 sub f1() { $fn=shift @ARGV; open F, $fn or die "$fn $!"; }
93 sub f2() { F->error and die "$fn $!"; close F or die "$fn $!"; }
95 $scorelog= "'"$scorelog"'";
96 if (length $scorelog) { open SCORE, "> $scorelog.new" or die $!; }
98 return unless length $scorelog;
99 printf SCORE "%$_[1]s", $_[0] or die $!;
102 sub readpkglist ($$) {
103 my ($arrayref, $filename) = @_;
104 return unless length $filename;
105 unshift @ARGV, $filename; f1();
107 next if m/^\#/ or !m/\S/;
108 die unless m/^($pre)\s*$/;
113 readpkglist(\%suppress, "'"$suppresspackages"'");
114 readpkglist(\%blacklist, "'"$blacklist"'");
118 die unless m/^($pre) ($vre) (\d+)( .*)?$/;
126 sub scorepackage () {
127 return if length $skip;
128 return if $blacklist{$package};
129 return if $score < $best_score
130 or ($score==$best_score and \
131 $package gt $best_package);
132 #printf STDERR " <----- best score=%s best_score=%s\n", $score, $best_score;
135 $best_package= $package;
138 return unless (defined $package
142 die unless defined $package;
143 die unless defined $version;
144 $source= $package if !defined $source;
146 $score= '$now' - $lasttime{$package};
147 pscore("$package ",-30);
148 pscore("$source ",-25);
155 pscore(" $lastver{$package}",-25);
156 pscore(" $version ",-25);
158 if ($lastver{$package} ne $version) {
162 if ($extras{$package} =~ m/ nt /) {
167 if ($suppress{$source}) {
171 $scorechars.="[$skip]" if length $skip;
173 pscore("-$scorechars",-7);
176 #print STDERR "SCORE package=$package score $score source=$source\n";
185 if (m/^Package: ($pre)$/) {
186 die if defined $package;
188 } elsif (m/^Version: ($vre)$/) {
189 die if defined $version;
191 } elsif (m/^Source: ($pre)$/) {
192 die if defined $source;
194 } elsif (m/^Architecture:.*/ &&
195 !m/\s(?:'$arch'|all|any)\s/) {
196 #printf STDERR " <----- skip %s %s\n", $&, "'$arch'";
204 if (length $scorelog) {
205 close SCORE or die $!;
206 rename "$scorelog.new","$scorelog" or die $!;
208 die unless length $best_package;
209 open L, ">&4" or die $!;
210 printf L "selected %s (age %s, score %d)\n",
212 exists($lastime{$best_package})
213 ? '$now' - $lasttime{$best_package}
216 print "$best_package\n" or die $!;
217 ' "$lastinfo" "$tmp"/_$sources-in`"
219 printf >&4 "package forced: %s\n" "$pkg"
222 sed -n "/^Package: $pkg\$/,/^\$/p" \
223 <"$tmp"/_$sources-in >"$tmp"/_this-stanza
226 cat "$tmp"/_this-stanza
230 sed -n '\''s/^'$1': //p'\'' \
235 printf >&3 "selected \"%s\" " $pkg
238 mkdir "$tp" "$tp/src" "$tp/tmp" "$tp/out"
243 if [ "x$pSource" != x ]; then
249 if test $target = source; then
252 sed -n '/^Files:/,/^([^ ].*)?$/{ /^ /{
253 s/^ [0-9a-z][0-9a-z]* *[0-9][0-9]* //; p
257 for leafname in $leafnames; do
258 df="$tp/src/$leafname"
260 */*|.*) echo >&2 "bad leafname: $leafname"; exit 1;;
263 gurl "$mirror/$pDirectory/$leafname" "$df"
268 : ${upload_if_ok:=true}
269 email_package_header="$email_sourcepackage_header"
272 fot="$tp/src/$pkg.deb"
273 gurl "$mirror/$pFilename" "$fot"
274 testmode='--binaries=install --binary'
275 testmode2=--instantiate
277 : ${upload_if_ok:=false}
278 email_package_header="$email_binarypackage_header"
281 if [ "x$maintainer_email_override" = x ]; then
283 maintainer_email=pMaintainer
285 maintainer_email=maintainer_email_override
288 printf >&3 "adt-run "
290 progress "starting test"
300 echo 'fatal: adt-run did not start properly' >"$tmp"/_summary
302 xrc adt-run --tmp-dir "$tp"/tmp \
303 --output-dir "$tp"/out \
304 --log-file "$tp"/log \
305 --summary "$tmp"/_summary \
307 $testmode "$fot" $testmode2 \
310 $adtvirt_extra_opts \
319 : ${upload_if_notests:=false}
323 0) summary='all OK'; email=''
324 upload=$upload_if_ok ;;
325 2) summary='OK (some skipped)'; email=''
326 upload=$upload_if_ok ;;
327 8) summary='package declares no tests'; email=''
328 upload=$upload_if_notests; extras='nt' ;;
329 4|6) summary='test(s) failed!'; email="$maintainer_email" ;;
330 12) summary='erroneous package!'; email="$maintainer_email" ;;
331 16) summary='testbed failed!'; email="administrator_email" ;;
332 *) summary='unexpected failure!'; email="administrator_email"; ourx=20;;
335 progress "RESULTS $summary"
337 if [ "x$suppresspackages" != x ] \
338 && grep -x "$src" "$suppresspackages" >/dev/null; then
339 printf >&3 "email-suppressed "
345 printf "\n%s\n" "$summary" >>"$tmp"/_summary
347 edest=${email%_email}
348 esummary="$var"/emailed/last-$pkg,$edest
349 if [ "x$edest" = x ]; then
350 printf >&3 "email-none "
351 rm -f "$var"/emailed/last-$pkg,*
353 elif $suppressrepeatedemails \
354 && [ -f "$esummary" ] \
355 && diff -u "$esummary" "$tmp"/_summary >"$var"/emailed/diff-$pkg; then
356 printf >&3 "email-same $email "
360 cp "$tmp"/_summary "$esummary".new
363 ln -f "$tmp"/_summary "$tp"/summary
365 for odir in tmp out; do
366 if test -d "$tp"/$odir; then
367 GZIP=-2 tar -f "$tp"/$odir.tar.gz -C "$tp" -zc $odir
373 printf >&3 "uploading"
374 $rsync -rltH --safe-links --delete "$tp" "$destrsynchead/$destdirfin/"
378 if [ "x$email" != x ]; then
379 progress "contacting $email"
380 eval "email_addr=\$$email"
381 printf >&3 "email \"%s\" " "$email_addr"
382 cat >"$tmp"/_email_header <<END
385 Subject: autopkgtest $distro $desc: $summary
389 email_package_header="${email_package_header//@p/$pkg}"
390 email_package_header="${email_package_header//@s/$src}"
391 email_package_header="${email_package_header//@v/$pVersion}"
392 email_package_header="${email_package_header//@a/@}"
393 printf >"$tmp"/_email "%s" "$email_package_header"
395 cat >>"$tmp"/_email <<END
396 Test executed for: $distro $target $pkg
399 sed -e 's/^/ /' "$tmp"/_summary >>"$tmp"/_email
400 cat >>"$tmp"/_email <<END
402 This message is automatically generated by the autopkgtest package
403 testing system. You are receiving it because:
407 cat >>"$tmp"/_email <<END
408 You are listed in the Maintainer field of the $pkg package in $distro
409 and the test results appear to indicate a problem with the package.
412 maintainer_email_override)
413 cat >>"$tmp"/_email <<END
414 The test results appear to indicate a problem with the package
415 and reports for package maintainers for $distro are being directed to
416 $maintainer_email_override
420 cat >>"$tmp"/_email <<END
421 You are the administrator for the autopkgtest installation.
425 echo >&2 "huh email $email is what why?"
429 cat >>"$tmp/_email" <<END
431 The test log, which is intended to be sufficient to diagnose most
432 failures, can be found below. However, in case this is not
433 sufficient, another copy can be found along with output files, saved
434 temporary files, and so on, at:
435 $desthttphead/$destdirfin/
437 If you have any questions about this service please contact me at:
447 printf >>"$var"/log "%s=%s rc=%s emailed='%s'\n" \
448 "$target" "$pkg" $rc "$email_addr"
450 if [ "x$ourx" = x0 ]; then
451 sed -e "/^$pkg /d" <"$lastinfo" >"$lastinfo".new
452 printf "%s %s %s %s\n" "$pkg" "$pVersion" "$now" "$extras" \
454 mv "$lastinfo".new "$lastinfo"
457 progress "fault ($ourx)."
460 perl <"$tmp"/_log_raw >"$tmp"/_log -pe '
461 s/[^\012\040-\133\135-\176]/
465 $& eq "\\" ? "\\\\" :
466 sprintf "\\x%02x", ord $&
469 if [ "x$email" = x ]; then
470 if $interactive; then
474 cat >>"$tmp"/_email 2>&1 "$tmp"/_log ||:
476 if [ "x$email_signing_key" != x ]; then
477 printf >&3 "signing "
479 gpg -u"$email_signing_key" --clearsign \
480 <"$tmp/_email" >"$tmp/_email.asc"
481 mv -f "$tmp/_email.asc" "$tmp/_email"
483 cat "$tmp/_email_header" "$tmp/_email" >"$tmp/_email.new"
484 mv -f "$tmp/_email.new" "$tmp/_email"
486 if $interactive; then
487 cat "$tmp"/_email >&2
489 sendmail -odi -oem -t -oi <"$tmp"/_email
490 if [ "x$esummary" != x ]; then
491 printf >&3 "email-recorded "
492 mv "$esummary".new "esummary"
497 printf >&3 "done %s.\n" $ourx