@ARGV==1 or die;
my ($dist) = @ARGV;
-my $debbugs_soap= 'Debbugs/SOAP';
-my $debbugs_uri= 'http://bugs.debian.org/cgi-bin/soap.cgi';
+sub e ($) {
+ my ($v) = @_;
+ $v= 'suppressions_'.$v;
+ my $r= $ENV{$v};
+ die "need $v in environment" unless defined $r;
+ return $r;
+}
+
+my $debbugs_soap= e('debbugs_soap');
+my $debbugs_uri= e('debbugs_uri');
-my $usertag_owner= 'autopkgtest@packages.debian.org';
-my $usertag_name= "autopkgtest";
+my $usertag_owner= e('usertag_owner')
+my $usertag_name= e('usertag_name')
my $soap= SOAP::Lite->uri($debbugs_soap)->proxy($debbugs_uri);
-#!/bin/sh
+#!/bin/bash
+#
+# This script expects to be given at least two arguments:
+# directory to cd to
+# main config file for adt-testreport-runloop which sets PATH if need be
+# remaining arguments are passed through to a-t-r unchanged
set -e
-cd ${0%/*}
+export suppressions_kind=debbugs
+export suppressions_debbugs_soap=Debbugs/SOAP
+export suppressions_debbugs_uri=http://bugs.debian.org/cgi-bin/soap.cgi
+export suppressions_usertag_owner=autopkgtest@packages.debian.org
+export suppressions_usertag_name=autopkgtest
-echo 'fetching'
-curl -s -S -k -o webpage "$url"
+cd "$1"
+shift
+. "$1"
-echo 'grepping'
-perl -ne '
- print "$1\n" or die $! if
- m,"https://bugs.launchpad.net/ubuntu/\+source/([-+.0-9a-z]+)/\+bug/\d+",
-' <webpage >suppressions.new
+: "${suppressions_file_to_fetch:=$suppresspackages}"
+export suppressions_file_to_fetch
-nl -ba suppressions.new
+: "${suppressions_lockfile:=$suppressions_file_to_fetch-lock}"
-if ! test -s suppressions.new;
-then
- echo >&2 'NO SUPPRESSIONS - PROBABLY WENT WRONG
+echo 'locking'
-webpage:'
- cat webpage
-fi
+with-lock-ex -f "$suppressions_file_to_lock" bash -c '
+ . "$1"
-echo 'uploading'
+ f="$suppressions_file_to_fetch"
-mv suppressions.new suppressions
-RSYNC_RSH=ssh rsync suppressions cadmium.buildd:adt-play/.
+ echo fetching
+ ${suppressions_fetch:-adt-suppressions-fetch-$suppressions_kind} \
+ >"$f".new
-echo 'done.'
+ echo results
+ nl -ba -- "$f".new
+
+ if ! test -s "$f".new;
+ then
+ echo >&2 'NO SUPPRESSIONS - PROBABLY WENT WRONG
+ exit 1
+ fi
+
+ mv -- "$f".new "$f"
+
+ if [ "x$suppressions_copy_destination" != x ]; then
+ echo "uploading"
+ RSYNC_RSH=ssh rsync "$f" "$suppressions_copy_destination"
+ fi
+ echo done.
+' x "$@"