]> git.ipfire.org Git - thirdparty/systemd.git/blob - semaphoreci/setup.sh
semaphoreci: Run subset of autopkgtests in LXC (#11814)
[thirdparty/systemd.git] / semaphoreci / setup.sh
1 #!/bin/bash
2
3 set -ex
4
5 # default to Debian testing
6 DISTRO=${DISTRO:-debian}
7 RELEASE=${RELEASE:-buster}
8 ARCH=${ARCH:-amd64}
9 CONTAINER=${RELEASE}-${ARCH}
10
11 # remove semaphore repos, some of them don't work and cause error messages
12 sudo rm -f /etc/apt/sources.list.d/*
13
14 # enable backports for latest LXC
15 echo 'deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list.d/backports.list
16 sudo apt-get -q update
17 sudo apt-get install -y -t xenial-backports lxc
18 sudo apt-get install -y python3-debian git dpkg-dev fakeroot
19
20 AUTOPKGTESTDIR=${SEMAPHORE_CACHE_DIR:-/tmp}/autopkgtest
21 [ -d $AUTOPKGTESTDIR ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTESTDIR"
22
23 # TODO: cache container image (though downloading/building it takes < 1 min)
24 # create autopkgtest LXC image
25 sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH
26
27 # unconfine the container, otherwise some tests fail
28 echo 'lxc.apparmor.profile = unconfined' | sudo tee -a /var/lib/lxc/$CONTAINER/config
29
30 sudo lxc-start -n $CONTAINER
31
32 # enable source repositories so that apt-get build-dep works
33 sudo lxc-attach -n $CONTAINER -- sh -ex <<EOF
34 sed 's/^deb/deb-src/' /etc/apt/sources.list >> /etc/apt/sources.list.d/sources.list
35 # wait until online
36 while [ -z "\$(ip route list 0/0)" ]; do sleep 1; done
37 apt-get -q update
38 apt-get -y dist-upgrade
39 apt-get install -y eatmydata
40 EOF
41 sudo lxc-stop -n $CONTAINER