diff --git a/remove-unconfigured-packages.sh b/remove-unconfigured-packages.sh index bbc0aef..78fe311 100755 --- a/remove-unconfigured-packages.sh +++ b/remove-unconfigured-packages.sh @@ -1,20 +1,25 @@ #!/usr/bin/env bash +set -o nounset +set -o errexit + +cpu="$(yaml2json < _machines/"$(hostname --short)".yml | jq --raw-output .cpu)" +gpu="$(yaml2json < _machines/"$(hostname --short)".yml | jq --raw-output .gpu)" + +if [[ "${cpu}" ]] ; then + readarray -d $'\0' -t cpu_packages < <(]*}" "${makedepends[@]%%[<=>]*}" "${pkgname}") done -packages_to_remove=() +declare -a packages_to_remove=() readarray -d $'\0' -t packages_to_remove < <(comm --zero-terminated -13 \ <(cat \ <( 0 )) ; then +if (( "${#packages_to_remove[@]}" > 0 )) ; then sudo pacman -Rcns "${packages_to_remove[@]}" "${@}" || exit $? exit 123 fi