boot: Make sure we take --root into account everywhere.
This commit is contained in:
committed by
Luca Boccassi
parent
dbfd5d3837
commit
77db9ef2ab
@@ -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
|
* 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
|
* 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. */
|
* 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;
|
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_LAYOUT", &layout,
|
||||||
"KERNEL_INSTALL_MACHINE_ID", &s);
|
"KERNEL_INSTALL_MACHINE_ID", &s);
|
||||||
if (r == -ENOENT)
|
if (r == -ENOENT)
|
||||||
@@ -83,7 +87,7 @@ static int load_etc_kernel_install_conf(void) {
|
|||||||
_cleanup_free_ char *layout = NULL, *p = NULL;
|
_cleanup_free_ char *layout = NULL, *p = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
p = path_join(etc_kernel(), "install.conf");
|
p = path_join(arg_root, etc_kernel(), "install.conf");
|
||||||
if (!p)
|
if (!p)
|
||||||
return log_oom();
|
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)
|
if (!arg_make_entry_directory && arg_entry_token_type == ARG_ENTRY_TOKEN_MACHINE_ID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
p = path_join(etc_kernel(), "entry-token");
|
p = path_join(arg_root, etc_kernel(), "entry-token");
|
||||||
if (!p)
|
if (!p)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ int settle_entry_token(void) {
|
|||||||
|
|
||||||
case ARG_ENTRY_TOKEN_AUTO: {
|
case ARG_ENTRY_TOKEN_AUTO: {
|
||||||
_cleanup_free_ char *buf = NULL, *p = NULL;
|
_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)
|
if (!p)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
r = read_one_line_file(p, &buf);
|
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)) {
|
} else if (sd_id128_is_null(arg_machine_id)) {
|
||||||
_cleanup_free_ char *id = NULL, *image_id = NULL;
|
_cleanup_free_ char *id = NULL, *image_id = NULL;
|
||||||
|
|
||||||
r = parse_os_release(NULL,
|
r = parse_os_release(arg_root,
|
||||||
"IMAGE_ID", &image_id,
|
"IMAGE_ID", &image_id,
|
||||||
"ID", &id);
|
"ID", &id);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@@ -171,7 +171,7 @@ int settle_entry_token(void) {
|
|||||||
case ARG_ENTRY_TOKEN_OS_IMAGE_ID: {
|
case ARG_ENTRY_TOKEN_OS_IMAGE_ID: {
|
||||||
_cleanup_free_ char *buf = NULL;
|
_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)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to load /etc/os-release: %m");
|
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: {
|
case ARG_ENTRY_TOKEN_OS_ID: {
|
||||||
_cleanup_free_ char *buf = NULL;
|
_cleanup_free_ char *buf = NULL;
|
||||||
|
|
||||||
r = parse_os_release(NULL, "ID", &buf);
|
r = parse_os_release(arg_root, "ID", &buf);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_error_errno(r, "Failed to load /etc/os-release: %m");
|
return log_error_errno(r, "Failed to load /etc/os-release: %m");
|
||||||
|
|
||||||
|
|||||||
@@ -90,18 +90,21 @@ if test -x "$_KERNEL_INSTALL_BOOTCTL"; then
|
|||||||
echo "Testing bootctl"
|
echo "Testing bootctl"
|
||||||
e2="${entry%+*}_2.conf"
|
e2="${entry%+*}_2.conf"
|
||||||
cp "$entry" "$e2"
|
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
|
# create file that is not referenced. Check if cleanup removes
|
||||||
# it but leaves the rest alone
|
# it but leaves the rest alone
|
||||||
:> "$BOOT_ROOT/the-token/1.1.2/initrd"
|
:> "$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/initrd"
|
||||||
test -e "$BOOT_ROOT/the-token/1.1.2/linux"
|
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/linux"
|
||||||
test -e "$BOOT_ROOT/the-token/1.1.1/initrd"
|
test -e "$BOOT_ROOT/the-token/1.1.1/initrd"
|
||||||
|
|
||||||
# now remove duplicated entry and make sure files are left over
|
# 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/linux"
|
||||||
test -e "$BOOT_ROOT/the-token/1.1.1/initrd"
|
test -e "$BOOT_ROOT/the-token/1.1.1/initrd"
|
||||||
test -e "$entry"
|
test -e "$entry"
|
||||||
@@ -109,7 +112,7 @@ if test -x "$_KERNEL_INSTALL_BOOTCTL"; then
|
|||||||
# remove last entry referencing those files
|
# remove last entry referencing those files
|
||||||
entry_id="${entry##*/}"
|
entry_id="${entry##*/}"
|
||||||
entry_id="${entry_id%+*}.conf"
|
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 "$entry"
|
||||||
test ! -e "$BOOT_ROOT/the-token/1.1.1/linux"
|
test ! -e "$BOOT_ROOT/the-token/1.1.1/linux"
|
||||||
test ! -e "$BOOT_ROOT/the-token/1.1.1/initrd"
|
test ! -e "$BOOT_ROOT/the-token/1.1.1/initrd"
|
||||||
|
|||||||
Reference in New Issue
Block a user