summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs42
1 files changed, 5 insertions, 37 deletions
diff --git a/src/main.rs b/src/main.rs
index 8d4787d..d3ac7c8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,4 @@
mod executor;
-mod prepared_command;
mod recipe;
mod resolve;
mod runner;
@@ -7,43 +6,13 @@ mod types;
mod unshare;
mod util;
-use nix::{
- mount::{self, MsFlags},
- unistd,
-};
-use std::{io::Result, path::Path};
+use std::path::Path;
use types::*;
-use util::ToIOResult;
-
-fn mount_buildtmp() -> Result<()> {
- mount::mount::<_, _, _, str>(
- Some("buildtmp"),
- "build/tmp",
- Some("tmpfs"),
- MsFlags::empty(),
- None,
- )
- .to_io_result()
-}
-
-fn exec_shell() -> Result<std::convert::Infallible> {
- let bin_sh = std::ffi::CString::new("/bin/sh").unwrap();
- unistd::execv(&bin_sh, &[&bin_sh]).to_io_result()
-}
-
-fn execute(mut exc: executor::Executor) -> Result<()> {
- unshare::unshare()?;
- mount_buildtmp()?;
-
- exc.run()?;
-
- exec_shell()?;
-
- Ok(())
-}
fn main() {
+ let runner = unsafe { runner::runc::RuncRunner::new() }.unwrap();
+
let recipes = recipe::read_recipes(Path::new("examples")).unwrap();
let mut tasks: TaskMap = TaskMap::default();
@@ -64,9 +33,8 @@ fn main() {
std::process::exit(1);
}
let taskset = rsv.to_taskset();
- let exc = executor::Executor::new(&tasks, taskset);
-
- if let Err(error) = execute(exc) {
+ let mut exc = executor::Executor::new(&tasks, taskset);
+ if let Err(error) = exc.run(&runner) {
eprintln!("{}", error);
std::process::exit(1);
}