2 # SPDX-License-Identifier: LGPL-2.1-or-later
7 # default to Debian testing
8 DISTRO
="${DISTRO:-debian}"
9 RELEASE
="${RELEASE:-bookworm}"
10 BRANCH
="${BRANCH:-upstream-ci}"
12 CONTAINER
="${RELEASE}-${ARCH}"
13 CACHE_DIR
="${SEMAPHORE_CACHE_DIR:-/tmp}"
14 AUTOPKGTEST_DIR
="${CACHE_DIR}/autopkgtest"
15 # semaphore cannot expose these, but useful for interactive/local runs
16 ARTIFACTS_DIR
=/tmp
/artifacts
17 # shellcheck disable=SC2206
18 PHASES
=(${@:-SETUP RUN})
19 UBUNTU_RELEASE
="$(lsb_release -cs)"
22 sudo lxc-create
-n "$CONTAINER" -t download
-- -d "$DISTRO" -r "$RELEASE" -a "$ARCH"
24 # unconfine the container, otherwise some tests fail
25 echo 'lxc.apparmor.profile = unconfined' | sudo
tee -a "/var/lib/lxc/$CONTAINER/config"
27 sudo lxc-start
-n "$CONTAINER"
29 # enable source repositories so that apt-get build-dep works
30 sudo lxc-attach
-n "$CONTAINER" -- sh
-ex <<EOF
31 sed 's/^deb/deb-src/' /etc/apt/sources.list >>/etc/apt/sources.list.d/sources.list
32 # We might attach the console too soon
33 while ! systemctl --quiet --wait is-system-running; do sleep 1; done
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
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
42 apt-get -q --allow-releaseinfo-change update
43 apt-get -y dist-upgrade
44 apt-get install -y eatmydata
45 # The following four are needed as long as these deps are not covered by Debian's own packaging
46 apt-get install -y fdisk tree libfdisk-dev libp11-kit-dev libssl-dev libpwquality-dev rpm
47 apt-get purge --auto-remove -y unattended-upgrades
48 systemctl unmask systemd-networkd
49 systemctl enable systemd-networkd
51 sudo lxc-stop
-n "$CONTAINER"
54 for phase
in "${PHASES[@]}"; do
57 # remove semaphore repos, some of them don't work and cause error messages
58 sudo
rm -rf /etc
/apt
/sources.list.d
/*
60 # enable backports for latest LXC
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
62 sudo apt-get
-q update
63 sudo apt-get
install -y -t "$UBUNTU_RELEASE-backports" lxc
64 sudo apt-get
install -y python3-debian git dpkg-dev fakeroot python3-jinja2
66 [ -d "$AUTOPKGTEST_DIR" ] || git clone
--quiet --branch=debian
/5.32 --depth=1 https
://salsa.debian.org
/ci-team
/autopkgtest.git
"$AUTOPKGTEST_DIR"
71 # add current debian/ packaging
72 git fetch
--depth=1 https
://salsa.debian.org
/systemd-team
/systemd.git
"$BRANCH"
73 git checkout FETCH_HEAD debian
76 UPSTREAM_VER
="$(git describe | sed 's/^v//;s/-/./g')"
77 cat <<EOF >debian/changelog.new
78 systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low
80 * Automatic build for upstream test
82 -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R)
85 cat debian
/changelog
>>debian
/changelog.new
86 mv debian
/changelog.new debian
/changelog
90 # disable autopkgtests which are not for upstream
91 sed -i '/# NOUPSTREAM/ q' debian
/tests
/control
92 # enable more unit tests
93 sed -i '/^CONFFLAGS =/ s/=/= --werror -Dtests=unsafe -Dsplit-usr=true -Dslow-tests=true -Dfuzz-tests=true -Dman=true /' debian
/rules
95 echo '1.0' >debian
/source
/format
97 # build source package
98 dpkg-buildpackage
-S -I -I"$(basename "$CACHE_DIR")" -d -us -uc -nc
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
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" \
110 echo >&2 "Unknown phase '$phase'"