Improve update and migration flow
This commit is contained in:
@@ -1,13 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Remove orphaned system packages after updates
|
||||
# omarchy:summary=Review and optionally remove orphaned system packages after updates
|
||||
# omarchy:requires-sudo=true
|
||||
|
||||
orphans=$(pacman -Qtdq || true)
|
||||
if [[ -n $orphans ]]; then
|
||||
echo -e "\e[32m\nRemove orphan system packages\e[0m"
|
||||
for pkg in $orphans; do
|
||||
sudo pacman -Rs --noconfirm "$pkg" || true
|
||||
done
|
||||
set -e
|
||||
|
||||
mapfile -t orphans < <(pacman -Qtdq 2>/dev/null || true)
|
||||
(( ${#orphans[@]} )) || exit 0
|
||||
|
||||
echo -e "\e[32m\nOrphan system packages\e[0m"
|
||||
printf ' %s\n' "${orphans[@]}"
|
||||
echo
|
||||
|
||||
if [[ ! -t 0 || ! -t 1 ]]; then
|
||||
echo "${#orphans[@]} orphaned package(s) found. Re-run omarchy-update-orphan-pkgs in a terminal to review/remove them."
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! gum confirm --default=false "Remove ${#orphans[@]} orphaned package(s)?"; then
|
||||
echo "Keeping orphaned packages."
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "\e[32m\nRemoving orphan system packages\e[0m"
|
||||
sudo pacman -Rns "${orphans[@]}"
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user