bootctl: honor $KERNEL_INSTALL_CONF_ROOT

Honor $KERNEL_INSTALL_CONF_ROOT for reading config files, as
kernel-install does.
This commit is contained in:
Ludwig Nussel
2023-01-10 15:17:07 +01:00
committed by Lennart Poettering
parent cd48e23f6a
commit 2e76ca79b3
5 changed files with 29 additions and 9 deletions
+14 -6
View File
@@ -77,15 +77,18 @@ static int load_etc_machine_info(void) {
}
static int load_etc_kernel_install_conf(void) {
_cleanup_free_ char *layout = NULL;
_cleanup_free_ char *layout = NULL, *p = NULL;
int r;
r = parse_env_file(NULL, "/etc/kernel/install.conf",
"layout", &layout);
p = path_join(etc_kernel(), "install.conf");
if (!p)
return log_oom();
r = parse_env_file(NULL, p, "layout", &layout);
if (r == -ENOENT)
return 0;
if (r < 0)
return log_error_errno(r, "Failed to parse /etc/kernel/install.conf: %m");
return log_error_errno(r, "Failed to parse %s: %m", p);
if (!isempty(layout)) {
log_debug("layout=%s is specified in /etc/machine-info.", layout);
@@ -488,6 +491,7 @@ static int install_entry_directory(const char *root) {
}
static int install_entry_token(void) {
_cleanup_free_ char* p = NULL;
int r;
assert(arg_make_entry_directory >= 0);
@@ -499,9 +503,13 @@ static int install_entry_token(void) {
if (!arg_make_entry_directory && arg_entry_token_type == ARG_ENTRY_TOKEN_MACHINE_ID)
return 0;
r = write_string_file("/etc/kernel/entry-token", arg_entry_token, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
p = path_join(etc_kernel(), "entry-token");
if (!p)
return log_oom();
r = write_string_file(p, arg_entry_token, WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
if (r < 0)
return log_error_errno(r, "Failed to write entry token '%s' to /etc/kernel/entry-token", arg_entry_token);
return log_error_errno(r, "Failed to write entry token '%s' to %s", arg_entry_token, p);
return 0;
}