From: Daan De Meyer Date: Wed, 24 Apr 2024 19:21:34 +0000 (+0200) Subject: mkosi: Build minimal images and enable related integration tests X-Git-Tag: v256-rc1~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c77dad706bbb039bd88d1256b7d35158acb68a5e;p=thirdparty%2Fsystemd.git mkosi: Build minimal images and enable related integration tests This commit adds definitions to build the minimal_0 and minimal_1 images with mkosi and includes them into the system image. We also move the building of the various app-xxx and similar images that are extremely minimal into the tests itself by moving the related logic from install_verity_minimal() into a new function install_extension_images() in util.sh. Because the mkosi /usr is read-only, we now place the extension images in /tmp instead of /usr/share. Co-authored-by: Richard Maw Co-authored-by: sam-leonard-ct --- diff --git a/mkosi.images/minimal-0/mkosi.conf b/mkosi.images/minimal-0/mkosi.conf new file mode 100644 index 00000000000..3315d4b4a9c --- /dev/null +++ b/mkosi.images/minimal-0/mkosi.conf @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Config] +Dependencies=minimal-base + +[Distribution] +CacheOnly=always + +[Output] +Format=portable +SplitArtifacts=yes + +[Content] +BaseTrees=%O/minimal-base +Environment=SYSTEMD_REPART_OVERRIDE_FSTYPE=squashfs +Bootable=no + +BuildSources= +Packages= +BuildPackages= +VolatilePackages= + +[Host] +Incremental=no diff --git a/mkosi.images/minimal-0/mkosi.extra/opt/some_file b/mkosi.images/minimal-0/mkosi.extra/opt/some_file new file mode 100644 index 00000000000..bd4fba4dfea --- /dev/null +++ b/mkosi.images/minimal-0/mkosi.extra/opt/some_file @@ -0,0 +1 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later diff --git a/mkosi.images/minimal-0/mkosi.extra/usr/lib/systemd/system/minimal-app0.service b/mkosi.images/minimal-0/mkosi.extra/usr/lib/systemd/system/minimal-app0.service new file mode 100644 index 00000000000..0532112f764 --- /dev/null +++ b/mkosi.images/minimal-0/mkosi.extra/usr/lib/systemd/system/minimal-app0.service @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Service] +ExecStartPre=cat /usr/lib/os-release +ExecStart=sleep 120 diff --git a/mkosi.images/minimal-0/mkosi.postinst b/mkosi.images/minimal-0/mkosi.postinst new file mode 100755 index 00000000000..a66cf68465a --- /dev/null +++ b/mkosi.images/minimal-0/mkosi.postinst @@ -0,0 +1,11 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux + +mkdir -p "$BUILDROOT/var/lib/app1" + +cat >>"$BUILDROOT/usr/lib/os-release" <>"$BUILDROOT/usr/lib/os-release" </dev/null; then ukify build --secureboot-private-key mkosi.key --secureboot-certificate mkosi.crt --cmdline this_should_be_here -o "$addons_dir/good.addon.efi" ukify build --cmdline this_should_not_be_here -o "$addons_dir/bad.addon.efi" fi + +for f in "$BUILDROOT"/usr/share/*.verity.sig; do + jq --join-output '.rootHash' "$f" >"${f%.verity.sig}.roothash" +done diff --git a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh index 1d1dab43c30..c05573595bc 100755 --- a/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh +++ b/test/TEST-43-PRIVATEUSER-UNPRIV/test.sh @@ -12,6 +12,7 @@ has_user_dbus_socket || exit 0 test_require_bin mksquashfs test_append_files() { + inst_binary mksquashfs inst_binary unsquashfs install_verity_minimal } diff --git a/test/meson.build b/test/meson.build index bd25e94276c..f8e40fa0065 100644 --- a/test/meson.build +++ b/test/meson.build @@ -338,6 +338,9 @@ integration_test_wrapper = find_program('integration-test-wrapper.py') integration_tests = { '01': 'TEST-01-BASIC', '02': 'TEST-02-UNITTESTS', + '29': 'TEST-29-PORTABLE', + '43': 'TEST-43-PRIVATEUSER-UNPRIV', + '50': 'TEST-50-DISSECT', } foreach test_number, dirname : integration_tests test_params = { diff --git a/test/test-functions b/test/test-functions index 67896fb30f6..c5a7216c06c 100644 --- a/test/test-functions +++ b/test/test-functions @@ -783,109 +783,6 @@ EOF mksquashfs "$initdir" "$oldinitdir/usr/share/minimal_1.raw" -noappend veritysetup format "$oldinitdir/usr/share/minimal_1.raw" "$oldinitdir/usr/share/minimal_1.verity" | \ grep '^Root hash:' | cut -f2 | tr -d '\n' >"$oldinitdir/usr/share/minimal_1.roothash" - - # Rolling distros like Arch do not set VERSION_ID - local version_id="" - if grep -q "^VERSION_ID=" "$os_release"; then - version_id="$(grep "^VERSION_ID=" "$os_release")" - fi - - export initdir="$TESTDIR/app0" - mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" "$initdir/opt" - grep "^ID=" "$os_release" >"$initdir/usr/lib/extension-release.d/extension-release.app0" - echo "${version_id}" >>"$initdir/usr/lib/extension-release.d/extension-release.app0" - ( echo "${version_id}" - echo "SYSEXT_IMAGE_ID=app" ) >>"$initdir/usr/lib/extension-release.d/extension-release.app0" - cat >"$initdir/usr/lib/systemd/system/app0.service" <"$initdir/opt/script0.sh" <\${STATE_DIRECTORY}/foo -cat /usr/lib/extension-release.d/extension-release.app0 -EOF - chmod +x "$initdir/opt/script0.sh" - echo MARKER=1 >"$initdir/usr/lib/systemd/system/some_file" - mksquashfs "$initdir" "$oldinitdir/usr/share/app0.raw" -noappend - - export initdir="$TESTDIR/conf0" - mkdir -p "$initdir/etc/extension-release.d" "$initdir/etc/systemd/system" "$initdir/opt" - grep "^ID=" "$os_release" >"$initdir/etc/extension-release.d/extension-release.conf0" - echo "${version_id}" >>"$initdir/etc/extension-release.d/extension-release.conf0" - ( echo "${version_id}" - echo "CONFEXT_IMAGE_ID=app" ) >>"$initdir/etc/extension-release.d/extension-release.conf0" - echo MARKER_1 >"$initdir/etc/systemd/system/some_file" - mksquashfs "$initdir" "$oldinitdir/usr/share/conf0.raw" -noappend - - export initdir="$TESTDIR/app1" - mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" "$initdir/opt" - grep "^ID=" "$os_release" >"$initdir/usr/lib/extension-release.d/extension-release.app2" - ( echo "${version_id}" - echo "SYSEXT_SCOPE=portable" - echo "SYSEXT_IMAGE_ID=app" - echo "SYSEXT_IMAGE_VERSION=1" - echo "PORTABLE_PREFIXES=app1" ) >>"$initdir/usr/lib/extension-release.d/extension-release.app2" - setfattr -n user.extension-release.strict -v false "$initdir/usr/lib/extension-release.d/extension-release.app2" - cat >"$initdir/usr/lib/systemd/system/app1.service" <"$initdir/opt/script1.sh" <\${STATE_DIRECTORY}/foo -cat /usr/lib/extension-release.d/extension-release.app2 -EOF - chmod +x "$initdir/opt/script1.sh" - echo MARKER=1 >"$initdir/usr/lib/systemd/system/other_file" - mksquashfs "$initdir" "$oldinitdir/usr/share/app1.raw" -noappend - - export initdir="$TESTDIR/app-nodistro" - mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" - ( echo "ID=_any" - echo "ARCHITECTURE=_any" ) >"$initdir/usr/lib/extension-release.d/extension-release.app-nodistro" - echo MARKER=1 >"$initdir/usr/lib/systemd/system/some_file" - mksquashfs "$initdir" "$oldinitdir/usr/share/app-nodistro.raw" -noappend - - export initdir="$TESTDIR/service-scoped-test" - mkdir -p "$initdir/etc/extension-release.d" "$initdir/etc/systemd/system" - ( echo "ID=_any" - echo "ARCHITECTURE=_any" ) >"$initdir/etc/extension-release.d/extension-release.service-scoped-test" - echo MARKER_CONFEXT_123 >"$initdir/etc/systemd/system/some_file" - mksquashfs "$initdir" "$oldinitdir/etc/service-scoped-test.raw" -noappend - - # We need to create a dedicated sysext image to test the reload mechanism. If we share an image to install the - # 'foo.service' it will be loaded from another test run, which will impact the targeted test. - export initdir="$TESTDIR/app-reload" - mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" - ( echo "ID=_any" - echo "ARCHITECTURE=_any" - echo "EXTENSION_RELOAD_MANAGER=1" ) >"$initdir/usr/lib/extension-release.d/extension-release.app-reload" - mkdir -p "$initdir/usr/lib/systemd/system/multi-user.target.d" - cat >"${initdir}/usr/lib/systemd/system/foo.service" < "$initdir/usr/lib/systemd/system/multi-user.target.d/10-foo-service.conf" - mksquashfs "$initdir" "$oldinitdir/usr/share/app-reload.raw" -noappend ) } diff --git a/test/units/testsuite-29.sh b/test/units/testsuite-29.sh index 4c0f1ba3293..27c24a0e6cc 100755 --- a/test/units/testsuite-29.sh +++ b/test/units/testsuite-29.sh @@ -5,6 +5,11 @@ set -eux set -o pipefail +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + +install_extension_images + # Set longer timeout for slower machines, e.g. non-KVM vm. mkdir -p /run/systemd/system.conf.d cat >/run/systemd/system.conf.d/10-timeout.conf </skipped exit 77 @@ -130,7 +132,7 @@ umount /tmp/img_bind # Unprivileged overlayfs was added to Linux 5.11, so try to detect it first mkdir -p /tmp/a /tmp/b /tmp/c if unshare --mount --user --map-root-user mount -t overlay overlay /tmp/c -o lowerdir=/tmp/a:/tmp/b; then - unsquashfs -no-xattrs -d /tmp/app2 /usr/share/app1.raw + unsquashfs -no-xattrs -d /tmp/app2 /tmp/app1.raw runas testuser systemd-run --wait --user --unit=test-extension-dir \ -p ExtensionDirectories=/tmp/app2 \ -p TemporaryFileSystem=/run -p RootDirectory=/tmp/img \ diff --git a/test/units/testsuite-50.dissect.sh b/test/units/testsuite-50.dissect.sh index 25bf4d8f939..de69b72ef12 100755 --- a/test/units/testsuite-50.dissect.sh +++ b/test/units/testsuite-50.dissect.sh @@ -18,6 +18,7 @@ BIND_LOG_SOCKETS=( systemd-dissect --json=short "$MINIMAL_IMAGE.raw" | \ grep -q -F '{"rw":"ro","designator":"root","partition_uuid":null,"partition_label":null,"fstype":"squashfs","architecture":null,"verity":"external"' systemd-dissect "$MINIMAL_IMAGE.raw" | grep -q -F "MARKER=1" +# shellcheck disable=SC2153 systemd-dissect "$MINIMAL_IMAGE.raw" | grep -q -F -f <(sed 's/"//g' "$OS_RELEASE") systemd-dissect --list "$MINIMAL_IMAGE.raw" | grep -q '^etc/os-release$' @@ -349,37 +350,37 @@ systemctl is-active testservice-50d.service # ExtensionImages will set up an overlay systemd-run -P \ - --property ExtensionImages=/usr/share/app0.raw \ + --property ExtensionImages=/tmp/app0.raw \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /opt/script0.sh | grep -q -F "extension-release.app0" systemd-run -P \ - --property ExtensionImages=/usr/share/app0.raw \ + --property ExtensionImages=/tmp/app0.raw \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /usr/lib/systemd/system/some_file | grep -q -F "MARKER=1" systemd-run -P \ - --property ExtensionImages="/usr/share/app0.raw /usr/share/app1.raw" \ + --property ExtensionImages="/tmp/app0.raw /tmp/app1.raw" \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /opt/script0.sh | grep -q -F "extension-release.app0" systemd-run -P \ - --property ExtensionImages="/usr/share/app0.raw /usr/share/app1.raw" \ + --property ExtensionImages="/tmp/app0.raw /tmp/app1.raw" \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /usr/lib/systemd/system/some_file | grep -q -F "MARKER=1" systemd-run -P \ - --property ExtensionImages="/usr/share/app0.raw /usr/share/app1.raw" \ + --property ExtensionImages="/tmp/app0.raw /tmp/app1.raw" \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /opt/script1.sh | grep -q -F "extension-release.app2" systemd-run -P \ - --property ExtensionImages="/usr/share/app0.raw /usr/share/app1.raw" \ + --property ExtensionImages="/tmp/app0.raw /tmp/app1.raw" \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /usr/lib/systemd/system/other_file | grep -q -F "MARKER=1" systemd-run -P \ - --property ExtensionImages=/usr/share/app-nodistro.raw \ + --property ExtensionImages=/tmp/app-nodistro.raw \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /usr/lib/systemd/system/some_file | grep -q -F "MARKER=1" @@ -389,11 +390,11 @@ systemd-run -P \ "${BIND_LOG_SOCKETS[@]}" \ cat /etc/systemd/system/some_file | grep -q -F "MARKER_CONFEXT_123" # Check that using a symlink to NAME-VERSION.raw works as long as the symlink has the correct name NAME.raw -mkdir -p /usr/share/symlink-test/ -cp /usr/share/app-nodistro.raw /usr/share/symlink-test/app-nodistro-v1.raw -ln -fs /usr/share/symlink-test/app-nodistro-v1.raw /usr/share/symlink-test/app-nodistro.raw +mkdir -p /tmp/symlink-test/ +cp /tmp/app-nodistro.raw /tmp/symlink-test/app-nodistro-v1.raw +ln -fs /tmp/symlink-test/app-nodistro-v1.raw /tmp/symlink-test/app-nodistro.raw systemd-run -P \ - --property ExtensionImages=/usr/share/symlink-test/app-nodistro.raw \ + --property ExtensionImages=/tmp/symlink-test/app-nodistro.raw \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /usr/lib/systemd/system/some_file | grep -q -F "MARKER=1" @@ -409,13 +410,13 @@ systemd-run -P \ cat /etc/systemd/system/some_file | grep -q -F "MARKER_CONFEXT_123" # And again mixing sysext and confext systemd-run -P \ - --property ExtensionImages=/usr/share/symlink-test/app-nodistro.raw \ + --property ExtensionImages=/tmp/symlink-test/app-nodistro.raw \ --property ExtensionImages=/etc/symlink-test/service-scoped-test.raw \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /etc/systemd/system/some_file | grep -q -F "MARKER_CONFEXT_123" systemd-run -P \ - --property ExtensionImages=/usr/share/symlink-test/app-nodistro.raw \ + --property ExtensionImages=/tmp/symlink-test/app-nodistro.raw \ --property ExtensionImages=/etc/symlink-test/service-scoped-test.raw \ --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ @@ -427,7 +428,7 @@ MountAPIVFS=yes TemporaryFileSystem=/run /var/lib StateDirectory=app0 RootImage=$MINIMAL_IMAGE.raw -ExtensionImages=/usr/share/app0.raw /usr/share/app1.raw:nosuid +ExtensionImages=/tmp/app0.raw /tmp/app1.raw:nosuid BindReadOnlyPaths=/dev/log /run/systemd/journal/socket /run/systemd/journal/stdout # Relevant only for sanitizer runs UnsetEnvironment=LD_PRELOAD @@ -444,8 +445,8 @@ VBASE="vtest$RANDOM" VDIR="/tmp/$VBASE.v" mkdir "$VDIR" -ln -s /usr/share/app0.raw "$VDIR/${VBASE}_0.raw" -ln -s /usr/share/app1.raw "$VDIR/${VBASE}_1.raw" +ln -s /tmp/app0.raw "$VDIR/${VBASE}_0.raw" +ln -s /tmp/app1.raw "$VDIR/${VBASE}_1.raw" systemd-run -P -p ExtensionImages="$VDIR" bash -c '/opt/script1.sh | grep ID' @@ -463,9 +464,9 @@ mkdir -p "$IMAGE_DIR/app0" "$IMAGE_DIR/app1" "$IMAGE_DIR/app-nodistro" "$IMAGE_D --property RootImage="$MINIMAL_IMAGE.raw" \ "${BIND_LOG_SOCKETS[@]}" \ cat /opt/script0.sh) -systemd-dissect --mount /usr/share/app0.raw "$IMAGE_DIR/app0" -systemd-dissect --mount /usr/share/app1.raw "$IMAGE_DIR/app1" -systemd-dissect --mount /usr/share/app-nodistro.raw "$IMAGE_DIR/app-nodistro" +systemd-dissect --mount /tmp/app0.raw "$IMAGE_DIR/app0" +systemd-dissect --mount /tmp/app1.raw "$IMAGE_DIR/app1" +systemd-dissect --mount /tmp/app-nodistro.raw "$IMAGE_DIR/app-nodistro" systemd-dissect --mount /etc/service-scoped-test.raw "$IMAGE_DIR/service-scoped-test" systemd-run -P \ --property ExtensionDirectories="$IMAGE_DIR/app0" \ @@ -542,7 +543,7 @@ systemd-dissect --umount "$IMAGE_DIR/app1" # Test that an extension consisting of an empty directory under /etc/extensions/ takes precedence mkdir -p /var/lib/extensions/ -ln -s /usr/share/app-nodistro.raw /var/lib/extensions/app-nodistro.raw +ln -s /tmp/app-nodistro.raw /var/lib/extensions/app-nodistro.raw systemd-sysext merge grep -q -F "MARKER=1" /usr/lib/systemd/system/some_file systemd-sysext unmerge @@ -715,7 +716,7 @@ systemd-run -P -p RootImage="$MINIMAL_IMAGE.raw" "${BIND_LOG_SOCKETS[@]}" cat /r # Test that systemd-sysext reloads the daemon. mkdir -p /var/lib/extensions/ -ln -s /usr/share/app-reload.raw /var/lib/extensions/app-reload.raw +ln -s /tmp/app-reload.raw /var/lib/extensions/app-reload.raw systemd-sysext merge --no-reload # the service should not be running (! systemctl --quiet is-active foo.service) diff --git a/test/units/testsuite-50.sh b/test/units/testsuite-50.sh index 8c4d2bfc3f9..d014e824fce 100755 --- a/test/units/testsuite-50.sh +++ b/test/units/testsuite-50.sh @@ -6,6 +6,9 @@ set -o pipefail # shellcheck source=test/units/test-control.sh . "$(dirname "$0")"/test-control.sh +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + # Setup shared stuff & run all subtests at_exit() { @@ -103,6 +106,8 @@ cp -v /usr/share/minimal* "$IMAGE_DIR/" MINIMAL_IMAGE="$IMAGE_DIR/minimal_0" MINIMAL_IMAGE_ROOTHASH="$(<"$MINIMAL_IMAGE.roothash")" +install_extension_images + OS_RELEASE="$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release)" if systemctl --version | grep -q -- +OPENSSL ; then diff --git a/test/units/util.sh b/test/units/util.sh index dc5dd1e1ecc..8eea263135b 100755 --- a/test/units/util.sh +++ b/test/units/util.sh @@ -241,3 +241,123 @@ maybe_umount_usr_overlay() { umount -l /usr fi } + +install_extension_images() { + local os_release + os_release="$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release)" + + # Rolling distros like Arch do not set VERSION_ID + local version_id="" + if grep -q "^VERSION_ID=" "$os_release"; then + version_id="$(grep "^VERSION_ID=" "$os_release")" + fi + + local initdir="/var/tmp/app0" + mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" "$initdir/opt" + grep "^ID=" "$os_release" >"$initdir/usr/lib/extension-release.d/extension-release.app0" + echo "$version_id" >>"$initdir/usr/lib/extension-release.d/extension-release.app0" + ( + echo "$version_id" + echo "SYSEXT_IMAGE_ID=app" + ) >>"$initdir/usr/lib/extension-release.d/extension-release.app0" + cat >"$initdir/usr/lib/systemd/system/app0.service" <"$initdir/opt/script0.sh" <\${STATE_DIRECTORY}/foo +cat /usr/lib/extension-release.d/extension-release.app0 +EOF + chmod +x "$initdir/opt/script0.sh" + echo MARKER=1 >"$initdir/usr/lib/systemd/system/some_file" + mksquashfs "$initdir" /tmp/app0.raw -noappend + + initdir="/var/tmp/conf0" + mkdir -p "$initdir/etc/extension-release.d" "$initdir/etc/systemd/system" "$initdir/opt" + grep "^ID=" "$os_release" >"$initdir/etc/extension-release.d/extension-release.conf0" + echo "$version_id" >>"$initdir/etc/extension-release.d/extension-release.conf0" + ( + echo "$version_id" + echo "CONFEXT_IMAGE_ID=app" + ) >>"$initdir/etc/extension-release.d/extension-release.conf0" + echo MARKER_1 >"$initdir/etc/systemd/system/some_file" + mksquashfs "$initdir" /tmp/conf0.raw -noappend + + initdir="/var/tmp/app1" + mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" "$initdir/opt" + grep "^ID=" "$os_release" >"$initdir/usr/lib/extension-release.d/extension-release.app2" + ( + echo "$version_id" + echo "SYSEXT_SCOPE=portable" + echo "SYSEXT_IMAGE_ID=app" + echo "SYSEXT_IMAGE_VERSION=1" + echo "PORTABLE_PREFIXES=app1" + ) >>"$initdir/usr/lib/extension-release.d/extension-release.app2" + setfattr -n user.extension-release.strict -v false "$initdir/usr/lib/extension-release.d/extension-release.app2" + cat >"$initdir/usr/lib/systemd/system/app1.service" <"$initdir/opt/script1.sh" <\${STATE_DIRECTORY}/foo +cat /usr/lib/extension-release.d/extension-release.app2 +EOF + chmod +x "$initdir/opt/script1.sh" + echo MARKER=1 >"$initdir/usr/lib/systemd/system/other_file" + mksquashfs "$initdir" /tmp/app1.raw -noappend + + initdir="/var/tmp/app-nodistro" + mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" + ( + echo "ID=_any" + echo "ARCHITECTURE=_any" + ) >"$initdir/usr/lib/extension-release.d/extension-release.app-nodistro" + echo MARKER=1 >"$initdir/usr/lib/systemd/system/some_file" + mksquashfs "$initdir" /tmp/app-nodistro.raw -noappend + + initdir="/var/tmp/service-scoped-test" + mkdir -p "$initdir/etc/extension-release.d" "$initdir/etc/systemd/system" + ( + echo "ID=_any" + echo "ARCHITECTURE=_any" + ) >"$initdir/etc/extension-release.d/extension-release.service-scoped-test" + echo MARKER_CONFEXT_123 >"$initdir/etc/systemd/system/some_file" + mksquashfs "$initdir" /etc/service-scoped-test.raw -noappend + + # We need to create a dedicated sysext image to test the reload mechanism. If we share an image to install the + # 'foo.service' it will be loaded from another test run, which will impact the targeted test. + initdir="/var/tmp/app-reload" + mkdir -p "$initdir/usr/lib/extension-release.d" "$initdir/usr/lib/systemd/system" + ( + echo "ID=_any" + echo "ARCHITECTURE=_any" + echo "EXTENSION_RELOAD_MANAGER=1" + ) >"$initdir/usr/lib/extension-release.d/extension-release.app-reload" + mkdir -p "$initdir/usr/lib/systemd/system/multi-user.target.d" + cat >"$initdir/usr/lib/systemd/system/foo.service" <"$initdir/usr/lib/systemd/system/multi-user.target.d/10-foo-service.conf" + mksquashfs "$initdir" /tmp/app-reload.raw -noappend +}