From 28e1f84d6a2721000b0d781220b154f0bed50cc8 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 26 Jul 2026 12:27:08 +0100 Subject: [PATCH 1/3] test: add deb coverage to TEST-88-UPGRADE --- .../mkosi.conf.d/debian-ubuntu/mkosi.prepare | 90 +++++++++++++++++++ test/units/TEST-88-UPGRADE.sh | 25 +++++- 2 files changed, 111 insertions(+), 4 deletions(-) create mode 100755 mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare diff --git a/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare b/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare new file mode 100755 index 0000000000..3a4415c547 --- /dev/null +++ b/mkosi/mkosi.conf.d/debian-ubuntu/mkosi.prepare @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -e +set -o pipefail + +if [[ "$1" == "build" ]]; then + exit 0 +fi + +pkgdir=/usr/host-pkgs +develver=$(dpkg-query --root="$BUILDROOT" --showformat='${Version}' --show systemd) +distrover=$( + apt-cache madison systemd | + awk -F '|' '$3 !~ /file:\/+repository/ && !found { gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2); print $2; found=1 }' +) + +if [[ -z $distrover ]]; then + echo "Skipping upgrade test, no distro version found" + exit 0 +fi + +if [[ ${distrover#*:} =~ ^([0-9]+) ]]; then + distromajor=${BASH_REMATCH[1]} +else + echo "Skipping upgrade test, unable to parse distro version: $distrover" + exit 0 +fi + +if [[ ${develver#*:} =~ ^([0-9]+) ]]; then + develmajor=${BASH_REMATCH[1]} +else + echo "Skipping upgrade test, unable to parse development version: $develver" + exit 0 +fi + +deltaver=$((develmajor - distromajor)) + +if [[ $deltaver -le 0 ]]; then + echo "Skipping upgrade test, distro version is newer or equal: $distrover" + exit 0 +fi + +distro_packages=() +devel_packages=() + +while IFS=$'\t' read -r package source package_architecture; do + [[ $source == systemd ]] || continue + [[ $package_architecture == "$DISTRIBUTION_ARCHITECTURE" || $package_architecture == all ]] || continue + [[ $package != *-dbgsym* ]] || continue + + devel_packages+=("$package=$(dpkg-query --root="$BUILDROOT" --showformat='${Version}' --show "$package")") + + package_versions=$(apt-cache madison "$package") + if awk -F '|' -v version="$distrover" ' + $3 !~ /file:\/+repository/ { + gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2) + if ($2 == version) + found=1 + } + END { + exit !found + } + ' <<<"$package_versions"; then + distro_packages+=("$package=$distrover") + fi +done < <(dpkg-query --root="$BUILDROOT" --show --showformat='${binary:Package}\t${source:Package}\t${Architecture}\n') + +if (( ${#distro_packages[@]} == 0 )); then + echo "Skipping upgrade test, no distro packages found" + exit 0 +fi + +if (( ${#devel_packages[@]} == 0 )); then + echo "Skipping upgrade test, no development packages found" + exit 0 +fi + +rm -rf "$BUILDROOT$pkgdir/distro" "$BUILDROOT$pkgdir/devel" +mkdir -p "$BUILDROOT$pkgdir"/{distro,devel} + +# apt-get download writes packages to the current directory +( + cd "$BUILDROOT$pkgdir/distro" + apt-get download "${distro_packages[@]}" +) + +( + cd "$BUILDROOT$pkgdir/devel" + apt-get download "${devel_packages[@]}" +) diff --git a/test/units/TEST-88-UPGRADE.sh b/test/units/TEST-88-UPGRADE.sh index 5cc1df21aa..153fc0ba49 100755 --- a/test/units/TEST-88-UPGRADE.sh +++ b/test/units/TEST-88-UPGRADE.sh @@ -12,8 +12,25 @@ if ! [[ -d $pkgdir ]]; then exit 77 fi -if ! command -v dnf >/dev/null; then - echo 'dnf not found, skipping test.' >/skipped +if command -v dnf >/dev/null; then + package_extension=rpm + downgrade=(dnf downgrade --nogpgcheck -y --allowerasing --disablerepo '*') + upgrade=(dnf -y upgrade --nogpgcheck --disablerepo '*') +elif command -v apt-get >/dev/null; then + package_extension=deb + apt_sources=/run/TEST-88-UPGRADE.sources + apt_source_parts=/run/TEST-88-UPGRADE.sources.d + : >"$apt_sources" + mkdir -p "$apt_source_parts" + apt_options=( + -o "Dir::Etc::sourcelist=$apt_sources" + -o "Dir::Etc::sourceparts=$apt_source_parts" + --no-install-recommends + ) + downgrade=(apt-get "${apt_options[@]}" install --allow-downgrades -y) + upgrade=(apt-get "${apt_options[@]}" install -y) +else + echo 'No supported package manager found, skipping test.' >/skipped exit 77 fi @@ -84,7 +101,7 @@ timer2=$(systemctl show -P NextElapseUSecRealtime upgrade_timer_test.timer) # FIXME: See https://github.com/systemd/systemd/pull/39293 systemctl stop systemd-networkd-resolve-hook.socket || true -dnf downgrade --nogpgcheck -y --allowerasing --disablerepo '*' "$pkgdir"/distro/*.rpm +"${downgrade[@]}" "$pkgdir"/distro/*."$package_extension" # Some distros don't ship networkd, so the test will always fail if command -v networkctl >/dev/null; then @@ -105,7 +122,7 @@ fi check_sd # Finally test the upgrade -dnf -y upgrade --nogpgcheck --disablerepo '*' "$pkgdir"/devel/*.rpm +"${upgrade[@]}" "$pkgdir"/devel/*."$package_extension" # TODO: sanity checks check_sd From 14b93b64096156302793082eb2b22855dba4f6a2 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 26 Jul 2026 12:33:15 +0100 Subject: [PATCH 2/3] test: add a few more quick sanity checks to TEST-88-UPGRADE --- test/units/TEST-88-UPGRADE.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/units/TEST-88-UPGRADE.sh b/test/units/TEST-88-UPGRADE.sh index 153fc0ba49..513eacab14 100755 --- a/test/units/TEST-88-UPGRADE.sh +++ b/test/units/TEST-88-UPGRADE.sh @@ -36,6 +36,7 @@ fi minor=$(systemctl --version | awk '/^systemd/{print$2}') networkd= +resolved= unitscmd='systemctl list-units --failed *systemd*' if [[ $($unitscmd --output json | jq length) -gt 0 ]]; then @@ -46,6 +47,22 @@ fi check_sd() { local unit fail=0 timer1_new timer2_new + + if ! systemctl daemon-reload; then + echo 'System manager reload failed after the test!' + fail=1 + fi + + if ! systemd-run --quiet --wait --collect --service-type=exec true; then + echo 'Transient service failed after the test!' + fail=1 + fi + + if command -v udevadm >/dev/null && ! udevadm control --ping --timeout=5; then + echo 'Udev failed after the test!' + fail=1 + fi + for unit in $($unitscmd --output json | jq -r '.[].unit'); do if ! grep -sxqF "$unit" /tmp/failed-units; then fail=1 @@ -64,6 +81,13 @@ check_sd() { fi fi + if [[ -n $resolved ]]; then + if ! resolvectl status; then + echo 'Resolved failed after the test!' + fail=1 + fi + fi + if ! loginctl list-sessions; then echo 'Loginctl failed after the test!' fail=1 @@ -103,10 +127,13 @@ systemctl stop systemd-networkd-resolve-hook.socket || true "${downgrade[@]}" "$pkgdir"/distro/*."$package_extension" -# Some distros don't ship networkd, so the test will always fail +# Some distros don't ship networkd or resolved, so only test them when available if command -v networkctl >/dev/null; then networkd=1 fi +if command -v resolvectl >/dev/null && systemctl is-active --quiet systemd-resolved.service; then + resolved=1 +fi newminor=$(systemctl --version | awk '/^systemd/{print$2}') From a5819bd3f5998116235e1ea83902e424a5ae4039 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sun, 26 Jul 2026 13:18:49 +0100 Subject: [PATCH 3/3] test: udev might not be running in container, skip check in TEST-88-UPGRADE --- test/units/TEST-88-UPGRADE.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/units/TEST-88-UPGRADE.sh b/test/units/TEST-88-UPGRADE.sh index 513eacab14..90443dd09c 100755 --- a/test/units/TEST-88-UPGRADE.sh +++ b/test/units/TEST-88-UPGRADE.sh @@ -37,8 +37,13 @@ fi minor=$(systemctl --version | awk '/^systemd/{print$2}') networkd= resolved= +udev= unitscmd='systemctl list-units --failed *systemd*' +if command -v udevadm >/dev/null && systemctl is-active --quiet systemd-udevd.service; then + udev=1 +fi + if [[ $($unitscmd --output json | jq length) -gt 0 ]]; then echo 'Systemd failed units found before the test:' $unitscmd @@ -58,7 +63,7 @@ check_sd() { fail=1 fi - if command -v udevadm >/dev/null && ! udevadm control --ping --timeout=5; then + if [[ -n $udev ]] && ! udevadm control --ping --timeout=5; then echo 'Udev failed after the test!' fail=1 fi