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 [ "x$pkg" = x ]; then
84 $vre= "[-+.0-9a-zA-Z:~]+";
86 sub f1() { $fn=shift @ARGV; open F, $fn or die "$fn $!"; }
87 sub f2() { F->error and die "$fn $!"; close F or die "$fn $!"; }
89 $scorelog= "'"$scorelog"'";
90 if (length $scorelog) { open SCORE, "> $scorelog.new" or die $!; }
92 return unless length $scorelog;
93 printf SCORE "%$_[1]s", $_[0] or die $!;
96 $suppresspackages= "'"$suppresspackages"'";
97 if (length $suppresspackages) {
98 unshift @ARGV, $suppresspackages; f1();
100 next if m/^\#/ or !m/\S/;
101 die unless m/^($pre)\s*$/;
102 #print STDERR "SUPPRESS GOT $1\n";
110 die unless m/^($pre) ($vre) (\d+)( .*)?$/;
118 sub scorepackage () {
120 return if $score < $best_score
121 or ($score==$best_score and \
122 $package gt $best_package);
123 #printf STDERR " <----- best score=%s best_score=%s\n", $score, $best_score;
126 $best_package= $package;
129 return unless (defined $package
133 die unless defined $package;
134 die unless defined $version;
135 $source= $package if !defined $source;
137 $score= '$now' - $lasttime{$package};
138 pscore("$package ",-30);
139 pscore("$source ",-25);
146 pscore(" $lastver{$package}",-25);
147 pscore(" $version ",-25);
149 if ($lastver{$package} ne $version) {
153 if ($extras{$package} =~ m/ nt /) {
158 if ($suppress{$source}) {
162 pscore("-$scorechars",-5);
165 #print STDERR "SCORE package=$package score $score source=$source\n";
174 if (m/^Package: ($pre)$/) {
175 die if defined $package;
177 } elsif (m/^Version: ($vre)$/) {
178 die if defined $version;
180 } elsif (m/^Source: ($pre)$/) {
181 die if defined $source;
183 } elsif (m/^Architecture:.*/ &&
184 !m/\s(?:'$arch'|all|any)\s/) {
185 #printf STDERR " <----- skip %s %s\n", $&, "'$arch'";
193 if (length $scorelog) {
194 close SCORE or die $!;
195 rename "$scorelog.new","$scorelog" or die $!;
197 die unless length $best_package;
198 open L, ">&4" or die $!;
199 printf L "selected %s (age %s, score %d)\n",
201 exists($lastime{$best_package})
202 ? '$now' - $lasttime{$best_package}
205 print "$best_package\n" or die $!;
206 ' "$lastinfo" "$tmp"/_$sources-in`"
208 printf >&4 "package forced: %s\n" "$pkg"
211 sed -n "/^Package: $pkg\$/,/^\$/p" \
212 <"$tmp"/_$sources-in >"$tmp"/_this-stanza
215 cat "$tmp"/_this-stanza
219 sed -n '\''s/^'$1': //p'\'' \
224 printf >&3 "selected \"%s\" " $pkg
227 mkdir "$tp" "$tp/src" "$tp/tmp" "$tp/out"
232 if [ "x$pSource" != x ]; then
238 if test $target = source; then
241 sed -n '/^Files:/,/^([^ ].*)?$/{ /^ /{
242 s/^ [0-9a-z][0-9a-z]* *[0-9][0-9]* //; p
246 for leafname in $leafnames; do
247 df="$tp/src/$leafname"
249 */*|.*) echo >&2 "bad leafname: $leafname"; exit 1;;
252 gurl "$mirror/$pDirectory/$leafname" "$df"
257 : ${upload_if_ok:=true}
258 email_package_header="$email_sourcepackage_header"
261 fot="$tp/src/$pkg.deb"
262 gurl "$mirror/$pFilename" "$fot"
263 testmode='--binaries=install --binary'
264 testmode2=--instantiate
266 : ${upload_if_ok:=false}
267 email_package_header="$email_binarypackage_header"
270 if [ "x$maintainer_email_override" = x ]; then
272 maintainer_email=pMaintainer
274 maintainer_email=maintainer_email_override
277 printf >&3 "adt-run "
279 progress "starting test"
289 echo 'fatal: adt-run did not start properly' >"$tmp"/_summary
291 xrc adt-run --tmp-dir "$tp"/tmp \
292 --output-dir "$tp"/out \
293 --log-file "$tp"/log \
294 --summary "$tmp"/_summary \
296 $testmode "$fot" $testmode2 \
299 $adtvirt_extra_opts \
308 : ${upload_if_notests:=false}
312 0) summary='all OK'; email=''
313 upload=$upload_if_ok ;;
314 2) summary='OK (some skipped)'; email=''
315 upload=$upload_if_ok ;;
316 8) summary='package declares no tests'; email=''
317 upload=$upload_if_notests; extras='nt' ;;
318 4|6) summary='test(s) failed!'; email="$maintainer_email" ;;
319 12) summary='erroneous package!'; email="$maintainer_email" ;;
320 16) summary='testbed failed!'; email="administrator_email" ;;
321 *) summary='unexpected failure!'; email="administrator_email"; ourx=20;;
324 progress "RESULTS $summary"
326 if [ "x$suppresspackages" != x ] \
327 && grep -x "$pkg" "$suppresspackages" >/dev/null; then
328 printf >&3 "email-suppressed "
334 printf "\n%s\n" "$summary" >>"$tmp"/_summary
336 edest=${email%_email}
337 esummary="$var"/emailed/last-$pkg,$edest
338 if [ "x$edest" = x ]; then
339 printf >&3 "email-none "
340 rm -f "$var"/emailed/last-$pkg,*
342 elif $suppressrepeatedemails \
343 && [ -f "$esummary" ] \
344 && diff -u "$esummary" "$tmp"/_summary >"$var"/emailed/diff-$pkg; then
345 printf >&3 "email-same $email "
349 cp "$tmp"/_summary "$esummary".new
352 ln -f "$tmp"/_summary "$tp"/summary
354 for odir in tmp out; do
355 if test -d "$tp"/$odir; then
356 GZIP=-2 tar -f "$tp"/$odir.tar.gz -C "$tp" -zc $odir
362 printf >&3 "uploading"
363 $rsync -rltH --safe-links --delete "$tp" "$destrsynchead/$destdirfin/"
367 if [ "x$email" != x ]; then
368 progress "contacting $email"
369 eval "email_addr=\$$email"
370 printf >&3 "email \"%s\" " "$email_addr"
371 cat >"$tmp"/_email_header <<END
374 Subject: autopkgtest $distro $desc: $summary
378 email_package_header="${email_package_header//@p/$pkg}"
379 email_package_header="${email_package_header//@s/$src}"
380 email_package_header="${email_package_header//@v/$pVersion}"
381 email_package_header="${email_package_header//@a/@}"
382 printf >"$tmp"/_email "%s" "$email_package_header"
384 cat >>"$tmp"/_email <<END
385 Test executed for: $distro $target $pkg
388 sed -e 's/^/ /' "$tmp"/_summary >>"$tmp"/_email
389 cat >>"$tmp"/_email <<END
391 This message is automatically generated by the autopkgtest package
392 testing system. You are receiving it because:
396 cat >>"$tmp"/_email <<END
397 You are listed in the Maintainer field of the $pkg package in $distro
398 and the test results appear to indicate a problem with the package.
401 maintainer_email_override)
402 cat >>"$tmp"/_email <<END
403 The test results appear to indicate a problem with the package
404 and reports for package maintainers for $distro are being directed to
405 $maintainer_email_override
409 cat >>"$tmp"/_email <<END
410 You are the administrator for the autopkgtest installation.
414 echo >&2 "huh email $email is what why?"
418 cat >>"$tmp/_email" <<END
420 The test log, which is intended to be sufficient to diagnose most
421 failures, can be found below. However, in case this is not
422 sufficient, another copy can be found along with output files, saved
423 temporary files, and so on, at:
424 $desthttphead/$destdirfin/
426 If you have any questions about this service please contact me at:
436 printf >>"$var"/log "%s=%s rc=%s emailed='%s'\n" \
437 "$target" "$pkg" $rc "$email_addr"
439 if [ "x$ourx" = x0 ]; then
440 sed -e "/^$pkg /d" <"$lastinfo" >"$lastinfo".new
441 printf "%s %s %s %s\n" "$pkg" "$pVersion" "$now" "$extras" \
443 mv "$lastinfo".new "$lastinfo"
446 progress "fault ($ourx)."
449 perl <"$tmp"/_log_raw >"$tmp"/_log -pe '
450 s/[^\012\040-\133\135-\176]/
454 $& eq "\\" ? "\\\\" :
455 sprintf "\\x%02x", ord $&
458 if [ "x$email" = x ]; then
459 if $interactive; then
463 cat >>"$tmp"/_email 2>&1 "$tmp"/_log ||:
465 if [ "x$email_signing_key" != x ]; then
466 printf >&3 "signing "
468 gpg -u"$email_signing_key" --clearsign \
469 <"$tmp/_email" >"$tmp/_email.asc"
470 mv -f "$tmp/_email.asc" "$tmp/_email"
472 cat "$tmp/_email_header" "$tmp/_email" >"$tmp/_email.new"
473 mv -f "$tmp/_email.new" "$tmp/_email"
475 if $interactive; then
476 cat "$tmp"/_email >&2
478 sendmail -odi -oem -t -oi <"$tmp"/_email
479 if [ "x$esummary" != x ]; then
480 printf >&3 "email-recorded "
481 mv "$esummary".new "esummary"
486 printf >&3 "done %s.\n" $ourx