diff --git a/src/boot/bootctl-install.c b/src/boot/bootctl-install.c index 3dcb4687d1d..c795e75bc3d 100644 --- a/src/boot/bootctl-install.c +++ b/src/boot/bootctl-install.c @@ -43,10 +43,14 @@ static int load_etc_machine_info(void) { * for setting up the ESP in /etc/machine-info. The newer /etc/kernel/entry-token file, as well as * the $layout field in /etc/kernel/install.conf are better replacements for this though, hence this * has been deprecated and is only returned for compatibility. */ - _cleanup_free_ char *s = NULL, *layout = NULL; + _cleanup_free_ char *p = NULL, *s = NULL, *layout = NULL; int r; - r = parse_env_file(NULL, "/etc/machine-info", + p = path_join(arg_root, "etc/machine-info"); + if (!p) + return log_oom(); + + r = parse_env_file(NULL, p, "KERNEL_INSTALL_LAYOUT", &layout, "KERNEL_INSTALL_MACHINE_ID", &s); if (r == -ENOENT) @@ -83,7 +87,7 @@ static int load_etc_kernel_install_conf(void) { _cleanup_free_ char *layout = NULL, *p = NULL; int r; - p = path_join(etc_kernel(), "install.conf"); + p = path_join(arg_root, etc_kernel(), "install.conf"); if (!p) return log_oom(); @@ -506,7 +510,7 @@ static int install_entry_token(void) { if (!arg_make_entry_directory && arg_entry_token_type == ARG_ENTRY_TOKEN_MACHINE_ID) return 0; - p = path_join(etc_kernel(), "entry-token"); + p = path_join(arg_root, etc_kernel(), "entry-token"); if (!p) return log_oom(); diff --git a/src/boot/bootctl-util.c b/src/boot/bootctl-util.c index 859742a1261..f89721244ac 100644 --- a/src/boot/bootctl-util.c +++ b/src/boot/bootctl-util.c @@ -120,7 +120,7 @@ int settle_entry_token(void) { case ARG_ENTRY_TOKEN_AUTO: { _cleanup_free_ char *buf = NULL, *p = NULL; - p = path_join(etc_kernel(), "entry-token"); + p = path_join(arg_root, etc_kernel(), "entry-token"); if (!p) return log_oom(); r = read_one_line_file(p, &buf); @@ -133,7 +133,7 @@ int settle_entry_token(void) { } else if (sd_id128_is_null(arg_machine_id)) { _cleanup_free_ char *id = NULL, *image_id = NULL; - r = parse_os_release(NULL, + r = parse_os_release(arg_root, "IMAGE_ID", &image_id, "ID", &id); if (r < 0) @@ -171,7 +171,7 @@ int settle_entry_token(void) { case ARG_ENTRY_TOKEN_OS_IMAGE_ID: { _cleanup_free_ char *buf = NULL; - r = parse_os_release(NULL, "IMAGE_ID", &buf); + r = parse_os_release(arg_root, "IMAGE_ID", &buf); if (r < 0) return log_error_errno(r, "Failed to load /etc/os-release: %m"); @@ -185,7 +185,7 @@ int settle_entry_token(void) { case ARG_ENTRY_TOKEN_OS_ID: { _cleanup_free_ char *buf = NULL; - r = parse_os_release(NULL, "ID", &buf); + r = parse_os_release(arg_root, "ID", &buf); if (r < 0) return log_error_errno(r, "Failed to load /etc/os-release: %m"); diff --git a/src/kernel-install/test-kernel-install.sh b/src/kernel-install/test-kernel-install.sh index f16bb9f50f9..bc833e4cb26 100755 --- a/src/kernel-install/test-kernel-install.sh +++ b/src/kernel-install/test-kernel-install.sh @@ -90,18 +90,21 @@ if test -x "$_KERNEL_INSTALL_BOOTCTL"; then echo "Testing bootctl" e2="${entry%+*}_2.conf" cp "$entry" "$e2" - export SYSTEMD_ESP_PATH=/ + export SYSTEMD_ESP_PATH=/boot + # We use --root so strip the root prefix from KERNEL_INSTALL_CONF_ROOT + export KERNEL_INSTALL_CONF_ROOT="sources" # create file that is not referenced. Check if cleanup removes # it but leaves the rest alone :> "$BOOT_ROOT/the-token/1.1.2/initrd" - "$_KERNEL_INSTALL_BOOTCTL" --root="$BOOT_ROOT" cleanup + "$_KERNEL_INSTALL_BOOTCTL" --root="$D" cleanup test ! -e "$BOOT_ROOT/the-token/1.1.2/initrd" test -e "$BOOT_ROOT/the-token/1.1.2/linux" test -e "$BOOT_ROOT/the-token/1.1.1/linux" test -e "$BOOT_ROOT/the-token/1.1.1/initrd" + # now remove duplicated entry and make sure files are left over - "$_KERNEL_INSTALL_BOOTCTL" --root="$BOOT_ROOT" unlink "${e2##*/}" + "$_KERNEL_INSTALL_BOOTCTL" --root="$D" unlink "${e2##*/}" test -e "$BOOT_ROOT/the-token/1.1.1/linux" test -e "$BOOT_ROOT/the-token/1.1.1/initrd" test -e "$entry" @@ -109,7 +112,7 @@ if test -x "$_KERNEL_INSTALL_BOOTCTL"; then # remove last entry referencing those files entry_id="${entry##*/}" entry_id="${entry_id%+*}.conf" - "$_KERNEL_INSTALL_BOOTCTL" --root="$BOOT_ROOT" unlink "$entry_id" + "$_KERNEL_INSTALL_BOOTCTL" --root="$D" unlink "$entry_id" test ! -e "$entry" test ! -e "$BOOT_ROOT/the-token/1.1.1/linux" test ! -e "$BOOT_ROOT/the-token/1.1.1/initrd"