]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test/portable: Ensure ExtensionImages is set for any dep 40911/head
authorRodrigo Campos <rodrigo@amutable.com>
Mon, 2 Mar 2026 15:02:06 +0000 (16:02 +0100)
committerRodrigo Campos <rodrigo@amutable.com>
Tue, 3 Mar 2026 08:38:36 +0000 (09:38 +0100)
The previous commit made portablectl attach add a drop-in for any
extension image. Let's add a test for that too.

test/units/TEST-29-PORTABLE.image.sh
test/units/util.sh

index 36d187a75288d86d26d5fcb4e022dff53a238347..3018e86ecdee10792c14dd4bbd2287f93f34d3e0 100755 (executable)
@@ -212,6 +212,19 @@ portablectl inspect --force --cat --extension /tmp/app0.raw --extension /tmp/con
 
 portablectl detach --now --runtime --extension /tmp/app0.raw --extension /tmp/conf0.raw /usr/share/minimal_0.raw app0
 
+# Ensure that ExtensionImages= is added to the drop-in even when the extension has no unit files
+# (all units come from the base image).
+portablectl "${ARGS[@]}" attach --force --now --runtime --extension /tmp/app-data-only.raw /usr/share/minimal_0.raw minimal-app0
+
+systemctl is-active minimal-app0.service
+status="$(portablectl is-attached --extension app-data-only minimal_0)"
+[[ "${status}" == "running-runtime" ]]
+
+grep -q -F "ExtensionImages=/tmp/app-data-only.raw" /run/systemd/system.attached/minimal-app0.service.d/20-portable.conf
+grep -q -F "LogExtraFields=PORTABLE_EXTENSION=app-data-only.raw" /run/systemd/system.attached/minimal-app0.service.d/20-portable.conf
+
+portablectl detach --now --runtime --extension /tmp/app-data-only.raw /usr/share/minimal_0.raw minimal-app0
+
 # Ensure that mixed mode copies the images and units (client-owned) but symlinks the profile (OS owned)
 portablectl "${ARGS[@]}" attach --copy=mixed --runtime --extension /tmp/app0.raw /usr/share/minimal_0.raw app0
 test -f /run/portables/app0.raw
index 6f03f5e33996c2fd90ac05982728e173cd5ac84f..d9e561e79186ae4331e50c2190ddf4ca4b825247 100755 (executable)
@@ -401,6 +401,18 @@ EOF
         echo MARKER=1 >"$initdir/usr/lib/systemd/system/other_file"
         mksquashfs "$initdir" /tmp/app1.raw -noappend
 
+        # Create a data-only extension image (no unit files) to test that
+        # ExtensionImages= is added to the drop-in even when the extension
+        # does not carry any units.
+        initdir="/var/tmp/app-data-only"
+        mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/opt"
+        (
+            echo "ID=_any"
+            echo "ARCHITECTURE=_any"
+        ) >"$initdir/usr/lib/extension-release.d/extension-release.app-data-only"
+        echo "MARKER_DATA_ONLY=1" >"$initdir/opt/data-file"
+        mksquashfs "$initdir" /tmp/app-data-only.raw -noappend
+
         initdir="/var/tmp/app-nodistro"
         mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system"
         (