#! /bin/bash -ex

# build and test everything in a fresh docker installation

DOCKER_ID=$(docker run -d -v $(pwd):/workdir -w /workdir ubuntu sleep infinity)
trap "docker rm -f ${DOCKER_ID}" INT TERM EXIT
docker exec ${DOCKER_ID} apt-get install -y software-properties-common apt-transport-https dpkg-dev
docker exec ${DOCKER_ID} apt-add-repository universe
docker exec ${DOCKER_ID} apt-add-repository https://dev.marc.waeckerlin.org/repository
wget -O- https://dev.marc.waeckerlin.org/repository/PublicKey \
   | docker exec -i ${DOCKER_ID} apt-key add -
docker exec ${DOCKER_ID} apt-get update
docker exec ${DOCKER_ID} ./resolve-debbuilddeps.sh
docker exec -u $(id -u) ${DOCKER_ID} svn upgrade || true
docker exec -u $(id -u) ${DOCKER_ID} ./bootstrap.sh -t "all check distcheck"
