finalising some stuff
parent
52df05752b
commit
dba4ede596
@ -1,32 +1,38 @@
|
|||||||
use crate::{info, log, Options};
|
use crate::{crash, info, log, Options};
|
||||||
|
|
||||||
pub fn install(mut a: Vec<String>, options: Options) {
|
pub fn install(a: Vec<String>, options: Options) {
|
||||||
info(format!("Installing packages {} from repos", &a.join(", ")));
|
info(format!("Installing packages {} from repos", &a.join(", ")));
|
||||||
let b = a.clone();
|
let mut opers = vec![];
|
||||||
if options.noconfirm {
|
if options.noconfirm {
|
||||||
a.push("--noconfirm".to_string());
|
opers.push("--noconfirm".to_string());
|
||||||
}
|
}
|
||||||
if options.asdeps {
|
if options.asdeps {
|
||||||
a.push("--asdeps".to_string());
|
opers.push("--asdeps".to_string());
|
||||||
}
|
}
|
||||||
let verbosity = options.verbosity;
|
let verbosity = options.verbosity;
|
||||||
if verbosity >= 1 {
|
if verbosity >= 1 {
|
||||||
log(format!("Installing from repos: {:?}", &b));
|
log(format!("Installing from repos: {:?}", &a));
|
||||||
}
|
}
|
||||||
|
|
||||||
let r = runas::Command::new("pacman")
|
let r = runas::Command::new("pacman")
|
||||||
.arg("-S")
|
.arg("-S")
|
||||||
.arg("--needed")
|
.arg("--needed")
|
||||||
.args(&a)
|
.args(&a)
|
||||||
|
.args(&opers)
|
||||||
.status()
|
.status()
|
||||||
.expect("Something has gone wrong");
|
.expect("Something has gone wrong");
|
||||||
|
|
||||||
if let Some(x) = r.code() {
|
if r.code() != Some(0) {
|
||||||
if verbosity >= 1 {
|
crash(
|
||||||
log(format!(
|
format!(
|
||||||
"Installing packages: {:?} exited with code {}",
|
"An error occured while installing packages: {}, aborting",
|
||||||
&b, x
|
a.join(", ")
|
||||||
));
|
),
|
||||||
}
|
1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if verbosity >= 1 {
|
||||||
|
log(format!("Installing packages: {:?} was successful", &a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue