]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: also edit /etc/os-release if it's not a symlink when patching /usr/lib/os-relea...
authorLuca Boccassi <bluca@debian.org>
Tue, 19 Aug 2025 11:32:00 +0000 (12:32 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 3 Sep 2025 10:10:48 +0000 (12:10 +0200)
mkosi patches up /etc/os-release to add local IDs and fixup certain
issues, so when tests patch /usr/lib/ on the fly, copy to the version in
/etc/ too to avoid test failures when querying

6370s 10/98 systemd:integration-tests / TEST-07-PID1 FAIL 31.03s exit
status 1
6370s 25/98 systemd:integration-tests / TEST-29-PORTABLE FAIL 12.76s
exit status 1
6370s 33/98 systemd:integration-tests / TEST-43-PRIVATEUSER-UNPRIV FAIL
6.57s exit status 1
6370s 37/98 systemd:integration-tests / TEST-50-DISSECT FAIL 16.97s exit
status 1

This is particularly an issue when running these tests on debian unstable,
where mkosi has to fixup os-release to make it valid and avoid further
breakages:

https://github.com/systemd/mkosi/blob/main/mkosi/distributions/debian.py#L234
(cherry picked from commit b1cd38e893c5a0d353e2112acfc701ed29449c5e)

mkosi/mkosi.images/minimal-0/mkosi.postinst
mkosi/mkosi.images/minimal-1/mkosi.postinst
test/units/TEST-50-DISSECT.sysext.sh

index a66cf68465ab79cb1c38865d825a00241940f2d1..8b009f5012f588f0cd34f73d895e9842d76f0287 100755 (executable)
@@ -8,4 +8,7 @@ cat >>"$BUILDROOT/usr/lib/os-release" <<EOF
 MARKER=1
 PORTABLE_PREFIXES=app0 minimal minimal-app0
 EOF
+if [ ! -L "$BUILDROOT/etc/os-release" ]; then
+    cp "$BUILDROOT/usr/lib/os-release" "$BUILDROOT/etc/os-release"
+fi
 cp "$BUILDROOT/usr/lib/systemd/system/minimal-app0.service" "$BUILDROOT/usr/lib/systemd/system/minimal-app0-foo.service"
index e2d08d04d8833ee0bed1d34dd627dc646a15e790..a971748ad9657d051ccd6efc5cf1d6426b542485 100755 (executable)
@@ -8,4 +8,7 @@ cat >>"$BUILDROOT/usr/lib/os-release" <<EOF
 MARKER=2
 PORTABLE_PREFIXES=app0 minimal minimal-app0
 EOF
+if [ ! -L "$BUILDROOT/etc/os-release" ]; then
+    cp "$BUILDROOT/usr/lib/os-release" "$BUILDROOT/etc/os-release"
+fi
 cp "$BUILDROOT/usr/lib/systemd/system/minimal-app0.service" "$BUILDROOT/usr/lib/systemd/system/minimal-app0-bar.service"
index 6bb106bac26b1464bb0618c281f8f4bde51499fe..5302314d2617361bf50d007a1759722523e02b0b 100755 (executable)
@@ -89,6 +89,11 @@ prepare_root() {
         echo "VERSION=1.2.3"
     } >"$root/usr/lib/os-release"
 
+    if [[ -e $root/etc/os-release ]] && [[ ! -L $root/etc/os-release ]]; then
+        mv "$root/etc/os-release" "$root/etc/os-release.orig"
+        cp "$root/usr/lib/os-release" "$root/etc/os-release"
+    fi
+
     prepend_trap "cleanup_os_release ${root@Q}"
 }
 
@@ -103,6 +108,11 @@ cleanup_os_release() {
         # shellcheck disable=SC2317 # It is not unreachable, used in a trap couple lines above.
         mv "$root/usr/lib/os-release.orig" "$root/usr/lib/os-release"
     fi
+    # shellcheck disable=SC2317 # It is not unreachable, used in a trap couple lines above.
+    if [[ -e $root/etc/os-release.orig ]]; then
+        # shellcheck disable=SC2317 # It is not unreachable, used in a trap couple lines above.
+        mv "$root/etc/os-release.orig" "$root/etc/os-release"
+    fi
 }
 
 prepare_extension_image() {