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
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
78 if [ "x$pkg" = x ]; then
83 $vre= "[-+.0-9a-zA-Z:~]+";
85 sub f1() { $fn=shift @ARGV; open F, $fn or die "$fn $!"; }
86 sub f2() { F->error and die "$fn $!"; close F or die "$fn $!"; }
90 die unless m/^($pre) ($vre) (\d+)( .*)?$/;
100 return if $score < $best_score
101 or ($score==$best_score and \
102 $package gt $best_package);
103 #printf STDERR " <----- best score=%s best_score=%s\n", $score, $best_score;
105 $best_package= $package;
108 return unless (defined $package
111 die unless defined $package;
112 die unless defined $version;
119 if (m/^Package: ($pre)$/) {
120 die if defined $package;
122 } elsif (m/^Version: ($vre)$/) {
123 die if defined $version;
125 $score= '$now' - $lasttime{$package};
126 $score= 1e7 if $score>1e7;
127 $score *= 5 if $lastver{$package} ne $version;
128 $score *= 10 unless $extras{$package} =~ m/ nt /;
129 #print STDERR "$package score $score\n";
130 } elsif (m/^Architecture:.*/ &&
131 !m/\s(?:'$arch'|all|any)\s/) {
132 #printf STDERR " <----- skip %s %s\n", $&, "'$arch'";
140 die unless length $best_package;
141 open L, ">&4" or die $!;
142 printf L "selected %s (age %s, score %d)\n",
144 exists($lastime{$best_package})
145 ? '$now' - $lasttime{$best_package}
148 print "$best_package\n" or die $!;
149 ' "$lastinfo" "$tmp"/_$sources-in`"
151 printf >&4 "package forced: %s\n" "$pkg"
154 sed -n "/^Package: $pkg\$/,/^\$/p" \
155 <"$tmp"/_$sources-in >"$tmp"/_this-stanza
158 cat "$tmp"/_this-stanza
162 sed -n '\''s/^'$1': //p'\'' \
167 printf >&3 "selected \"%s\" " $pkg
170 mkdir "$tp" "$tp/src" "$tp/tmp" "$tp/out"
174 if test $target = source; then
177 sed -n '/^Files:/,/^([^ ].*)?$/{ /^ /{
178 s/^ [0-9a-z][0-9a-z]* *[0-9][0-9]* //; p
182 for leafname in $leafnames; do
183 df="$tp/src/$leafname"
185 */*|.*) echo >&2 "bad leafname: $leafname"; exit 1;;
188 gurl "$mirror/$pDirectory/$leafname" "$df"
193 : ${upload_if_ok:=true}
196 fot="$tp/src/$pkg.deb"
197 gurl "$mirror/$pFilename" "$fot"
198 testmode='--binaries=install --binary'
199 testmode2=--instantiate
201 : ${upload_if_ok:=false}
204 if [ "x$maintainer_email_override" = x ]; then
206 maintainer_email=pMaintainer
208 maintainer_email=maintainer_email_override
211 printf >&3 "adt-run "
213 progress "starting test"
223 echo 'fatal: adt-run did not start properly' >"$tmp"/_summary
225 xrc adt-run --tmp-dir "$tp"/tmp \
226 --output-dir "$tp"/out \
227 --log-file "$tp"/log \
228 --summary "$tmp"/_summary \
230 $testmode "$fot" $testmode2 \
233 $adtvirt_extra_opts \
242 : ${upload_if_notests:=false}
246 0) summary='all OK'; email=''
247 upload=$upload_if_ok ;;
248 2) summary='OK (some skipped)'; email=''
249 upload=$upload_if_ok ;;
250 8) summary='package declares no tests'; email=''
251 upload=$upload_if_notests; extras='nt' ;;
252 4|6) summary='test(s) failed!'; email="$maintainer_email" ;;
253 12) summary='erroneous package!'; email="$maintainer_email" ;;
254 16) summary='testbed failed!'; email="administrator_email" ;;
255 *) summary='unexpected failure!'; email="administrator_email"; ourx=20;;
258 progress "RESULTS $summary"
260 if [ "x$suppresspackages" != x ] \
261 && grep -x "$pkg" "$suppresspackages" >/dev/null; then
262 printf >&3 "email-suppressed "
268 printf "\n%s\n" "$summary" >>"$tmp"/_summary
270 edest=${email%_email}
271 esummary="$var"/emailed/last-$pkg,$edest
272 if [ "x$edest" = x ]; then
273 printf >&3 "email-none "
274 rm -f "$var"/emailed/last-$pkg,*
276 elif $suppressrepeatedemails \
277 && [ -f "$esummary" ] \
278 && diff -u "$esummary" "$tmp"/_summary >"$var"/emailed/diff-$pkg; then
279 printf >&3 "email-same $email "
283 cp "$tmp"/_summary "$esummary".new
286 ln -f "$tmp"/_summary "$tp"/summary
288 for odir in tmp out; do
289 if test -d "$tp"/$odir; then
290 GZIP=-2 tar -f "$tp"/$odir.tar.gz -C "$tp" -zc $odir
296 printf >&3 "uploading"
297 $rsync -rltH --safe-links --delete "$tp" "$destrsynchead/$destdirfin/"
301 if [ "x$email" != x ]; then
302 progress "contacting $email"
303 eval "email_addr=\$$email"
304 printf >&3 "email \"%s\" " "$email_addr"
305 cat >"$tmp"/_email_header <<END
308 Subject: autopkgtest $distro $desc: $summary
312 printf >"$tmp"/_email "$email_package_header" "$pkg"
314 cat >>"$tmp"/_email <<END
315 Test executed for: $distro $target $pkg
318 sed -e 's/^/ /' "$tmp"/_summary >>"$tmp"/_email
319 cat >>"$tmp"/_email <<END
321 This message is automatically generated by the autopkgtest package
322 testing system. You are receiving it because:
326 cat >>"$tmp"/_email <<END
327 You are listed in the Maintainer field of the $pkg package in $distro
328 and the test results appear to indicate a problem with the package.
331 maintainer_email_override)
332 cat >>"$tmp"/_email <<END
333 The test results appear to indicate a problem with the package
334 and reports for package maintainers for $distro are being directed to
335 $maintainer_email_override
339 cat >>"$tmp"/_email <<END
340 You are the administrator for the autopkgtest installation.
344 echo >&2 "huh email $email is what why?"
348 cat >>"$tmp/_email" <<END
350 The test log, which is intended to be sufficient to diagnose most
351 failures, can be found below. However, in case this is not
352 sufficient, another copy can be found along with output files, saved
353 temporary files, and so on, at:
354 $desthttphead/$destdirfin/
356 If you have any questions about this service please contact me at:
366 printf >>"$var"/log "%s=%s rc=%s emailed='%s'\n" \
367 "$target" "$pkg" $rc "$email_addr"
369 if [ "x$ourx" = x0 ]; then
370 sed -e "/^$pkg /d" <"$lastinfo" >"$lastinfo".new
371 printf "%s %s %s %s\n" "$pkg" "$pVersion" "$now" "$extras" \
373 mv "$lastinfo".new "$lastinfo"
376 progress "fault ($ourx)."
379 if [ "x$email" = x ]; then
380 if $interactive; then
384 cat >>"$tmp"/_email 2>&1 "$tmp"/_log ||:
386 if [ "x$email_signing_key" != x ]; then
387 printf >&3 "signing "
389 gpg -u"$email_signing_key" --clearsign \
390 <"$tmp/_email" >"$tmp/_email.asc"
391 mv -f "$tmp/_email.asc" "$tmp/_email"
393 cat "$tmp/_email_header" "$tmp/_email" >"$tmp/_email.new"
394 mv -f "$tmp/_email.new" "$tmp/_email"
396 if $interactive; then
397 cat "$tmp"/_email >&2
399 sendmail -odi -oem -t -oi <"$tmp"/_email
400 if [ "x$esummary" != x ]; then
401 printf >&3 "email-recorded "
402 mv "$esummary".new "esummary"
407 printf >&3 "done %s.\n" $ourx