dissect: optionally allow attaching images that do not qualify as DDIs with --attach (#43583)

It's nice to use --attach since it validates our images. So far, it
strictly insisted on checking that the image was a DDI however, which
limits its use for certain usecases.

Add "--relax" to address this limitation.

Fixes: #43605
This commit is contained in:
Yu Watanabe
2026-09-23 08:54:29 +09:00
committed by GitHub
6 changed files with 76 additions and 23 deletions
+12
View File
@@ -1066,6 +1066,18 @@ test ! -e "/dev/disk/by-loop-ref/$name"
systemd-dissect --detach "$MINIMAL_IMAGE.raw"
(! systemd-dissect --detach "$MINIMAL_IMAGE.raw")
# --attach --relax also works on images that do not qualify as DDI, e.g. an entirely blank one
BLANK_IMAGE="$(mktemp /var/tmp/blankXXX.raw)"
truncate -s 16M "$BLANK_IMAGE"
(! systemd-dissect --attach "$BLANK_IMAGE")
LOOP="$(systemd-dissect --attach --relax "$BLANK_IMAGE")"
test -b "$LOOP"
systemd-dissect --detach "$LOOP"
rm -f "$BLANK_IMAGE"
# --relax makes no sense for the other verbs
(! systemd-dissect --relax "$MINIMAL_IMAGE.raw")
# check for confext functionality
mkdir -p /run/confexts/test/etc/extension-release.d
echo "ID=_any" >/run/confexts/test/etc/extension-release.d/extension-release.test