From 2982fa162ec55bf1911e016b19ab5ebdeb58f348 Mon Sep 17 00:00:00 2001 From: Michal S Date: Mon, 22 Aug 2022 14:34:29 +0100 Subject: [PATCH] Ensured noconfirm is passed through to finish() --- src/operations/aur_install.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/operations/aur_install.rs b/src/operations/aur_install.rs index 8e2b0d8..1b1936a 100644 --- a/src/operations/aur_install.rs +++ b/src/operations/aur_install.rs @@ -109,36 +109,46 @@ fn review(cachedir: &str, pkg: &str, orig_cachedir: &str) { }; } -fn finish(cachedir: &str, pkg: &str) { +fn finish(cachedir: &str, pkg: &str, options: &Options) { // Install all packages from cachedir except `pkg` using --asdeps let dirs = list(cachedir); // Get a list of packages in cachedir if dirs.len() > 1 { info!("Installing all AUR dependencies"); - std::process::Command::new("bash") + let cmd = std::process::Command::new("bash") .args(&[ "-cO", "extglob", - format!("sudo pacman -U --asdeps {}/!({})/*.zst", cachedir, pkg).as_str(), + format!("sudo pacman -U --asdeps {}/!({})/*.zst {}", cachedir, pkg, if options.noconfirm { "--noconfirm" } else { "" }).as_str(), ]) .spawn() .unwrap() .wait() .unwrap(); + if cmd.success() { + info!("All AUR dependencies installed"); + } else { + crash!(AppExitCode::PacmanError, "AUR dependencies failed to install"); + } } // Install package explicitly info!("Installing {}", pkg); - std::process::Command::new("bash") + let cmd = std::process::Command::new("bash") .args(&[ "-c", - format!("sudo pacman -U {}/{}/*.zst", cachedir, pkg).as_str(), + format!("sudo pacman -U {}/{}/*.zst {}", cachedir, pkg, if options.noconfirm { "--noconfirm" } else { "" }).as_str(), ]) .spawn() .unwrap() .wait() .unwrap(); + if cmd.success() { + info!("{} installed!", pkg); + } else { + crash!(AppExitCode::PacmanError, "{} failed to install", pkg); + } } pub fn aur_install(a: Vec, options: Options, orig_cachedir: &str) { @@ -300,7 +310,7 @@ pub fn aur_install(a: Vec, options: Options, orig_cachedir: &str) { set_current_dir(&cachedir).unwrap(); if !options.asdeps { - finish(&cachedir, pkg); + finish(&cachedir, pkg, &options); } }