]> git.ipfire.org Git - thirdparty/systemd.git/blob - semaphoreci/semaphore-runner.sh
Merge pull request #13405 from yuwata/network-ipv6-privacy-extensions-cleanup
[thirdparty/systemd.git] / semaphoreci / semaphore-runner.sh
1 #!/bin/bash
2
3 set -eux
4
5 # default to Debian testing
6 DISTRO=${DISTRO:-debian}
7 RELEASE=${RELEASE:-buster}
8 BRANCH=${BRANCH:-master}
9 ARCH=${ARCH:-amd64}
10 CONTAINER=${RELEASE}-${ARCH}
11 CACHE_DIR=${SEMAPHORE_CACHE_DIR:=/tmp}
12 AUTOPKGTEST_DIR="${CACHE_DIR}/autopkgtest"
13 # semaphore cannot expose these, but useful for interactive/local runs
14 ARTIFACTS_DIR=/tmp/artifacts
15 PHASES=(${@:-SETUP RUN})
16
17 create_container() {
18 # create autopkgtest LXC image; this sometimes fails with "Unable to fetch
19 # GPG key from keyserver", so retry a few times
20 for retry in $(seq 5); do
21 sudo lxc-create -n $CONTAINER -t download -- -d $DISTRO -r $RELEASE -a $ARCH --keyserver hkp://keyserver.ubuntu.com:80 && break
22 sleep $((retry*retry))
23 done
24
25 # unconfine the container, otherwise some tests fail
26 echo 'lxc.apparmor.profile = unconfined' | sudo tee -a /var/lib/lxc/$CONTAINER/config
27
28 sudo lxc-start -n $CONTAINER
29
30 # enable source repositories so that apt-get build-dep works
31 sudo lxc-attach -n $CONTAINER -- sh -ex <<EOF
32 sed 's/^deb/deb-src/' /etc/apt/sources.list >> /etc/apt/sources.list.d/sources.list
33 # wait until online
34 while [ -z "\$(ip route list 0/0)" ]; do sleep 1; done
35 apt-get -q --allow-releaseinfo-change update
36 apt-get -y dist-upgrade
37 apt-get install -y eatmydata
38 apt-get purge --auto-remove -y unattended-upgrades
39 EOF
40 sudo lxc-stop -n $CONTAINER
41 }
42
43 for phase in "${PHASES[@]}"; do
44 case $phase in
45 SETUP)
46 # remove semaphore repos, some of them don't work and cause error messages
47 sudo rm -f /etc/apt/sources.list.d/*
48
49 # enable backports for latest LXC
50 echo 'deb http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list.d/backports.list
51 sudo apt-get -q update
52 sudo apt-get install -y -t xenial-backports lxc
53 sudo apt-get install -y python3-debian git dpkg-dev fakeroot
54
55 [ -d $AUTOPKGTEST_DIR ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTEST_DIR"
56
57 create_container
58 ;;
59 RUN)
60 # add current debian/ packaging
61 git fetch --depth=1 https://salsa.debian.org/systemd-team/systemd.git $BRANCH
62 git checkout FETCH_HEAD debian
63
64 # craft changelog
65 UPSTREAM_VER=$(git describe | sed 's/^v//')
66 cat << EOF > debian/changelog.new
67 systemd (${UPSTREAM_VER}-0) UNRELEASED; urgency=low
68
69 * Automatic build for upstream test
70
71 -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R)
72
73 EOF
74 cat debian/changelog >> debian/changelog.new
75 mv debian/changelog.new debian/changelog
76
77 # clean out patches
78 rm -rf debian/patches
79 # disable autopkgtests which are not for upstream
80 sed -i '/# NOUPSTREAM/ q' debian/tests/control
81 # enable more unit tests
82 sed -i '/^CONFFLAGS =/ s/=/= --werror -Dtests=unsafe -Dsplit-usr=true -Dslow-tests=true -Dman=true /' debian/rules
83 # no orig tarball
84 echo '1.0' > debian/source/format
85
86 # build source package
87 dpkg-buildpackage -S -I -I$(basename "$CACHE_DIR") -d -us -uc -nc
88
89 # now build the package and run the tests
90 rm -rf "$ARTIFACTS_DIR"
91 # autopkgtest exits with 2 for "some tests skipped", accept that
92 $AUTOPKGTEST_DIR/runner/autopkgtest --env DEB_BUILD_OPTIONS=noudeb \
93 --env TEST_UPSTREAM=1 ../systemd_*.dsc \
94 -o "$ARTIFACTS_DIR" \
95 -- lxc -s $CONTAINER \
96 || [ $? -eq 2 ]
97 ;;
98 *)
99 echo >&2 "Unknown phase '$phase'"
100 exit 1
101 esac
102 done