kernel-install: also parse KERNEL_INSTALL_LAYOUT from /etc/machine-info

For consistency with bootctl.
This commit is contained in:
Yu Watanabe
2023-06-05 14:23:54 +09:00
parent f7665b7f6c
commit 1fd2af1ab8
+5 -3
View File
@@ -395,7 +395,7 @@ static int context_load_install_conf(Context *c) {
static int context_load_machine_info(Context *c) {
_cleanup_close_ int fd = -EBADF;
_cleanup_free_ char *machine_id = NULL;
_cleanup_free_ char *machine_id = NULL, *layout = NULL;
static const char *path = "/etc/machine-info";
int r;
@@ -404,7 +404,7 @@ static int context_load_machine_info(Context *c) {
/* If the user configured an explicit machine ID in /etc/machine-info to use for our purpose, we'll
* use that instead (for compatibility). */
if (!sd_id128_is_null(c->machine_id))
if (!sd_id128_is_null(c->machine_id) && c->layout >= 0)
return 0;
r = chaseat(c->rfd, path, CHASE_AT_RESOLVE_IN_ROOT, NULL, &fd);
@@ -416,11 +416,13 @@ static int context_load_machine_info(Context *c) {
log_debug("Loading %s…", path);
r = parse_env_file_fd(fd, path,
"KERNEL_INSTALL_MACHINE_ID", &machine_id);
"KERNEL_INSTALL_MACHINE_ID", &machine_id,
"KERNEL_INSTALL_LAYOUT", &layout);
if (r < 0)
return log_error_errno(r, "Failed to parse '%s': %m", path);
(void) context_set_machine_id(c, machine_id, path);
(void) context_set_layout(c, layout, path);
return 0;
}