--- /dev/null
+#!/bin/bash
+
+set -e
+
+mirror=http://mirror.relativity.greenend.org.uk/mirror/ubuntu.good
+distro=feisty
+suite=main
+salt=''
+tmp=tmp
+var=var
+administrator_email=ian@davenant.greenend.org.uk
+maintainer_email_override="$administrator_email"
+salutation="Ian"
+from="$salutation Jackson <ian@davenant.greenend.org.uk>"
+rsync=rsync
+
+destdirtail=autopkgtest-output/$distro
+destrsynchead=ijackson@chiark:public-html/
+desthttphead=http://www.chiark.greenend.org.uk/~ijackson/
+
+rm -rf "$tmp"
+mkdir "$tmp"
+
+exec >"$tmp"/log
+
+progress () {
+ echo "++++++ $1 ++++++"
+}
+
+gurl () {
+ progress "fetching $1"
+ curl -sS "$1" >"$2"
+}
+
+gurl "$mirror/dists/$distro/$suite/source/Sources.gz" "$tmp"/sources.gz
+zcat "$tmp"/sources.gz >"$tmp"/sources-in
+
+sed -n 's/^Package: \([-+.0-9a-z][-+.0-9a-z]*\)$/\1/p' \
+ <"$tmp"/sources-in >"$tmp"/sources-packages
+
+if test -f "$var"/last; then
+ sed -e 's/$/ _/' "$var"/last >>"$tmp"/sources-packages
+else
+ echo ' _' >>"$tmp"/sources-packages
+fi
+
+sort <"$tmp"/sources-packages >"$tmp"/all-sorted
+pkg="`
+ perl -ne '
+ if ($now) { print or die $!; $now++; exit; }
+ $now = m/ _$/;
+ END { die unless $now>1; }
+ ' <"$tmp"/all-sorted
+`"
+
+progress "selected $pkg"
+
+sed -n "/^Package: $pkg\$/,/^\$/p" \
+ <"$tmp"/sources-in >"$tmp"/this-stanza
+
+cat "$tmp"/this-stanza
+
+getfield () {
+ eval 'p'$1'="`
+ sed -n '\''s/^'$1': //p'\'' \
+ <"$tmp"/this-stanza
+ `"'
+}
+
+getfield Directory
+
+leafnames="`
+ sed -n '/^Files:/,/^([^ ].*)?$/{ /^ /{
+ s/^ [0-9a-z][0-9a-z]* *[0-9][0-9]* //; p
+ }}' \
+ <"$tmp"/this-stanza
+`"
+
+tp="$tmp/$pkg"
+mkdir "$tp" "$tp/src" "$tp/tmp" "$tp/out"
+
+for leafname in $leafnames; do
+ df="$tp/src/$leafname"
+ case "$leafname" in
+ */*|.*) echo >&2 "bad leafname: $leafname"; exit 1;;
+ *.dsc) dsc="$df";;
+ esac
+ gurl "$mirror/pool/$suite/$pDirectory/$leafname" "$df"
+done
+
+if [ "x$maintainer_email_override" = x ]; then
+ getfield Maintainer
+ maintainer_email=pMaintainer
+else
+ maintainer_email=maintainer_email_override
+fi
+
+progress "starting test"
+
+xrc () {
+ printf "+ %s\n" "$*"
+ set +e
+ "$@"
+ rc=$?
+ set -e
+}
+
+xrc adt-run --tmp-dir "$tp"/tmp \
+ --output-dir "$tp"/out \
+ --log-file "$tp"/log \
+ --source "$dsc" \
+ --- \
+ adt-virt-xenlvm \
+ distro="$distro" \
+ 2>&1
+
+case "$rc" in
+0) summary='all OK'; email='' ;;
+2) summary='OK (some skipped)'; email='' ;;
+8) summary='package declares no tests'; email='' ;;
+4|6) summary='test(s) failed!'; email="$maintainer_email" ;;
+12) summary='erroneous package!'; email="$maintainer_email" ;;
+16) summary='testbed failed!'; email="administrator_email" ;;
+*) summary='unexpected failure!'; email="administrator_email" ;;
+esac
+
+progress "RESULTS $summary"
+progress "contacting $email"
+
+for odir in tmp out; do
+ if test -d "$tp"/$odir; then
+ GZIP=-2 tar -f "$tp"/$odir.tar.gz -C "$tp" -zc $odir
+ rm -r "$tp"/$odir
+ fi
+done
+
+$rsync -rltH --safe-links --delete "$tp" "$destrsynchead/$destdirtail/"
+
+if [ "x$email" != x ]; then
+ eval "email_addr=\$$email"
+ cat >"$tmp"/email <<END
+From: $from
+To: $email_addr
+Subject: autopkgtest $distro $pkg: $summary
+
+ Test executed for: $distro $pkg
+ Outcome: $summary
+
+This message is automatically generated by the autopkgtest package
+testing system. You are receiving it because:
+END
+ case "$email" in
+ pMaintainer)
+ cat >>"$tmp"/email <<END
+ You are listed in the Maintainer field of the $pkg package in $distro
+ and the test results appear to indicate a problem with the package.
+END
+ ;;
+ maintainer_email_override)
+ cat >>"$tmp"/email <<END
+ The test results appear to indicate a problem with the package
+ and reports for package maintainers for $distro are being directed to
+ $maintainer_email_override
+END
+ ;;
+ administrator_email)
+ cat >>"$tmp"/email <<END
+ You are the administrator for the autopkgtest installation.
+END
+ ;;
+ *)
+ echo >&2 "huh email $email is what why?"
+ exit 1
+ ;;
+ esac
+ cat >>"$tmp/email" <<END
+
+The test log, which is intended to be sufficient to diagnose most
+failures, can be found below. However, in case this is not
+sufficient, another copy can be found along with output files, saved
+temporary files, and so on, at:
+ $desthttphead/$destdirtail/
+
+If you have any questions about this service please contact me at:
+ $from
+
+Regards,
+$salutation
+
+-8<-
+END
+ cat >>"$tmp"/email 2>&1 "$tmp"/log ||:
+ sendmail -odq -oem -t -oi <"$tmp"/email
+fi
+
+printf >>"$var"/log "package=%s rc=%s emailed='%s'\n" \
+ "$pkg" $rc "$email_addr"
+echo $pkg >"$var"/last.new
+mv "$var"/last.new "$var"/last
+
+progress "done."