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"
262 printf "\n%s\n" "$summary" >>"$tmp"/_summary
264 edest=${email%_email}
265 esummary="$var"/emailed/last-$pkg,$edest
266 if [ "x$edest" = x ]; then
267 printf >&3 "email-none "
268 rm -f "$var"/emailed/last-$pkg,*
270 elif $suppressrepeatedemails \
271 && [ -f "$esummary" ] \
272 && diff -u "$esummary" "$tmp"/_summary >"$var"/emailed/diff-$pkg; then
273 printf >&3 "email-suppressed $email "
277 cp "$tmp"/_summary "$esummary".new
280 ln -f "$tmp"/_summary "$tp"/summary
282 for odir in tmp out; do
283 if test -d "$tp"/$odir; then
284 GZIP=-2 tar -f "$tp"/$odir.tar.gz -C "$tp" -zc $odir
290 printf >&3 "uploading"
291 $rsync -rltH --safe-links --delete "$tp" "$destrsynchead/$destdirfin/"
295 if [ "x$email" != x ]; then
296 progress "contacting $email"
297 eval "email_addr=\$$email"
298 printf >&3 "email \"%s\" " "$email_addr"
299 cat >"$tmp"/_email <<END
302 Subject: autopkgtest $distro $desc: $summary
304 Test executed for: $distro $target $pkg
307 sed -e 's/^/ /' "$tmp"/_summary >>"$tmp"/_email
308 cat >>"$tmp"/_email <<END
310 This message is automatically generated by the autopkgtest package
311 testing system. You are receiving it because:
315 cat >>"$tmp"/_email <<END
316 You are listed in the Maintainer field of the $pkg package in $distro
317 and the test results appear to indicate a problem with the package.
320 maintainer_email_override)
321 cat >>"$tmp"/_email <<END
322 The test results appear to indicate a problem with the package
323 and reports for package maintainers for $distro are being directed to
324 $maintainer_email_override
328 cat >>"$tmp"/_email <<END
329 You are the administrator for the autopkgtest installation.
333 echo >&2 "huh email $email is what why?"
337 cat >>"$tmp/_email" <<END
339 The test log, which is intended to be sufficient to diagnose most
340 failures, can be found below. However, in case this is not
341 sufficient, another copy can be found along with output files, saved
342 temporary files, and so on, at:
343 $desthttphead/$destdirfin/
345 If you have any questions about this service please contact me at:
355 printf >>"$var"/log "%s=%s rc=%s emailed='%s'\n" \
356 "$target" "$pkg" $rc "$email_addr"
358 if [ "x$ourx" = x0 ]; then
359 sed -e "/^$pkg /d" <"$lastinfo" >"$lastinfo".new
360 printf "%s %s %s %s\n" "$pkg" "$pVersion" "$now" "$extras" \
362 mv "$lastinfo".new "$lastinfo"
365 progress "fault ($ourx)."
368 if [ "x$email" = x ]; then
369 if $interactive; then
373 cat >>"$tmp"/_email 2>&1 "$tmp"/_log ||:
374 if $interactive; then
375 cat "$tmp"/_email >&2
377 sendmail -odi -oem -t -oi <"$tmp"/_email
378 if [ "x$esummary" != x ]; then
379 printf >&3 "email-recorded "
380 mv "$esummary".new "esummary"
385 printf >&3 "done %s.\n" $ourx