diff --git a/Cargo.lock b/Cargo.lock index ea33526..d7dc6ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -624,6 +624,17 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.3.3", + "cfg-if", + "libc", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -803,6 +814,7 @@ dependencies = [ "camino", "clap", "hex", + "nix 0.27.1", "rugpi-common", "serde", "sha1", @@ -835,7 +847,7 @@ dependencies = [ "camino", "clap", "indoc", - "nix", + "nix 0.26.2", "rugpi-common", "serde", "tempdir", diff --git a/crates/rugpi-bakery/Cargo.toml b/crates/rugpi-bakery/Cargo.toml index 6d9952b..3c9263c 100644 --- a/crates/rugpi-bakery/Cargo.toml +++ b/crates/rugpi-bakery/Cargo.toml @@ -12,6 +12,7 @@ anyhow = "1.0.71" camino = { version = "1.1.4", features = ["serde"] } clap = { version = "4.3.8", features = ["derive"] } hex = "0.4.3" +nix = { version = "0.27.1", features = ["process"] } rugpi-common = { path = "../rugpi-common" } serde = { version = "1.0.171", features = ["derive", "rc"] } sha1 = "0.10.5" diff --git a/crates/rugpi-bakery/src/main.rs b/crates/rugpi-bakery/src/main.rs index a3ab1b6..c199558 100644 --- a/crates/rugpi-bakery/src/main.rs +++ b/crates/rugpi-bakery/src/main.rs @@ -1,4 +1,7 @@ -use std::path::PathBuf; +use std::{ + ffi::{CStr, CString}, + path::PathBuf, +}; use clap::Parser; use rugpi_common::Anyhow; @@ -31,6 +34,8 @@ pub enum Task { Customize(CustomizeTask), /// Bake a final image for distribution. Bake(BakeTask), + /// Spawn a shell in the Rugpi Bakery Docker container. + Shell, } fn main() -> Anyhow<()> { @@ -45,6 +50,10 @@ fn main() -> Anyhow<()> { Task::Bake(task) => { bake::run(&args, task)?; } + Task::Shell => { + let zsh_prog = CString::new("/bin/zsh")?; + nix::unistd::execv::<&CStr>(&zsh_prog, &[])?; + } } Ok(()) }