diff --git a/pkgtxt b/pkgtxt index cf89680..b2c00df 100755 --- a/pkgtxt +++ b/pkgtxt @@ -56,11 +56,17 @@ update() { esac done - # installing all missing packages - pacman -S --noconfirm $(cat $to_install) 2>/dev/null + # remove all packages to remove + while IFS='' read -r LINE || [ -n "${LINE}" ]; do + if pacman -Qii "$LINE" | grep "^Required By.*None$"; then + pacman -Rs --noconfirm "$LINE" + else + pacman -D --asdeps "$LINE" + fi + done < $to_remove - # removing all packages to remove - pacman -Rs --noconfirm $(cat $to_remove) 2>/dev/null + # install all missing packages + pacman -S --noconfirm $(cat $to_install) 2>/dev/null remove_tmps