From 0adb685741869a324d63648c96e3ca39a033b0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Wed, 22 Oct 2025 17:03:10 +0200 Subject: [PATCH] Remove orphaned packages --- remove-unconfigured-packages.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/remove-unconfigured-packages.sh b/remove-unconfigured-packages.sh index 3f015da..cb35b18 100755 --- a/remove-unconfigured-packages.sh +++ b/remove-unconfigured-packages.sh @@ -62,12 +62,29 @@ readarray -d $'\0' -t packages_to_remove < <(comm --zero-terminated -13 \ printf '%s\0' "${package}" done) +packages_removed=0 + if (( "${#packages_to_remove[@]}" > 0 )) ; then echo "found the following explicitly installed packages that are not configured:" for pkg in "${packages_to_remove[@]}" ; do echo "${pkg}" done sudo pacman -Rcns "${packages_to_remove[@]}" "${@}" || exit $? + packages_removed=1 +fi + +readarray -t orphans < <(pacman -Qdtq) + +if (( "${#orphans[@]}" > 0 )) ; then + echo "found the following orphaned packages:" + for pkg in "${orphans[@]}" ; do + echo "${pkg}" + done + sudo pacman -Rcns "${orphans[@]}" "${@}" || exit $? + packages_removed=1 +fi + +if (( packages_removed)) ; then exit 123 fi