Skip to content

Commit 22655e6

Browse files
committed
install/bootloader when chrooting for bootupctl do try to pass the target rootfs path
1 parent 9706f1e commit 22655e6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/lib/src/bootloader.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ pub(crate) fn install_via_bootupd(
5555
// When not running inside the target container (through `--src-imgref`) we chroot
5656
// into the deployment before running bootupd. This makes sure we use binaries
5757
// from the target image rather than the buildroot
58+
// But then `/target` (or wherever the user mounted the target FS) is not available,
59+
// but since bootupd use that just to find the underlying device,
60+
// we can use the deployement path just fine.
61+
// Another way of doing this would be to enforce having the target
62+
// rootfs mounted under `/run` so we'd get access to it as part of
63+
// the standard bind-mounts below.
64+
let chroot_root: Option<&str>;
5865
let bind_mount_dirs = ["/dev", "/run", "/proc", "/sys"];
5966
let chroot_args = if let Some(target_root) = abs_deployment_path.as_deref() {
6067
tracing::debug!("Setting up bind-mounts before chrooting to the target deployment");
@@ -66,10 +73,12 @@ pub(crate) fn install_via_bootupd(
6673
tracing::debug!("bind mounting {}", dest.display());
6774
rustix::mount::mount_bind_recursive(src, dest)?;
6875
}
76+
chroot_root = Some("/");
6977
// Append the `bootupctl` command, it will be passed as
7078
// an argument to chroot
7179
vec![target_root.as_str(), "bootupctl"]
7280
} else {
81+
chroot_root = None;
7382
vec![]
7483
};
7584

@@ -85,7 +94,8 @@ pub(crate) fn install_via_bootupd(
8594
.args(["backend", "install", "--write-uuid"])
8695
.args(verbose)
8796
.args(bootupd_opts.iter().copied().flatten())
88-
.args(["--device", devpath.as_str(), rootfs.as_str()])
97+
.args(["--device", devpath.as_str()])
98+
.args(chroot_root.or(Some(rootfs.as_str())))
8999
.log_debug()
90100
.run_inherited_with_cmd_context();
91101

0 commit comments

Comments
 (0)