From af22f05c44ca80841e08c708f34a83b89847679f Mon Sep 17 00:00:00 2001 From: b1ek Date: Tue, 13 Feb 2024 21:00:17 +1000 Subject: [PATCH] (feat) filter out installed pacman packages --- brick.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/brick.sh b/brick.sh index 853a759..9378e34 100755 --- a/brick.sh +++ b/brick.sh @@ -99,6 +99,7 @@ while [[ $# -gt 0 ]]; do source $(getbrick $pkg) inf "$(inf "$pkg - $(info)")" done + inf 'done' exit 0 ;; -*) @@ -143,16 +144,30 @@ fi PACDEPS=() -# so now lets install! yay +# lets first collect the packages for pkg in "${PKGS[@]}"; do source $(getbrick $pkg) IFS=' ' read -ra DEPS <<< $(pkgs) PACDEPS=("${PACDEPS[@]}" "${DEPS[@]}") done +# so yeah lets do it if [ "${#PACDEPS[@]}" != "0" ]; then + + # first, gotta filter out the ones that are already installed + INSTALLED=$(pacman -Qe) + TO_INSTALL='' + for pkg in $PACDEPS; do + if [[ ! -z $(echo $INSTALLED | grep $pkg) ]]; then + TO_INSTALL="$TO_INSTALL $pkg" + fi + done + + inf "installing pacman packages:" + inf "$TO_INSTALL" + # welp lets install those - sudo pacman -S --needed --noconfirm $(printf "%s\n" "${PACDEPS[@]}" | sort -u) + sudo pacman -S --needed --noconfirm $TO_INSTALL inf "installed all pacman deps" else inf "no pacman deps to install"