From: Yu Watanabe Date: Thu, 15 Jun 2023 05:00:09 +0000 (+0900) Subject: kernel-install: skip to read /etc/machine-info in test X-Git-Tag: v254-rc1~199 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5ebaf7982282e2aa932f7840a9a1c71407705be;p=thirdparty%2Fsystemd.git kernel-install: skip to read /etc/machine-info in test 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. --- diff --git a/src/kernel-install/kernel-install.c b/src/kernel-install/kernel-install.c index c0988b79c95..64833e53d9f 100644 --- a/src/kernel-install/kernel-install.c +++ b/src/kernel-install/kernel-install.c @@ -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; diff --git a/src/kernel-install/test-kernel-install.sh b/src/kernel-install/test-kernel-install.sh index edc67e46fb9..b7b7eae7e1d 100755 --- a/src/kernel-install/test-kernel-install.sh +++ b/src/kernel-install/test-kernel-install.sh @@ -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"