use std::error::Error;
use std::path::PathBuf;
use std::process::{Command, Stdio};
pub fn create(path: PathBuf) -> Result<(), Box<dyn Error>> {
Ok(())
}
pub fn update(path: PathBuf) -> Result<(), Box<dyn Error>> {
println!("[Updating chroot]");
let mut path = path.to_str().unwrap().to_string();
if path.contains('~') {
path = shellexpand::tilde(&path).into_owned();
}
let _mkchrtpkg = Command::new("sudo")
.arg("arch-nspawn")
.arg(format!("{}/root", path))
.arg("pacman")
.arg("-Syu")
.arg("--noprogressbar")
.arg("--noconfirm")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()
.expect("failed to execute process");
Ok(())
}