Rebrand to boco
CI / build (push) Successful in 13s

This commit is contained in:
hulthe committed 2026-09-11 17:56:38 +02:00
1 parent 8782baa705
commit a24e1efe31
12 files changed
+142 -142

No files matched your search

+3 -3
View File
@@ -1,4 +1,4 @@
//! Build: mount a podman image, inject /slim/ scripts, and pack the rootfs
//! Build: mount a podman image, inject /boco/ scripts, and pack the rootfs
//! as a gzipped cpio initrd or qcow2 disk in the registry.
use anyhow::{Context, Result, bail};
@@ -41,7 +41,7 @@ pub(crate) fn build(
}: BuildCmd,
) -> Result<()> {
let image = &name;
let container = format!("slim-build-{}", image.replace(':', "-"));
let container = format!("boco-build-{}", image.replace(':', "-"));
let mount_path = mount_container(image, &container)?;
println!("Mounted at: {}", mount_path.display());
@@ -86,7 +86,7 @@ fn build_inner(
config.user.as_deref(),
config.working_dir.as_deref(),
)?;
println!("Injected /slim/ (init + exec)");
println!("Injected /boco/ (init + exec)");
match kind {
ImageKind::Initrd => build_initrd(image, mount_path),
+6 -6
View File
@@ -1,5 +1,5 @@
//! Inject: inspect a podman image's config, infer the default command argv,
//! and inject the slim init binary + null-delimited argv/env files into the
//! and inject the boco init binary + null-delimited argv/env files into the
//! mounted rootfs.
use anyhow::{Context, Result, anyhow};
@@ -68,21 +68,21 @@ pub fn null_delimited(items: &[String]) -> Vec<u8> {
data
}
/// Install `content` into the mounted rootfs at `<mount>/slim/<name>` with
/// Install `content` into the mounted rootfs at `<mount>/boco/<name>` with
/// the given mode.
fn install_into_rootfs(mount: &str, name: &str, mode: &str, content: &[u8]) -> Result<()> {
let temp = tempfile::NamedTempFile::new()?;
fs::write(temp.path(), content)?;
let src = temp.path().to_str().context("temp path is not UTF-8")?;
let dest = format!("{mount}/slim/{name}");
let dest = format!("{mount}/boco/{name}");
cmd(&[
"podman", "unshare", "--", "install", "-D", "-m", mode, src, &dest,
])?;
Ok(())
}
/// Inject /slim/init (binary), /slim/exec (null-delimited argv), /slim/env
/// (null-delimited env), and optionally /slim/user and /slim/workdir into a
/// Inject /boco/init (binary), /boco/exec (null-delimited argv), /boco/env
/// (null-delimited env), and optionally /boco/user and /boco/workdir into a
/// mounted container image rootfs.
pub fn inject(
mount_path: &Path,
@@ -93,7 +93,7 @@ pub fn inject(
) -> Result<()> {
let mount_str = mount_path.to_str().context("mount path is not UTF-8")?;
let init_binary = fs::read(init_binary_path()?).context("Failed to read slim-init binary")?;
let init_binary = fs::read(init_binary_path()?).context("Failed to read boco-init binary")?;
let exec_data = null_delimited(argv);
let env_data = null_delimited(env);
+5 -5
View File
@@ -9,7 +9,7 @@ mod registry;
use anyhow::Result;
use clap::{Parser, Subcommand};
use crate::{build::BuildCmd, image::ImageCmd, qemu::RunCmd};
use crate::{build::BuildCmd, image::ImageCmd, qemu::BootCmd};
#[derive(Parser, Debug)]
#[command(about = "Turn containers into bootable VMs")]
@@ -23,8 +23,8 @@ 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
Boot(BootCmd),
/// List boco images in the registry
#[command(subcommand)]
Image(ImageCmd),
}
@@ -35,8 +35,8 @@ fn main() -> Result<()> {
Commands::Build(cmd) => {
build::build(cmd)?;
}
Commands::Run(cmd) => {
qemu::run(cmd)?;
Commands::Boot(cmd) => {
qemu::boot(cmd)?;
}
Commands::Image(cmd) => {
image::run(cmd)?;
+15 -15
View File
@@ -1,8 +1,8 @@
//! QEMU: boot a registry entry with qemu-system-x86_64 using direct kernel
//! boot (-kernel/-initrd or -drive). The kernel is shared across all VMs
//! at $XDG_DATA_HOME/slim-rs/registry/vmlinuz. A universal /slim/init script (injected
//! at build time) handles VM bootstrap; /slim/exec runs the container's
//! CMD/ENTRYPOINT. Runtime overrides are delivered as `slim.cmd=<base64>`
//! at $XDG_DATA_HOME/boco/registry/vmlinuz. A universal /boco/init script (injected
//! at build time) handles VM bootstrap; /boco/exec runs the container's
//! CMD/ENTRYPOINT. Runtime overrides are delivered as `boco.cmd=<base64>`
//! on the kernel cmdline.
use anyhow::{Context, Result, bail};
@@ -16,7 +16,7 @@ use crate::{
};
#[derive(Args, Debug)]
pub struct RunCmd {
pub struct BootCmd {
/// Image tag / registry subdir name
name: String,
@@ -29,7 +29,7 @@ pub struct RunCmd {
forward: Vec<PortForward>,
/// Override the command to exec in the VM (base64-encoded on the kernel
/// cmdline as slim.cmd=<b64>). Overrides the CMD inferred at build time.
/// cmdline as boco.cmd=<b64>). Overrides the CMD inferred at build time.
#[clap(long)]
cmd: Option<String>,
@@ -41,14 +41,14 @@ pub struct RunCmd {
mount: Vec<String>,
}
pub(crate) fn run(
RunCmd {
pub(crate) fn boot(
BootCmd {
name,
memory,
forward,
cmd,
mount,
}: RunCmd,
}: BootCmd,
) -> Result<()> {
let reg_dir = registry_dir(&name)?;
let vmlinuz_path = registry_base_dir()?.join("vmlinuz");
@@ -67,7 +67,7 @@ pub(crate) fn run(
"rw".into(),
"earlyprintk=serial".into(),
"nokaslr".into(),
"init=/slim/init".into(),
"init=/boco/init".into(),
"devtmpfs.mount=1".into(), // Automatically mount /dev at boot
];
@@ -81,19 +81,19 @@ pub(crate) fn run(
fs_args = vec!["-initrd".to_string(), initrd_str];
cmdline.push("root=/dev/ram0".into());
} else {
bail!("Registry missing rootfs/initrd for '{name}'. Run `slim build` first.");
bail!("Registry missing rootfs/initrd for '{name}'. Run `boco build` first.");
}
if let Some(cmd) = &cmd {
let argv = ["/bin/sh".to_string(), "-c".to_string(), cmd.clone()];
let data: Vec<u8> = argv.join("\0").into_bytes();
let encoded = base64::engine::general_purpose::STANDARD.encode(&data);
cmdline.push(format!("slim.cmd={encoded}"));
cmdline.push(format!("boco.cmd={encoded}"));
}
// Build 9p shares for each --mount. Tags are short (slim0, slim1, …)
// Build 9p shares for each --mount. Tags are short (boco0, boco1, …)
// because 9p mount_tag has a ~31-byte limit. The guest destination path
// is passed on the kernel cmdline as slim.mount=<tag>:<base64(guest_path)>.
// is passed on the kernel cmdline as boco.mount=<tag>:<base64(guest_path)>.
// If no guest path is specified, the host path is used as the guest path.
let mut virtfs_args: Vec<String> = Vec::new();
for (i, spec) in mount.iter().enumerate() {
@@ -107,7 +107,7 @@ pub(crate) fn run(
let host_str = canonical
.to_str()
.context("Mount path is not valid UTF-8")?;
let tag = format!("slim{i}");
let tag = format!("boco{i}");
let dest_b64 = base64::engine::general_purpose::STANDARD.encode(guest_path.as_bytes());
// QEMU's QemuOpts splits on commas — escape literal commas in the
@@ -117,7 +117,7 @@ pub(crate) fn run(
virtfs_args.push(format!(
"local,path={host_escaped},mount_tag={tag},security_model=mapped-xattr"
));
cmdline.push(format!("slim.mount={tag}:{dest_b64}"));
cmdline.push(format!("boco.mount={tag}:{dest_b64}"));
}
println!("Booting {name} from registry: {}", reg_dir.display());
+7 -7
View File
@@ -1,12 +1,12 @@
//! Registry: local storage of built VM artifacts under
//! `$XDG_DATA_HOME/slim-rs/registry/<image>/`.
//! `$XDG_DATA_HOME/boco/registry/<image>/`.
use anyhow::{Context, Result, anyhow, bail};
use std::{fs, io, path::PathBuf};
/// Validate a user-supplied image name before it is used in a registry path.
///
/// The name becomes a directory under `$XDG_DATA_HOME/slim-rs/registry/`, so
/// The name becomes a directory under `$XDG_DATA_HOME/boco/registry/`, so
/// path separators and `.`/`..` would allow escaping that directory.
/// Allow-list: ASCII alphanumerics plus `.`, `_`, `:`, `-` (covers image
/// refs like `alpine:3.15`).
@@ -27,15 +27,15 @@ pub(crate) fn validate_image_name(name: &str) -> Result<()> {
}
pub(crate) fn registry_base_dir() -> Result<PathBuf> {
let base = xdg::BaseDirectories::with_prefix("slim-rs");
let base = xdg::BaseDirectories::with_prefix("boco");
base.create_data_directory("registry")
.context("Failed to create XDG_DATA_HOME subdirectory")
}
pub(crate) fn init_binary_path() -> Result<PathBuf> {
let base = xdg::BaseDirectories::with_prefix("slim-rs");
base.get_data_file("slim-init")
.context("slim-init not found in XDG data dir")
let base = xdg::BaseDirectories::with_prefix("boco");
base.get_data_file("boco-init")
.context("boco-init not found in XDG data dir")
}
pub(crate) fn registry_dir(image: &str) -> Result<PathBuf> {
@@ -62,7 +62,7 @@ mod tests {
fn accepts_valid_image_names() {
for name in [
"alpine:3.15",
"slim",
"boco",
"mock-vm",
"my_vm",
"a.b.c",