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 18:53:29 +09:00
parent cf4dbd84ac
commit a5ebaf7982
2 changed files with 10 additions and 0 deletions
+9
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;