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