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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use std::io::{Error, ErrorKind};
use run_script::ScriptOptions;
use uuid::Uuid;
pub fn extract(archive_path: &str) -> Result<String, Error> {
let output = format!("/tmp/libdeb/{}/", Uuid::new_v4());
if cfg!(target_os = "windows") {
return Err(Error::new(
ErrorKind::Other,
"The target_os windows is not supported. Please only use on linux",
));
} else {
let data_archive = format!("{}data.tar.xz", &output);
let data_extract = format!("{}data/", &output);
let control_archive = format!("{}control.tar.xz", &output);
let control_extract = format!("{}control/", &output);
let _ = run_script::run(
&format!(
"
mkdir -p {};
mkdir -p {};
mkdir -p {};
ar -x {} --output={};
tar -xf {} -C {};
tar -xf {} -C {};
",
output,
data_extract,
control_extract,
archive_path,
output,
data_archive,
data_extract,
control_archive,
control_extract
),
&vec![],
&ScriptOptions::new(),
);
}
Ok(output)
}