Skip to content

Commit f7891ca

Browse files
committed
test: just bind-mount target/boot in deploymnt/boot
1 parent 1a35bb5 commit f7891ca

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

crates/lib/src/bootloader.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,19 @@ pub(crate) fn install_via_bootupd(
103103
// let's bind mount it to a temp mountpoint under /run
104104
// so it gets carried over in the chroot.
105105

106-
let rootfs_mountpoint: TempDir;
106+
// let rootfs_mountpoint: TempDir;
107107
let rootfs_mount = if rootfs.starts_with("/run") {
108108
rootfs.as_str()
109109
} else {
110-
rootfs_mountpoint = tempfile::tempdir_in("/run")?;
111-
rustix::mount::mount_bind_recursive(
112-
rootfs.as_std_path(),
113-
&rootfs_mountpoint.path().to_owned(),
114-
)?;
115-
rootfs_mountpoint
116-
.path()
117-
.to_str()
118-
.expect("Invalid tempdir path")
110+
"/"
119111
};
120112

113+
// rootfs_mountpoint
114+
// .path()
115+
// .to_str()
116+
// .expect("Invalid tempdir path")
117+
//};
118+
121119
// We mount the linux API file systems into the target deployment before chrooting
122120
// so bootupd can find the proper backing device.
123121
// xref https://systemd.io/API_FILE_SYSTEMS/
@@ -132,6 +130,21 @@ pub(crate) fn install_via_bootupd(
132130
tracing::debug!("bind mounting {}", dest.display());
133131
rustix::mount::mount_bind_recursive(src, dest)?;
134132
}
133+
// WIP : let's try to bind-mount /target/boot into the deployment as well rather than bind-mounting the whole thing??
134+
if !rootfs.starts_with("/run") {
135+
tracing::debug!(
136+
"We need to access the target /boot filesystem so let's also bind-mount it"
137+
);
138+
let trgt_boot = rootfs.as_std_path().join("boot");
139+
let chrooted_boot = target_root.join_os("boot");
140+
tracing::debug!(
141+
"bind-mounting {} in {}",
142+
&trgt_boot.display(),
143+
&chrooted_boot.display()
144+
);
145+
rustix::mount::mount_bind_recursive(trgt_boot, chrooted_boot)?;
146+
}
147+
135148
// Append the `bootupctl` command, it will be passed as
136149
// an argument to chroot
137150
vec![target_root.as_str(), "bootupctl"]
@@ -164,6 +177,7 @@ pub(crate) fn install_via_bootupd(
164177

165178
// Clean up the mounts after ourselves
166179
if let Some(target_root) = abs_deployment_path {
180+
rustix::mount::unmount(target_root.join("boot"), UnmountFlags::DETACH);
167181
for dir in bind_mount_dirs {
168182
let mount = target_root
169183
.join(dir.strip_prefix("/").unwrap())

0 commit comments

Comments
 (0)