1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#!/bin/sh
set -eu
echo ${RELEASE:=zesty}
echo ${ARCH:=amd64}
# get LP chroot
CHROOT_URL=$(curl --silent https://api.launchpad.net/1.0/ubuntu/$RELEASE/$ARCH | grep -o 'http://[^ "]*chroot-ubuntu-[^ "]*')
CHROOT_TAR="/tmp/$(basename $CHROOT_URL)"
[ -e "$CHROOT_TAR" ] || curl -o "$CHROOT_TAR" "$CHROOT_URL"
# prepare chroot
BUILDDIR=$(mktemp -d)
trap "echo sudo rm -rf $BUILDDIR" EXIT INT QUIT PIPE
sudo tar -C "$BUILDDIR" -xf "$CHROOT_TAR"
CHROOT="$BUILDDIR/chroot-autobuild"
sudo cp /etc/resolv.conf "$CHROOT/etc/resolv.conf"
# copy code checkout into chroot
sudo cp -a . "$CHROOT/build/src"
sudo chroot "$CHROOT" << EOF
set -ex
# install build deps
apt-get update
apt-get install -y dh-autoreconf pkg-config libvirt-dev libglib2.0-dev libtool python3-gi python3-dbus python3-pytest dbus
# run build and tests as user
chown -R buildd:buildd /build
su - buildd <<EOU
set -ex
cd /build/src
./autogen.sh
make -j4
make check || { cat test-suite.log; exit 1; }
EOU
EOF
|