From b284841f77c8df5b1b2c3aa43f6dc1b3b4a7e201 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 26 Oct 2026 14:08:47 -0600 Subject: [PATCH] various fixes --- README.md | 2 +- updates.d/95-cleanup.sh | 16 +++++++++------- utils.sh | 9 ++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e62925a..90cace4 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ The script pulls the latest CoreDesktop, then runs each step in ~/.local/share/c - updates the Arch keyring, then Arch and GNOME, then AUR packages, Flatpaks, Ruby, GNOME extensions and firmware - warns you not to reboot if the initramfs failed to rebuild - runs any one-time migrations, the way existing machines pick up new CoreDesktop setup -- lists packages that are no longer needed, and the command to remove them +- removes packages that were installed only because something else needed them, and are no longer needed by anything. It lists what it removed. To stop a package you use directly from being removed, run `sudo pacman -D --asexplicit ` If a step fails, the other steps still run, and the failed ones are listed at the end. diff --git a/updates.d/95-cleanup.sh b/updates.d/95-cleanup.sh index 3fc2999..b809608 100755 --- a/updates.d/95-cleanup.sh +++ b/updates.d/95-cleanup.sh @@ -10,11 +10,13 @@ if command -v paccache &>/dev/null; then sudo paccache -ruk0 fi -# Report packages that were installed as dependencies and are no longer needed. -# Not removed automatically: some may be tools you use directly. -ORPHANS="$(pacman -Qtdq 2>/dev/null)" -if [ -n "$ORPHANS" ]; then - echo "Packages no longer needed by anything:" - echo "$ORPHANS" | sed 's/^/ /' - echo "To remove them: sudo pacman -Rns \$(pacman -Qtdq)" +# Remove packages that were installed as dependencies and are no longer needed +# (packages something lists as an optional dependency are kept). To keep one +# you use directly: sudo pacman -D --asexplicit +mapfile -t ORPHANS < <(pacman -Qtdq 2>/dev/null) +if (( ${#ORPHANS[@]} > 0 )); then + echo "Removing packages no longer needed by anything:" + printf ' %s\n' "${ORPHANS[@]}" + sudo pacman -Rns --noconfirm "${ORPHANS[@]}" || exit 1 + echo "To get one of these back, reinstall it with: sudo pacman -S " fi diff --git a/utils.sh b/utils.sh index fdc85fc..cbcb5a4 100755 --- a/utils.sh +++ b/utils.sh @@ -118,7 +118,14 @@ PACMAN_UPDATE_LOG="$HOME/.local/state/coredesktop/pacman-update.log" initramfs_build_failed() { [ -f "$PACMAN_UPDATE_LOG" ] || return 1 grep -q "Updating linux initcpios" "$PACMAN_UPDATE_LOG" || return 1 - grep -q "==> ERROR" "$PACMAN_UPDATE_LOG" || ! grep -q "Image generation successful" "$PACMAN_UPDATE_LOG" + grep -q "==> ERROR" "$PACMAN_UPDATE_LOG" && return 0 + + # Every image built must report success. Older mkinitcpio says "==> Image + # generation successful", newer says "==> Initcpio image generation successful". + local built succeeded + built="$(grep -c "==> Building image from preset" "$PACMAN_UPDATE_LOG")" + succeeded="$(grep -cE "==> (Initcpio i|I)mage generation successful" "$PACMAN_UPDATE_LOG")" + (( succeeded == 0 || succeeded < built )) } # Install a script atomically (copy to a temp file, then rename over the target)