diff --git a/src/internal/detect.rs b/src/internal/detect.rs new file mode 100644 index 0000000..28166c2 --- /dev/null +++ b/src/internal/detect.rs @@ -0,0 +1,9 @@ +use crate::internal::strings::info; + +pub fn detect(a: String) { + if a.contains(".pacnew") || a.contains(".new") { + info("It appears that a program you have installed / upgraded has installed a .new/.pacnew config file. Please read over the pacman output and act on it accordingly".to_string()); + } else if a.contains(".old") { + info("It appears that a program you have installed / upgraded has installed a .old config file. Please read over the pacman output and act on it accordingly".to_string()); + } +} diff --git a/src/main.rs b/src/main.rs index d3f9d7e..0953eef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use std::process::{exit, Command}; -use std::{env, io}; +use std::{env, io, process}; use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand}; @@ -174,6 +174,17 @@ fn main() { sorted.nf.join(", ") )); } + + let out = process::Command::new("bash") + .args(&["-c", "sudo find /etc -name *.pacnew"]) + .output() + .expect("Something has gone wrong") + .stdout; + + if !String::from_utf8((*out).to_owned()).unwrap().is_empty() { + info(format!("You have .pacnew files in /etc ({}) that you haven't removed or acted upon, it is recommended you do that now", String::from_utf8((*out).to_owned()).unwrap().split_whitespace().collect::>().join(", "))); + } + exit(0); } diff --git a/src/operations/aur_install.rs b/src/operations/aur_install.rs index 2f9f304..13f0312 100644 --- a/src/operations/aur_install.rs +++ b/src/operations/aur_install.rs @@ -128,7 +128,7 @@ pub fn aur_install(a: Vec, options: Options) { crate::operations::aur_install(md_sorted.aur, newopts); } - let mut makepkg_args = vec!["-rsic", "--needed", "--skippgp"]; + let mut makepkg_args = vec!["-rsic", "--skippgp"]; if options.asdeps { makepkg_args.push("--asdeps") } diff --git a/src/operations/install.rs b/src/operations/install.rs index 95f1ddf..cb0aa38 100644 --- a/src/operations/install.rs +++ b/src/operations/install.rs @@ -10,29 +10,31 @@ pub fn install(a: Vec, options: Options) { opers.push("--asdeps".to_string()); } let verbosity = options.verbosity; - if verbosity >= 1 { - log(format!("Installing from repos: {:?}", &a)); - } + if !a.is_empty() { + if verbosity >= 1 { + log(format!("Installing from repos: {:?}", &a)); + } - let r = runas::Command::new("pacman") - .arg("-S") - .arg("--needed") - .args(&a) - .args(&opers) - .status() - .expect("Something has gone wrong"); + let r = runas::Command::new("pacman") + .arg("-S") + .arg("--needed") + .args(&a) + .args(&opers) + .status() + .expect("Something has gone wrong"); - if r.code() != Some(0) { - crash( - format!( - "An error occured while installing packages: {}, aborting", - a.join(", ") - ), - 7, - ); - } + if r.code() != Some(0) { + crash( + format!( + "An error occured while installing packages: {}, aborting", + a.join(", ") + ), + 7, + ); + } - if verbosity >= 1 { - log(format!("Installing packages: {:?} was successful", &a)); + if verbosity >= 1 { + log(format!("Installing packages: {:?} was successful", &a)); + } } }