]> git.ipfire.org Git - thirdparty/systemd.git/blame - semaphoreci/setup.sh
udev: use strempty() where appropriate
[thirdparty/systemd.git] / semaphoreci / setup.sh
CommitLineData
841e1049
EV
1#!/bin/bash
2
3set -ex
4
59273a0c
MP
5# default to Debian testing
6DISTRO=${DISTRO:-debian}
7RELEASE=${RELEASE:-buster}
8ARCH=${ARCH:-amd64}
9CONTAINER=${RELEASE}-${ARCH}
0d427d37
MP
10MAX_CACHE_AGE=604800 # one week
11CACHE=${SEMAPHORE_CACHE_DIR:=/tmp}/${CONTAINER}.img.tar.gz
12
13create_container() {
14 # create autopkgtest LXC image; this sometimes fails with "Unable to fetch
15 # GPG key from keyserver", so retry a few times
16 for retry in $(seq 5); do
17 sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH && break
18 sleep $((retry*retry))
19 done
20
21 # unconfine the container, otherwise some tests fail
22 echo 'lxc.apparmor.profile = unconfined' | sudo tee -a /var/lib/lxc/$CONTAINER/config
23
24 sudo lxc-start -n $CONTAINER
25
26 # enable source repositories so that apt-get build-dep works
27 sudo lxc-attach -n $CONTAINER -- sh -ex <<EOF
28sed 's/^deb/deb-src/' /etc/apt/sources.list >> /etc/apt/sources.list.d/sources.list
29# wait until online
30while [ -z "\$(ip route list 0/0)" ]; do sleep 1; done
31apt-get -q update
32apt-get -y dist-upgrade
33apt-get install -y eatmydata
34EOF
35 sudo lxc-stop -n $CONTAINER
36
37 # cache it
38 sudo tar cpzf "$CACHE" /var/lib/lxc/$CONTAINER
39}
59273a0c
MP
40
41# remove semaphore repos, some of them don't work and cause error messages
42sudo rm -f /etc/apt/sources.list.d/*
43
44# enable backports for latest LXC
45echo 'deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list.d/backports.list
46sudo apt-get -q update
47sudo apt-get install -y -t xenial-backports lxc
48sudo apt-get install -y python3-debian git dpkg-dev fakeroot
49
0d427d37 50AUTOPKGTESTDIR=$SEMAPHORE_CACHE_DIR/autopkgtest
59273a0c
MP
51[ -d $AUTOPKGTESTDIR ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTESTDIR"
52
0d427d37
MP
53# use cached container image, unless older than a week
54if [ -e "$CACHE" ] && [ $(( $(date +%s) - $(stat -c %Y "$CACHE") )) -le $MAX_CACHE_AGE ]; then
55 sudo tar -C / -xpzf "$CACHE"
56else
57 create_container
58fi