]> git.ipfire.org Git - thirdparty/systemd.git/blob - .semaphore/semaphore-runner.sh
man/capsule@.service: the capsule user is prefixed with "c-" rather than "p_"
[thirdparty/systemd.git] / .semaphore / semaphore-runner.sh
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3
4 set -eux
5 set -o pipefail
6
7 # default to Debian testing
8 DISTRO="${DISTRO:-debian}"
9 RELEASE="${RELEASE:-bookworm}"
10 SALSA_URL="${SALSA_URL:-https://salsa.debian.org/systemd-team/systemd.git}"
11 BRANCH="${BRANCH:-debian/master}"
12 ARCH="${ARCH:-amd64}"
13 CONTAINER="${RELEASE}-${ARCH}"
14 CACHE_DIR="${SEMAPHORE_CACHE_DIR:-/tmp}"
15 AUTOPKGTEST_DIR="${CACHE_DIR}/autopkgtest"
16 # semaphore cannot expose these, but useful for interactive/local runs
17 ARTIFACTS_DIR=/tmp/artifacts
18 # shellcheck disable=SC2206
19 PHASES=(${@:-SETUP RUN})
20 UBUNTU_RELEASE="$(lsb_release -cs)"
21
22 create_container() {
23 sudo lxc-create -n "$CONTAINER" -t download -- -d "$DISTRO" -r "$RELEASE" -a "$ARCH"
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 echo "deb http://deb.debian.org/debian $RELEASE-backports main" >/etc/apt/sources.list.d/backports.list
34 # We might attach the console too soon
35 until systemctl --quiet --wait is-system-running; do sleep 1; done
36 # Manpages database trigger takes a lot of time and is not useful in a CI
37 echo 'man-db man-db/auto-update boolean false' | debconf-set-selections
38 # Speed up dpkg, image is thrown away after the test
39 mkdir -p /etc/dpkg/dpkg.cfg.d/
40 echo 'force-unsafe-io' >/etc/dpkg/dpkg.cfg.d/unsafe_io
41 # For some reason, it is necessary to run this manually or the interface won't be configured
42 # Note that we avoid networkd, as some of the tests will break it later on
43 dhclient
44 apt-get -q --allow-releaseinfo-change update
45 apt-get -y dist-upgrade
46 apt-get install -y eatmydata
47 # The following four are needed as long as these deps are not covered by Debian's own packaging
48 apt-get install -y tree libpwquality-dev rpm libcurl4-openssl-dev libarchive-dev
49 # autopkgtest doesn't consider backports
50 apt-get install -y -t $RELEASE-backports debhelper
51 apt-get purge --auto-remove -y unattended-upgrades
52 systemctl unmask systemd-networkd
53 systemctl enable systemd-networkd
54 EOF
55 sudo lxc-stop -n "$CONTAINER"
56 }
57
58 for phase in "${PHASES[@]}"; do
59 case "$phase" in
60 SETUP)
61 # remove semaphore repos, some of them don't work and cause error messages
62 sudo rm -rf /etc/apt/sources.list.d/*
63
64 # enable backports for latest LXC
65 echo "deb http://archive.ubuntu.com/ubuntu $UBUNTU_RELEASE-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/backports.list
66 sudo apt-get -q update
67 sudo apt-get install -y -t "$UBUNTU_RELEASE-backports" lxc
68 sudo apt-get install -y python3-debian git dpkg-dev fakeroot python3-jinja2
69
70 [ -d "$AUTOPKGTEST_DIR" ] || git clone --quiet --depth=1 https://salsa.debian.org/ci-team/autopkgtest.git "$AUTOPKGTEST_DIR"
71
72 create_container
73 ;;
74 RUN)
75 # add current debian/ packaging
76 git fetch --depth=1 "$SALSA_URL" "$BRANCH"
77 git checkout FETCH_HEAD debian
78
79 # craft changelog
80 UPSTREAM_VER="$(git describe | sed 's/^v//;s/-/./g')"
81 cat <<EOF >debian/changelog.new
82 systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low
83
84 * Automatic build for upstream test
85
86 -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R)
87
88 EOF
89 cat debian/changelog >>debian/changelog.new
90 mv debian/changelog.new debian/changelog
91
92 # clean out patches
93 rm -rf debian/patches
94 # disable autopkgtests which are not for upstream
95 sed -i '/# NOUPSTREAM/ q' debian/tests/control
96 # enable more unit tests
97 sed -i '/^CONFFLAGS =/ s/=/= --werror -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true -Dman=true /' debian/rules
98 # no orig tarball
99 echo '1.0' >debian/source/format
100
101 # build source package
102 dpkg-buildpackage -S -I -I"$(basename "$CACHE_DIR")" -d -us -uc -nc
103
104 # now build the package and run the tests
105 rm -rf "$ARTIFACTS_DIR"
106 # autopkgtest exits with 2 for "some tests skipped", accept that
107 sudo "$AUTOPKGTEST_DIR/runner/autopkgtest" --env DEB_BUILD_OPTIONS="noudeb nostrip optimize=-lto" \
108 --env DPKG_DEB_COMPRESSOR_TYPE="none" \
109 --env DEB_BUILD_PROFILES="pkg.systemd.upstream noudeb" \
110 --env TEST_UPSTREAM=1 \
111 ../systemd_*.dsc \
112 -o "$ARTIFACTS_DIR" \
113 -- lxc -s "$CONTAINER" \
114 || [ $? -eq 2 ]
115 ;;
116 *)
117 echo >&2 "Unknown phase '$phase'"
118 exit 1
119 esac
120 done