Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions composefs-run/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ impl std::str::FromStr for UserSpec {
#[derive(Debug, Parser)]
#[clap(name = "cfsrun")]
pub(crate) struct Cli {
/// Path to the composefs repository
#[clap(long, default_value = "/sysroot/composefs")]
repo: PathBuf,
/// Path to the composefs repository (default: /sysroot/composefs for root,
/// ~/.var/lib/composefs for rootless)
#[clap(long)]
repo: Option<PathBuf>,

/// Mount the rootfs read-only
#[clap(long)]
Expand Down Expand Up @@ -422,6 +423,12 @@ fn main() -> Result<()> {
let rootless = !rustix::process::geteuid().is_root();
let container_id = format!("composefs-{}", std::process::id());

let repo_path = match cli.repo.clone() {
Some(path) => path,
None if rootless => composefs::repository::user_path()?,
None => composefs::repository::system_path(),
};

let image = if let Some(ref rootfs) = cli.rootfs {
ensure!(
rootfs.is_dir(),
Expand All @@ -433,7 +440,7 @@ fn main() -> Result<()> {
erofs_hex: None,
}
} else {
let repo = ResolvedRepo::open(&cli.repo)?;
let repo = ResolvedRepo::open(&repo_path)?;
repo.resolve_image(cli.image.as_deref().context("No image specified")?)?
};

Expand All @@ -454,6 +461,7 @@ fn main() -> Result<()> {
&container_id,
&container_dir,
&overlay_dir,
&repo_path,
&image,
);

Expand Down
5 changes: 3 additions & 2 deletions composefs-run/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub fn run(
container_id: &str,
container_dir: &Path,
overlay_dir: &Path,
repo_path: &Path,
image: &ResolvedImage,
) -> Result<()> {
if rootless {
Expand Down Expand Up @@ -60,15 +61,15 @@ pub fn run(
mount_rootfs_from_path(rootfs, &rootfs_dir, overlay_dir, cli.read_only, rootless)?;
} else if rootless {
mount_rootfs_with_fuse(
&cli.repo,
repo_path,
image,
&rootfs_dir,
container_dir,
overlay_dir,
cli.read_only,
)?;
} else {
mount_rootfs_with_erofs(&cli.repo, image, &rootfs_dir, overlay_dir, cli.read_only)?;
mount_rootfs_with_erofs(repo_path, image, &rootfs_dir, overlay_dir, cli.read_only)?;
}

// ── Networking ──────────────────────────────────────────────────────
Expand Down
Loading