Skip to content

Commit 94d896a

Browse files
committed
xtask: Map /home -> /var/home in local-rust-deps
bootc images have /home as a symlink to /var/home, but /var/home may not exist in the base container image. When local-rust-deps outputs bind mount arguments for paths under /home/..., crun fails to create the mount destination because it can't create /var/home. Fix by mapping /home/... paths to /var/home/... for the container destination. Cargo inside the container can still access the files via /home/... since the symlink works once /var/home exists. Assisted-by: OpenCode (Claude Sonnet 4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent f0ef9c5 commit 94d896a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

crates/xtask/src/xtask.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! by the user - add commands here which otherwise might
55
//! end up as a lot of nontrivial bash code.
66
7+
use std::borrow::Cow;
78
use std::fs::File;
89
use std::io::{BufRead, BufReader, BufWriter, Write};
910
use std::process::Command;
@@ -476,9 +477,19 @@ fn local_rust_deps(_sh: &Shell, args: &LocalRustDepsArgs) -> Result<()> {
476477
// Output podman -v arguments
477478
let mut args_out = Vec::new();
478479
for root in &external_roots {
480+
// Map /home/... -> /var/home/... for the container destination.
481+
// bootc images have /home as a symlink to /var/home, but /var/home
482+
// may not exist in the base image. Mounting to /var/home/... creates
483+
// the directory, and cargo can then access it via /home/... symlink.
484+
let dest: Cow<'_, str> = if let Some(suffix) = root.as_str().strip_prefix("/home/")
485+
{
486+
format!("/var/home/{suffix}").into()
487+
} else {
488+
root.as_str().into()
489+
};
479490
// Mount read-only with SELinux disabled (for cross-context access)
480491
args_out.push("-v".to_string());
481-
args_out.push(format!("{}:{}:ro", root, root));
492+
args_out.push(format!("{}:{}:ro", root, dest));
482493
args_out.push("--security-opt=label=disable".to_string());
483494
}
484495
if !args_out.is_empty() {

0 commit comments

Comments
 (0)