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