2021-12-13 03:27:04 +08:00
#!/usr/bin/env bash
2021-10-01 18:10:22 +08:00
# SPDX-License-Identifier: LGPL-2.1-or-later
2019-04-24 13:52:49 +08:00
set -eux
2021-09-30 01:55:24 +08:00
set -o pipefail
2019-04-24 13:52:49 +08:00
# default to Debian testing
2021-09-30 01:55:24 +08:00
DISTRO = " ${ DISTRO :- debian } "
2023-06-15 20:34:17 +08:00
RELEASE = " ${ RELEASE :- bookworm } "
2024-05-20 20:08:26 +08:00
SALSA_URL = " ${ SALSA_URL :- https : //salsa.debian.org/systemd-team/systemd.git } "
2024-02-22 18:07:24 +08:00
BRANCH = " ${ BRANCH :- debian /master } "
2021-09-30 01:55:24 +08:00
ARCH = " ${ ARCH :- amd64 } "
CONTAINER = " ${ RELEASE } - ${ ARCH } "
2024-10-07 18:23:32 +08:00
CACHE_DIR = /var/tmp
TMPDIR = /var/tmp
2019-04-24 13:52:49 +08:00
AUTOPKGTEST_DIR = " ${ CACHE_DIR } /autopkgtest "
# semaphore cannot expose these, but useful for interactive/local runs
ARTIFACTS_DIR = /tmp/artifacts
2021-09-30 01:55:24 +08:00
# shellcheck disable=SC2206
2019-04-24 13:52:49 +08:00
PHASES = ( ${ @ :- SETUP RUN } )
2020-06-25 06:32:00 +08:00
UBUNTU_RELEASE = " $( lsb_release -cs) "
2019-04-24 13:52:49 +08:00
create_container( ) {
2022-08-11 17:32:21 +08:00
sudo lxc-create -n " $CONTAINER " -t download -- -d " $DISTRO " -r " $RELEASE " -a " $ARCH "
2019-04-24 13:52:49 +08:00
# unconfine the container, otherwise some tests fail
2021-09-30 01:55:24 +08:00
echo 'lxc.apparmor.profile = unconfined' | sudo tee -a " /var/lib/lxc/ $CONTAINER /config "
2019-04-24 13:52:49 +08:00
2021-09-30 01:55:24 +08:00
sudo lxc-start -n " $CONTAINER "
2019-04-24 13:52:49 +08:00
# enable source repositories so that apt-get build-dep works
2021-09-30 01:55:24 +08:00
sudo lxc-attach -n " $CONTAINER " -- sh -ex <<EOF
2023-02-06 04:41:24 +08:00
sed 's/^deb/deb-src/' /etc/apt/sources.list >>/etc/apt/sources.list.d/sources.list
2024-02-22 18:18:32 +08:00
echo " deb http://deb.debian.org/debian $RELEASE -backports main " >/etc/apt/sources.list.d/backports.list
2022-04-06 05:23:49 +08:00
# We might attach the console too soon
2023-09-06 20:51:07 +08:00
until systemctl --quiet --wait is-system-running; do sleep 1; done
2022-04-06 06:45:27 +08:00
# Manpages database trigger takes a lot of time and is not useful in a CI
echo 'man-db man-db/auto-update boolean false' | debconf-set-selections
# Speed up dpkg, image is thrown away after the test
mkdir -p /etc/dpkg/dpkg.cfg.d/
2023-02-06 04:41:24 +08:00
echo 'force-unsafe-io' >/etc/dpkg/dpkg.cfg.d/unsafe_io
2022-04-06 05:23:49 +08:00
# For some reason, it is necessary to run this manually or the interface won't be configured
# Note that we avoid networkd, as some of the tests will break it later on
dhclient
2019-07-08 00:17:17 +08:00
apt-get -q --allow-releaseinfo-change update
2019-04-24 13:52:49 +08:00
apt-get -y dist-upgrade
apt-get install -y eatmydata
2019-12-18 02:19:02 +08:00
# The following four are needed as long as these deps are not covered by Debian's own packaging
2024-03-09 20:43:36 +08:00
apt-get install -y tree libpwquality-dev rpm libcurl4-openssl-dev libarchive-dev
2024-02-22 18:18:32 +08:00
# autopkgtest doesn't consider backports
2024-03-09 20:43:36 +08:00
apt-get install -y -t $RELEASE -backports debhelper
2019-07-12 08:08:15 +08:00
apt-get purge --auto-remove -y unattended-upgrades
2019-09-25 13:19:12 +08:00
systemctl unmask systemd-networkd
systemctl enable systemd-networkd
2019-04-24 13:52:49 +08:00
EOF
2021-09-30 01:55:24 +08:00
sudo lxc-stop -n " $CONTAINER "
2019-04-24 13:52:49 +08:00
}
for phase in " ${ PHASES [@] } " ; do
2021-09-30 01:55:24 +08:00
case " $phase " in
2019-04-24 13:52:49 +08:00
SETUP)
# remove semaphore repos, some of them don't work and cause error messages
2022-11-07 23:39:12 +08:00
sudo rm -rf /etc/apt/sources.list.d/*
2019-04-24 13:52:49 +08:00
# enable backports for latest LXC
2020-06-25 06:32:00 +08:00
echo " deb http://archive.ubuntu.com/ubuntu $UBUNTU_RELEASE -backports main restricted universe multiverse " | sudo tee -a /etc/apt/sources.list.d/backports.list
2019-04-24 13:52:49 +08:00
sudo apt-get -q update
2020-06-25 06:32:00 +08:00
sudo apt-get install -y -t " $UBUNTU_RELEASE -backports " lxc
2021-05-17 16:36:30 +08:00
sudo apt-get install -y python3-debian git dpkg-dev fakeroot python3-jinja2
2019-04-24 13:52:49 +08:00
2024-03-09 20:42:32 +08:00
[ -d " $AUTOPKGTEST_DIR " ] || git clone --quiet --depth= 1 https://salsa.debian.org/ci-team/autopkgtest.git " $AUTOPKGTEST_DIR "
2019-04-24 13:52:49 +08:00
2019-07-12 08:08:15 +08:00
create_container
2019-04-24 13:52:49 +08:00
; ;
RUN)
# add current debian/ packaging
2024-05-20 20:08:26 +08:00
git fetch --depth= 1 " $SALSA_URL " " $BRANCH "
2019-04-24 13:52:49 +08:00
git checkout FETCH_HEAD debian
# craft changelog
2021-09-30 01:55:24 +08:00
UPSTREAM_VER = " $( git describe | sed 's/^v//;s/-/./g' ) "
2023-02-06 04:41:24 +08:00
cat <<EOF >debian/changelog.new
2020-04-05 03:50:41 +08:00
systemd ( ${ UPSTREAM_VER } .0) UNRELEASED; urgency = low
2019-04-24 13:52:49 +08:00
* Automatic build for upstream test
-- systemd test <pkg-systemd-maintainers@lists.alioth.debian.org> $( date -R)
EOF
2021-09-30 01:55:24 +08:00
cat debian/changelog >>debian/changelog.new
2019-04-24 13:52:49 +08:00
mv debian/changelog.new debian/changelog
# clean out patches
rm -rf debian/patches
# disable autopkgtests which are not for upstream
sed -i '/# NOUPSTREAM/ q' debian/tests/control
# enable more unit tests
2024-10-08 02:38:16 +08:00
sed -i '/^CONFFLAGS =/ s/=/= --werror /' debian/rules
2019-04-24 13:52:49 +08:00
# no orig tarball
2023-02-06 04:41:24 +08:00
echo '1.0' >debian/source/format
2019-04-24 13:52:49 +08:00
# build source package
2021-09-30 01:55:24 +08:00
dpkg-buildpackage -S -I -I" $( basename " $CACHE_DIR " ) " -d -us -uc -nc
2019-04-24 13:52:49 +08:00
# now build the package and run the tests
rm -rf " $ARTIFACTS_DIR "
# autopkgtest exits with 2 for "some tests skipped", accept that
2024-10-07 18:23:32 +08:00
sudo TMPDIR = /var/tmp " $AUTOPKGTEST_DIR /runner/autopkgtest " --env DEB_BUILD_OPTIONS = "noudeb nostrip optimize=-lto" \
2024-02-29 07:46:15 +08:00
--env DPKG_DEB_COMPRESSOR_TYPE = "none" \
--env DEB_BUILD_PROFILES = "pkg.systemd.upstream noudeb" \
2024-02-22 18:07:24 +08:00
--env TEST_UPSTREAM = 1 \
../systemd_*.dsc \
2022-08-11 19:36:15 +08:00
-o " $ARTIFACTS_DIR " \
-- lxc -s " $CONTAINER " \
2019-04-24 13:52:49 +08:00
|| [ $? -eq 2 ]
; ;
*)
echo >& 2 " Unknown phase ' $phase ' "
exit 1
esac
done