]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: skip to read /etc/machine-info in test
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 15 Jun 2023 05:00:09 +0000 (14:00 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 15 Jun 2023 09:53:29 +0000 (18:53 +0900)
We do not provide any way to override /etc/machine-info.
As the file is deprecated in kernel-install, let's skip to read it when
we test kernel-install.

Fixes #28011.

src/kernel-install/kernel-install.c
src/kernel-install/test-kernel-install.sh

index c0988b79c95787d38b443ff70e38dcd4c382d6b0..64833e53d9fc73f3dfd972f28ba2003cf32b26a2 100644 (file)
@@ -414,6 +414,15 @@ static int context_load_machine_info(Context *c) {
         if (!sd_id128_is_null(c->machine_id) && c->layout >= 0)
                 return 0;
 
+        /* For testing. To make not read host's /etc/machine-info. */
+        r = getenv_bool("KERNEL_INSTALL_READ_MACHINE_INFO");
+        if (r < 0 && r != -ENXIO)
+                log_warning_errno(r, "Failed to read $KERNEL_INSTALL_READ_MACHINE_INFO, assuming yes: %m");
+        if (r == 0) {
+                log_debug("Skipping to read /etc/machine-info.");
+                return 0;
+        }
+
         r = chaseat(c->rfd, path, CHASE_AT_RESOLVE_IN_ROOT, NULL, &fd);
         if (r == -ENOENT)
                 return 0;
index edc67e46fb9b3c929b958c7bdcfec90bfd456499..b7b7eae7e1d0032f4cf7fa2a36df5dab86cc5b7c 100755 (executable)
@@ -47,6 +47,7 @@ export BOOT_MNT="$D/boot"
 export MACHINE_ID='3e0484f3634a418b8e6a39e8828b03e3'
 export KERNEL_INSTALL_UKIFY="$ukify"
 export KERNEL_INSTALL_BOOT_STUB="$boot_stub"
+export KERNEL_INSTALL_READ_MACHINE_INFO="no"
 
 # Test type#1 installation
 "$kernel_install" -v add 1.1.1 "$D/sources/linux" "$D/sources/initrd"