#!/bin/sh
set -e

cd "$ADTTMP"

sed -i 's/blacklist: AutoPkgTest Blhc Lintian Mailer Piuparts/blacklist: AutoPkgTest Mailer Piuparts/' /etc/debomatic/debomatic.conf
grep /etc/debomatic/debomatic.conf -e "blacklist: AutoPkgTest Mailer Piuparts" || exit 1

mkdir /incoming
mkdir mybuild
cd mybuild
export version=`rmadison -u debian -a source -s unstable hello | cut -d"|" -f 2 | xargs`
echo "rebuild hello_$version unstable" > /incoming/rebuild.commands
debomatic -c /etc/debomatic/debomatic.conf -o /incoming/rebuild.commands -i

cat /incoming/unstable/pool/hello*/hello*.buildlog
grep /incoming/unstable/pool/hello*/hello*.buildlog -e "Status: successful" || exit 1
grep /incoming/unstable/pool/hello*/hello*.blhc || exit 1
grep /incoming/unstable/pool/hello*/hello*.lintian || exit 1
