5 # default to Debian testing
6 DISTRO
=${DISTRO:-debian}
7 RELEASE
=${RELEASE:-buster}
9 CONTAINER
=${RELEASE}-${ARCH}
10 MAX_CACHE_AGE
=604800 # one week
11 CACHE
=${SEMAPHORE_CACHE_DIR:=/tmp}/${CONTAINER}.img.
tar.gz
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
))
21 # unconfine the container, otherwise some tests fail
22 echo 'lxc.apparmor.profile = unconfined' | sudo
tee -a /var
/lib
/lxc
/$CONTAINER/config
24 sudo lxc-start
-n $CONTAINER
26 # enable source repositories so that apt-get build-dep works
27 sudo lxc-attach
-n $CONTAINER -- sh
-ex <<EOF
28 sed 's/^deb/deb-src/' /etc/apt/sources.list >> /etc/apt/sources.list.d/sources.list
30 while [ -z "\$(ip route list 0/0)" ]; do sleep 1; done
32 apt-get -y dist-upgrade
33 apt-get install -y eatmydata
35 sudo lxc-stop
-n $CONTAINER
38 sudo
tar cpzf
"$CACHE" /var
/lib
/lxc
/$CONTAINER
41 # remove semaphore repos, some of them don't work and cause error messages
42 sudo
rm -f /etc
/apt
/sources.list.d
/*
44 # enable backports for latest LXC
45 echo 'deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse' | sudo
tee -a /etc
/apt
/sources.list.d
/backports.list
46 sudo apt-get
-q update
47 sudo apt-get
install -y -t xenial-backports lxc
48 sudo apt-get
install -y python3-debian git dpkg-dev fakeroot
50 AUTOPKGTESTDIR
=$SEMAPHORE_CACHE_DIR/autopkgtest
51 [ -d $AUTOPKGTESTDIR ] || git clone
--quiet --depth=1 https
://salsa.debian.org
/ci-team
/autopkgtest.git
"$AUTOPKGTESTDIR"
53 # use cached container image, unless older than a week
54 if [ -e "$CACHE" ] && [ $
(( $
(date +%s
) - $
(stat
-c %Y
"$CACHE") )) -le $MAX_CACHE_AGE ]; then
55 sudo
tar -C / -xpzf "$CACHE"