From 8e18a6238bc0c9632885c794088c0b56c07f392b Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 6 Nov 2026 09:04:18 -0700 Subject: [PATCH] remove_packages: remove a package's -debug package too An AUR package built with makepkg's debug option comes with pkg-debug, which nothing depends on, so pacman -Rns leaves it behind. voxtype-debug then conflicts with voxtype-bin-debug, and update fails on machines installed before voxtype-bin replaced voxtype. Found by 30-upgrade-from-baseline at 0c0ddf5. Co-Authored-By: Claude Opus 5.5 --- tests/utils.bats | 16 ++++++++++++++++ utils.sh | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/tests/utils.bats b/tests/utils.bats index e869523..a35783d 100644 --- a/tests/utils.bats +++ b/tests/utils.bats @@ -173,6 +173,22 @@ esac' called sudo pacman -Rns --noconfirm vim } +@test "remove_packages removes a package's -debug package too, even on its own" { + # voxtype-debug outlives voxtype, and conflicts with voxtype-bin-debug + stub pacman ' +[ "$1" = -Qq ] || exit 1 +case "$2" in + voxtype|voxtype-debug|herdr-debug) echo "$2" ;; + *) exit 1 ;; +esac' + stub sudo + source "$REPO/utils.sh" + + run remove_packages voxtype herdr vim + [ "$status" -eq 0 ] + called sudo pacman -Rns --noconfirm voxtype voxtype-debug herdr-debug +} + @test "remove_packages does nothing when nothing is installed" { stub pacman 'exit 1' stub sudo diff --git a/utils.sh b/utils.sh index 82ec9dc..618014a 100755 --- a/utils.sh +++ b/utils.sh @@ -106,10 +106,16 @@ remove_packages() { # Match the exact name: pacman -Q also finds a package that provides it, such # as herdr-bin for herdr, which pacman -R won't remove by that name + # An AUR package built with makepkg's debug option comes with pkg-debug, + # which nothing depends on, so -Rns leaves it behind, and its files conflict + # with the replacement's (voxtype-debug with voxtype-bin-debug) for pkg in "${packages[@]}"; do if [ "$(pacman -Qq "$pkg" 2> /dev/null)" = "$pkg" ]; then to_remove+=("$pkg") fi + if [ "$(pacman -Qq "$pkg-debug" 2> /dev/null)" = "$pkg-debug" ]; then + to_remove+=("$pkg-debug") + fi done if [ ${#to_remove[@]} -ne 0 ]; then