1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::process::Command;
use std::path::Path;
use super::{CliError, LalResult};
pub fn tar(tarball: &Path) -> LalResult<()> {
info!("Taring OUTPUT");
let mut args: Vec<String> = vec![
"czf".into(),
tarball.to_str().unwrap().into(),
"--transform=s,^OUTPUT/,,".into(),
];
let findargs = vec!["OUTPUT/", "-type", "f", "-o", "-type", "l"];
debug!("find {}", findargs.join(" "));
let find_output = Command::new("find").args(&findargs).output()?;
let find_str = String::from_utf8_lossy(&find_output.stdout);
for f in find_str.trim().split('\n') {
args.push(f.into())
}
debug!("tar {}", args.join(" "));
let s = Command::new("tar").args(&args).status()?;
if !s.success() {
return Err(CliError::SubprocessFailure(s.code().unwrap_or(1001)));
}
Ok(())
}