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:-debian/master}"
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 echo "deb http://deb.debian.org/debian $RELEASE-backports main" >/etc/apt/sources.list.d/backports.list
33 # We might attach the console too soon
34 until systemctl --quiet --wait is-system-running; do sleep 1; done
35 # Manpages database trigger takes a lot of time and is not useful in a CI
36 echo 'man-db man-db/auto-update boolean false' | debconf-set-selections
37 # Speed up dpkg, image is thrown away after the test
38 mkdir -p /etc/dpkg/dpkg.cfg.d/
39 echo 'force-unsafe-io' >/etc/dpkg/dpkg.cfg.d/unsafe_io
40 # For some reason, it is necessary to run this manually or the interface won't be configured
41 # Note that we avoid networkd, as some of the tests will break it later on
43 apt-get -q --allow-releaseinfo-change update
44 apt-get -y dist-upgrade
45 apt-get install -y eatmydata
46 # The following four are needed as long as these deps are not covered by Debian's own packaging
47 apt-get install -y fdisk tree libfdisk-dev libp11-kit-dev libssl-dev libpwquality-dev rpm
48 # autopkgtest doesn't consider backports
49 apt-get install -y -t $RELEASE-backports debhelper libcurl4-openssl-dev libarchive-dev
50 apt-get purge --auto-remove -y unattended-upgrades
51 systemctl unmask systemd-networkd
52 systemctl enable systemd-networkd
54 sudo lxc-stop
-n "$CONTAINER"
57 for phase
in "${PHASES[@]}"; do
60 # remove semaphore repos, some of them don't work and cause error messages
61 sudo
rm -rf /etc
/apt
/sources.list.d
/*
63 # enable backports for latest LXC
64 echo "deb http://archive.ubuntu.com/ubuntu $UBUNTU_RELEASE-backports main restricted universe multiverse" | sudo
tee -a /etc
/apt
/sources.list.d
/backports.list
65 sudo apt-get
-q update
66 sudo apt-get
install -y -t "$UBUNTU_RELEASE-backports" lxc
67 sudo apt-get
install -y python3-debian git dpkg-dev fakeroot python3-jinja2
69 [ -d "$AUTOPKGTEST_DIR" ] || git clone
--quiet --branch=debian
/5.32 --depth=1 https
://salsa.debian.org
/ci-team
/autopkgtest.git
"$AUTOPKGTEST_DIR"
74 # add current debian/ packaging
75 git fetch
--depth=1 https
://salsa.debian.org
/systemd-team
/systemd.git
"$BRANCH"
76 git checkout FETCH_HEAD debian
79 UPSTREAM_VER
="$(git describe | sed 's/^v//;s/-/./g')"
80 cat <<EOF >debian/changelog.new
81 systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low
83 * Automatic build for upstream test
85 -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R)
88 cat debian
/changelog
>>debian
/changelog.new
89 mv debian
/changelog.new debian
/changelog
93 # disable autopkgtests which are not for upstream
94 sed -i '/# NOUPSTREAM/ q' debian
/tests
/control
95 # enable more unit tests
96 sed -i '/^CONFFLAGS =/ s/=/= --werror -Dtests=unsafe -Dslow-tests=true -Dfuzz-tests=true -Dman=true /' debian
/rules
98 echo '1.0' >debian
/source
/format
100 # build source package
101 dpkg-buildpackage
-S -I -I"$(basename "$CACHE_DIR")" -d -us -uc -nc
103 # now build the package and run the tests
104 rm -rf "$ARTIFACTS_DIR"
105 # autopkgtest exits with 2 for "some tests skipped", accept that
106 sudo
"$AUTOPKGTEST_DIR/runner/autopkgtest" --env DEB_BUILD_OPTIONS
=noudeb \
107 --env DEB_BUILD_PROFILES
=pkg.systemd.upstream \
108 --env TEST_UPSTREAM
=1 \
110 -o "$ARTIFACTS_DIR" \
111 -- lxc
-s "$CONTAINER" \
115 echo >&2 "Unknown phase '$phase'"