Make package removal match exact installed names only
pacman -Q resolves provider names, so dropping a virtual package could remove whichever package provides it. Read pacman -Qq once and match requested names exactly, ignoring providers and duplicate arguments. Ports the provider-ignoring semantics of 9791b227 from master with a single pacman query instead of one per package. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
f7152cac17
commit
a4c13bdefb
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
test_tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$test_tmp"' EXIT
|
||||
|
||||
mock_path="$test_tmp/pkg-drop-bin"
|
||||
mkdir -p "$mock_path"
|
||||
|
||||
cat >"$mock_path/pacman" <<'EOF'
|
||||
#!/bin/bash
|
||||
if [[ $1 == "-Qq" ]]; then
|
||||
printf '%s\n' exact-package provider-package
|
||||
fi
|
||||
EOF
|
||||
|
||||
cat >"$mock_path/sudo" <<'EOF'
|
||||
#!/bin/bash
|
||||
printf '%s\n' "$*" >"$TEST_TMP/pkg-drop-command"
|
||||
EOF
|
||||
|
||||
chmod +x "$mock_path/pacman" "$mock_path/sudo"
|
||||
|
||||
PATH="$mock_path:$PATH" TEST_TMP="$test_tmp" \
|
||||
"$ROOT/bin/omarchy-pkg-drop" exact-package virtual-package provider-package exact-package
|
||||
|
||||
[[ $(<"$test_tmp/pkg-drop-command") == "pacman -Rns --noconfirm exact-package provider-package" ]] ||
|
||||
fail "package removal targets exact installed names only"
|
||||
pass "package removal ignores providers and duplicate arguments"
|
||||
Reference in New Issue
Block a user