From 0594ecf5e497ba352b55e0341b7c9fb6939f3c10 Mon Sep 17 00:00:00 2001 From: Michal S Date: Sat, 20 Aug 2022 15:34:58 +0100 Subject: [PATCH] Fixed #3 --- src/internal/rpc.rs | 3 +++ src/main.rs | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/internal/rpc.rs b/src/internal/rpc.rs index f71d6fe..323f46d 100644 --- a/src/internal/rpc.rs +++ b/src/internal/rpc.rs @@ -14,6 +14,9 @@ pub struct Package { #[serde(rename = "MakeDepends")] #[serde(default)] pub make_depends: Vec, + #[serde(rename = "OptDepends")] + #[serde(default)] + pub opt_depends: Vec, } #[derive(serde::Deserialize)] diff --git a/src/main.rs b/src/main.rs index 3e80da8..6d447e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -82,11 +82,41 @@ fn cmd_install(args: InstallArgs, options: Options) { if !sorted.repo.is_empty() { // If repo packages found, install them - operations::install(sorted.repo, options); + operations::install(sorted.repo.clone(), options); } if !sorted.aur.is_empty() { // If AUR packages found, install them - operations::aur_install(sorted.aur, options); + operations::aur_install(sorted.aur.clone(), options); + } + + // Show optional dependencies for installed packages + info!("Showing optional dependencies for installed packages"); + for r in sorted.repo { + info!("{}:", r); + std::process::Command::new("expac") + .args(&["-S", "-l", "\n ", " %O", &r]) + .spawn() + .unwrap() + .wait() + .unwrap(); + } + for a in sorted.aur { + info!("{}:", a); + let dir_bytes = std::process::Command::new("mktemp").arg("-d").output().unwrap().stdout; + let dir = String::from_utf8(dir_bytes).unwrap(); + std::process::Command::new("bash") + .arg("-c") + .arg(format!("\ + cd {} + curl -L https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h={} -o PKGBUILD -s + source PKGBUILD + printf ' %s\\n' \"${{optdepends[@]}}\" + ", dir, a)) + .spawn() + .unwrap() + .wait() + .unwrap(); + std::fs::remove_dir_all(&std::path::Path::new(&dir.trim())).unwrap(); } }