From 716fe83aa4928e975cee82c4d1bbb5167e51e301 Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 6 Nov 2026 11:50:15 -0700 Subject: [PATCH] update: remove -debug packages whose package is gone makepkg builds pkg-debug alongside an AUR package, and removing the package leaves it behind: the migration that dropped asdf-vm left asdf-vm-debug. Found by 30-upgrade-from-baseline at 0c0ddf5, whose machine kept it where a fresh install has none. Co-Authored-By: Claude Opus 5.5 --- tests/cleanup.bats | 33 +++++++++++++++++++++++++++++++++ updates.d/95-cleanup.sh | 11 +++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/cleanup.bats diff --git a/tests/cleanup.bats b/tests/cleanup.bats new file mode 100644 index 0000000..0918771 --- /dev/null +++ b/tests/cleanup.bats @@ -0,0 +1,33 @@ +#!/usr/bin/env bats + +load test_helper + +@test "95-cleanup removes -debug packages whose package is gone, and keeps the rest" { + # -Qqm lists the AUR packages; -Qq NAME prints what matches NAME, which for + # herdr is herdr-bin, as it provides herdr + stub pacman ' +case "$1" in + -Qqm) printf "%s\n" asdf-vm-debug cliamp cliamp-debug herdr-bin herdr-debug ;; + -Qq) case "$2" in cliamp) echo cliamp ;; herdr) echo herdr-bin ;; *) exit 1 ;; esac ;; +esac' + stub sudo + stub flatpak + + run bash "$REPO/updates.d/95-cleanup.sh" < /dev/null + [ "$status" -eq 0 ] + called sudo pacman -R --noconfirm asdf-vm-debug herdr-debug +} + +@test "95-cleanup leaves -debug packages alone while their packages are installed" { + stub pacman ' +case "$1" in + -Qqm) printf "%s\n" cliamp cliamp-debug ;; + -Qq) [ "$2" = cliamp ] && echo cliamp ;; +esac' + stub sudo + stub flatpak + + run bash "$REPO/updates.d/95-cleanup.sh" < /dev/null + [ "$status" -eq 0 ] + [ -z "$(grep 'pacman -R ' "$STUB_LOG")" ] +} diff --git a/updates.d/95-cleanup.sh b/updates.d/95-cleanup.sh index 281f4cf..518cda2 100755 --- a/updates.d/95-cleanup.sh +++ b/updates.d/95-cleanup.sh @@ -10,6 +10,17 @@ if command -v paccache &>/dev/null; then sudo paccache -ruk0 fi +# makepkg builds pkg-debug alongside an AUR package, and removing the package +# leaves it behind (asdf-vm-debug). Without its package it's no use to anyone, +# so remove it without asking. The exact name: pacman -Q herdr finds herdr-bin +mapfile -t STRAY_DEBUG < <(pacman -Qqm 2> /dev/null | grep -- '-debug$' | while read -r pkg; do + [ "$(pacman -Qq "${pkg%-debug}" 2> /dev/null)" = "${pkg%-debug}" ] || echo "$pkg" +done) +if (( ${#STRAY_DEBUG[@]} > 0 )); then + echo "Removing debug symbols for packages that are gone: ${STRAY_DEBUG[*]}" + sudo pacman -R --noconfirm "${STRAY_DEBUG[@]}" || exit 1 +fi + # Offer to remove packages that were installed as dependencies and are no # longer needed (packages something lists as an optional dependency are kept). # Ask first: one may be something you use directly. Without a terminal to ask