feat: run use temp sub file

This commit is contained in:
2020-11-14 21:31:13 +08:00
parent 723819e2e2
commit 1b28ec7f8e
3 changed files with 90 additions and 7 deletions

View File

@@ -4,13 +4,34 @@ extern crate rust_util;
mod build_util;
mod docker_util;
use std::fs;
use std::env;
use std::path::Path;
use rust_util::util_file;
pub use docker_util::DockerCmd;
const DOCKER_REGISTRY: &str = "~/.dockerbuild/register/rust_1_47";
const MIRROR_USTC: &str = "git://mirrors.ustc.edu.cn/crates.io-index";
fn main() {
information!("dockerbuild v0.1");
let docker_registry_path_buf = util_file::get_absolute_path(DOCKER_REGISTRY).expect("Cannot find $HOME !");
let docker_registry = docker_registry_path_buf.to_str().expect("Cannot find $HOME !!");
let p = Path::new(&docker_registry);
if !p.exists() {
if let Err(e) = fs::create_dir_all(&docker_registry) {
failure!("Create dir failed: {:?}, error: {}", p, e);
return;
}
}
let args_iter = env::args().skip(1);
let args = args_iter.map(|a| a.to_owned()).collect::<Vec<_>>();
DockerCmd::new("rust:1.47").exec(&args).unwrap();
let mut docker_cmd = DockerCmd::new("rust:1.47");
docker_cmd.add_volumn(docker_registry, "/usr/local/cargo/registry")
.mirror(MIRROR_USTC);
docker_cmd.exec(&args).unwrap();
}