Files
boco/src/main.rs
T
hulthe 589afef4f5
CI / build (pull_request) Successful in 12s
Inject universal /slim/init instead of requiring container-specific setup
slim now works with any Containerfile by injecting distro-agnostic scripts
at build time:

- /slim/init: mounts special filesystems, configures networking (static
  QEMU slirp), sets up cgroup2, timezone, and rootless container prereqs.
  Parses slim.cmd=<base64> from the kernel cmdline for runtime overrides,
  otherwise execs /slim/exec.

- /slim/exec: generated from the image's CMD/ENTRYPOINT (via podman image
  inspect), overridable via --cmd at build and run time.

Changes:
- New src/inject.rs: inspect image config, infer command, generate
  /slim/exec script, inject /slim/ into mounted rootfs
- New src/scripts/slim-init.sh: the universal init script (include_str!)
- build.rs: rename --init to --cmd, inject scripts before packing,
  drop Meta::save, restructure to ensure unmount always runs
- qemu.rs: hardcode init=/slim/init, add --cmd (base64 on cmdline),
  drop Meta::load, add -no-reboot
- Remove src/meta.rs and meta.toml (no longer needed)
- Cargo.toml: add serde_json + base64, remove unused walkdir + cpio + toml
- Example Containerfiles simplified to plain FROM + CMD
- New example/test.sh for manual verification
- README updated for new workflow
2026-09-08 09:21:12 +02:00

47 lines
948 B
Rust

mod build;
mod command;
mod forward;
mod image;
mod inject;
mod qemu;
mod registry;
use anyhow::Result;
use clap::{Parser, Subcommand};
use crate::{build::BuildCmd, image::ImageCmd, qemu::RunCmd};
#[derive(Parser, Debug)]
#[command(about = "Turn containers into bootable VMs")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand, Debug)]
enum Commands {
/// Build initrd from an image (podman image must exist)
Build(BuildCmd),
/// Launch a previously built VM via QEMU.
Run(RunCmd),
/// List slim images in the registry
#[command(subcommand)]
Image(ImageCmd),
}
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Build(cmd) => {
build::build(cmd)?;
}
Commands::Run(cmd) => {
qemu::run(cmd)?;
}
Commands::Image(cmd) => {
image::run(cmd)?;
}
}
Ok(())
}