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.
This commit is contained in:
Yu Watanabe
2023-06-15 14:00:09 +09:00
parent cf4dbd84ac
commit a5ebaf7982
2 changed files with 10 additions and 0 deletions

View 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;

View File

@@ -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"