2 # SPDX-License-Identifier: LGPL-2.1-or-later
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}"
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)"
23 sudo lxc-create
-n "$CONTAINER" -t download
-- -d "$DISTRO" -r "$RELEASE" -a "$ARCH"
25 # unconfine the container, otherwise some tests fail
26 echo 'lxc.apparmor.profile = unconfined' | sudo
tee -a "/var/lib/lxc/$CONTAINER/config"
28 sudo lxc-start
-n "$CONTAINER"
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
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
55 sudo lxc-stop
-n "$CONTAINER"
58 for phase
in "${PHASES[@]}"; do
61 # remove semaphore repos, some of them don't work and cause error messages
62 sudo
rm -rf /etc
/apt
/sources.list.d
/*
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
70 [ -d "$AUTOPKGTEST_DIR" ] || git clone
--quiet --depth=1 https
://salsa.debian.org
/ci-team
/autopkgtest.git
"$AUTOPKGTEST_DIR"
75 # add current debian/ packaging
76 git fetch
--depth=1 "$SALSA_URL" "$BRANCH"
77 git checkout FETCH_HEAD debian
80 UPSTREAM_VER
="$(git describe | sed 's/^v//;s/-/./g')"
81 cat <<EOF >debian/changelog.new
82 systemd (${UPSTREAM_VER}.0) UNRELEASED; urgency=low
84 * Automatic build for upstream test
86 -- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $(date -R)
89 cat debian
/changelog
>>debian
/changelog.new
90 mv debian
/changelog.new debian
/changelog
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
99 echo '1.0' >debian
/source
/format
101 # build source package
102 dpkg-buildpackage
-S -I -I"$(basename "$CACHE_DIR")" -d -us -uc -nc
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 \
112 -o "$ARTIFACTS_DIR" \
113 -- lxc
-s "$CONTAINER" \
117 echo >&2 "Unknown phase '$phase'"