2 # SPDX-License-Identifier: LGPL-2.1-or-later
7 DISTRO
="${DISTRO:-debian}"
8 RELEASE
="${RELEASE:-bookworm}"
9 SALSA_URL
="${SALSA_URL:-https://salsa.debian.org/systemd-team/systemd.git}"
10 BRANCH
="${BRANCH:-debian/master}"
12 CONTAINER
="${RELEASE}-${ARCH}"
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)"
23 sudo lxc-create
-n "$CONTAINER" -t download
-- -d "$DISTRO" -r "$RELEASE" -a "$ARCH"
25 # unconfine the container, otherwise some tests fail
27 # disable automatic cgroup setup, instead let pid1 figure it out in mount_setup().
28 # This is especially important to ensure we get unified cgroup hierarchy
30 # FIXME: remove cgroup workarounds once the host runs on unified hierarchy
31 sudo
tee "/var/lib/lxc/$CONTAINER/config.systemd_upstream" <<EOF
32 lxc.apparmor.profile = unconfined
34 lxc.mount.auto = proc:mixed sys:mixed
35 lxc.init.cmd = /sbin/init systemd.unified_cgroup_hierarchy=1
38 sudo lxc-start
-n "$CONTAINER" --define "lxc.include=/var/lib/lxc/$CONTAINER/config.systemd_upstream"
40 # enable source repositories so that apt-get build-dep works
41 sudo lxc-attach
-n "$CONTAINER" -- sh
-ex <<EOF
42 sed 's/^deb/deb-src/' /etc/apt/sources.list >>/etc/apt/sources.list.d/sources.list
43 echo "deb http://deb.debian.org/debian $RELEASE-backports main" >/etc/apt/sources.list.d/backports.list
44 # We might attach the console too soon
45 until systemctl --quiet --wait is-system-running; do sleep 1; done
46 # Manpages database trigger takes a lot of time and is not useful in a CI
47 echo 'man-db man-db/auto-update boolean false' | debconf-set-selections
48 # Speed up dpkg, image is thrown away after the test
49 mkdir -p /etc/dpkg/dpkg.cfg.d/
50 echo 'force-unsafe-io' >/etc/dpkg/dpkg.cfg.d/unsafe_io
51 # For some reason, it is necessary to run this manually or the interface won't be configured
52 # Note that we avoid networkd, as some of the tests will break it later on
54 apt-get -q --allow-releaseinfo-change update
55 apt-get -y dist-upgrade
56 apt-get install -y eatmydata
57 # The following four are needed as long as these deps are not covered by Debian's own packaging
58 apt-get install -y tree libpwquality-dev rpm libcurl4-openssl-dev libarchive-dev
59 # autopkgtest doesn't consider backports
60 apt-get install -y -t $RELEASE-backports debhelper
61 apt-get purge --auto-remove -y unattended-upgrades
62 systemctl unmask systemd-networkd
63 systemctl enable systemd-networkd
65 sudo lxc-stop
-n "$CONTAINER"
68 for phase
in "${PHASES[@]}"; do
71 # remove semaphore repos, some of them don't work and cause error messages
72 sudo
rm -rf /etc
/apt
/sources.list.d
/*
74 # enable backports for latest LXC
75 echo "deb http://archive.ubuntu.com/ubuntu $UBUNTU_RELEASE-backports main restricted universe multiverse" | sudo
tee -a /etc
/apt
/sources.list.d
/backports.list
76 sudo apt-get
-q update
77 sudo apt-get
install -y -t "$UBUNTU_RELEASE-backports" lxc
78 sudo apt-get
install -y python3-debian git dpkg-dev fakeroot python3-jinja2
80 [ -d "$AUTOPKGTEST_DIR" ] || git clone
--quiet --depth=1 https
://salsa.debian.org
/ci-team
/autopkgtest.git
"$AUTOPKGTEST_DIR"
85 # add current debian/ packaging
86 git fetch
--depth=1 "$SALSA_URL" "$BRANCH"
87 git checkout FETCH_HEAD debian
90 UPSTREAM_VER
="$(git describe | sed 's/^v//;s/-/./g')"
91 cat <<EOF >debian/changelog.new
92 systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low
94 * Automatic build for upstream test
96 -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R)
99 cat debian
/changelog
>>debian
/changelog.new
100 mv debian
/changelog.new debian
/changelog
103 rm -rf debian
/patches
104 # disable autopkgtests which are not for upstream
105 sed -i '/# NOUPSTREAM/ q' debian
/tests
/control
106 # enable more unit tests
107 sed -i '/^CONFFLAGS =/ s/=/= --werror /' debian
/rules
109 echo '1.0' >debian
/source
/format
111 # build source package
112 dpkg-buildpackage
-S -I -I"$(basename "$CACHE_DIR")" -d -us -uc -nc
114 # now build the package and run the tests
115 rm -rf "$ARTIFACTS_DIR"
116 # autopkgtest exits with 2 for "some tests skipped", accept that
117 sudo TMPDIR
=/var
/tmp
"$AUTOPKGTEST_DIR/runner/autopkgtest" --env DEB_BUILD_OPTIONS
="noudeb nostrip nodoc optimize=-lto" \
118 --env DPKG_DEB_COMPRESSOR_TYPE
="none" \
119 --env DEB_BUILD_PROFILES
="pkg.systemd.upstream noudeb nodoc" \
120 --env TEST_UPSTREAM
=1 \
122 -o "$ARTIFACTS_DIR" \
123 -- lxc
-s "$CONTAINER" \
124 --define "lxc.include=/var/lib/lxc/$CONTAINER/config.systemd_upstream" \
128 echo >&2 "Unknown phase '$phase'"