Dire Wolf, Graywolf and others key a radio through a CM108-family sound card (a Digirig, an AIOC) by setting a GPIO pin through its hidraw device, which only root can open otherwise. Dire Wolf's own rule gives it to the audio group, which most Arch users aren't in, and shouldn't need to be. udev/70-hampack-cm108.rules tags those devices uaccess instead, so whoever is at the desktop can use them, as they can the sound card. It matches the devices Dire Wolf 1.8 treats as CM108-compatible, and no other C-Media devices. update.sh installs it in /etc/udev/rules.d when it changes, and reloads and re-applies udev's rules; hampackremove removes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
159 lines
5.1 KiB
Bash
159 lines
5.1 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
setup() {
|
|
setup_fake_home
|
|
fake_coredesktop
|
|
stub uv 'exit 0'
|
|
stub clear 'exit 0'
|
|
# hampackremove finds HamPack by the sibling clone's origin, and deletes it
|
|
SIBLING="$HOME/.local/share/siblings/HamPack"
|
|
mkdir -p "$SIBLING"
|
|
cp "$REPO"/{lib.sh,packages.conf,binaries.conf,compile.conf,hampackremove} "$SIBLING"/
|
|
git init -q "$SIBLING"
|
|
git -C "$SIBLING" remote add origin https://gitea.example/david/HamPack.git
|
|
}
|
|
|
|
remove() {
|
|
run bash "$REPO/hampackremove" <<< "${1:-y}"
|
|
}
|
|
|
|
@test "removes only the packages HamPack recorded, and keeps ones others need" {
|
|
mark_installed hamlib fldigi wine cmake
|
|
mkdir -p "$HAMPACK_STATE"
|
|
printf 'fldigi\nhamlib\n' > "$HAMPACK_STATE/installed-packages"
|
|
echo hamlib > "$FAKE_PACMAN_DB/.required" # something else needs hamlib
|
|
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
[ ! -e "$FAKE_PACMAN_DB/fldigi" ]
|
|
[ -e "$FAKE_PACMAN_DB/hamlib" ]
|
|
[ -e "$FAKE_PACMAN_DB/wine" ]
|
|
[ -e "$FAKE_PACMAN_DB/cmake" ]
|
|
[[ "$output" == *"Kept because other software needs them: hamlib"* ]]
|
|
[[ "$output" == *"sudo pacman -Rns"*"wine"* ]]
|
|
}
|
|
|
|
@test "removes recorded Flatpaks only" {
|
|
touch "$FAKE_FLATPAKS/io.github.foldynl.QLog" "$FAKE_FLATPAKS/io.sourceforge.wsjt.wsjtx"
|
|
mkdir -p "$HAMPACK_STATE"
|
|
echo io.github.foldynl.QLog > "$HAMPACK_STATE/installed-flatpaks"
|
|
remove
|
|
[ ! -e "$FAKE_FLATPAKS/io.github.foldynl.QLog" ]
|
|
[ -e "$FAKE_FLATPAKS/io.sourceforge.wsjt.wsjtx" ]
|
|
}
|
|
|
|
@test "removes files from manifests, conf install paths and older builds" {
|
|
mkdir -p "$HAMPACK_STATE/manifests" "$HOME/.local/share/applications" "$HOME/.local/share/doc/direwolf"
|
|
touch "$HOME/.local/bin/staged-file" "$HOME/.local/bin/paracon.pyz" "$HOME/.local/bin/QtTermTCP" \
|
|
"$HOME/.local/bin/decode_aprs" "$HOME/.local/share/applications/qttermtcp.desktop"
|
|
printf '%s\n/etc/udev/rules.d/99-x.rules\n' "$HOME/.local/bin/staged-file" > "$HAMPACK_STATE/manifests/x"
|
|
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
[ ! -e "$HOME/.local/bin/staged-file" ]
|
|
grep -qx "sudo rm -f /etc/udev/rules.d/99-x.rules" "$STUB_LOG"
|
|
[ ! -e "$HOME/.local/bin/paracon.pyz" ]
|
|
[ ! -e "$HOME/.local/bin/QtTermTCP" ]
|
|
[ ! -e "$HOME/.local/share/applications/qttermtcp.desktop" ]
|
|
[ ! -e "$HOME/.local/bin/decode_aprs" ]
|
|
[ ! -e "$HOME/.local/share/doc/direwolf" ]
|
|
}
|
|
|
|
@test "removes Wine apps but keeps a Wine prefix HamPack didn't create" {
|
|
mkdir -p "$HOME/.wine/drive_c/VARA" "$HOME/.wine/drive_c/Other"
|
|
remove
|
|
[ ! -e "$HOME/.wine/drive_c/VARA" ]
|
|
[ -d "$HOME/.wine/drive_c/Other" ]
|
|
}
|
|
|
|
@test "offers to remove a Wine prefix HamPack created" {
|
|
mkdir -p "$HOME/.wine/drive_c" "$HAMPACK_STATE"
|
|
touch "$HAMPACK_STATE/wine-prefix-created"
|
|
run bash "$REPO/hampackremove" <<< $'y\ny'
|
|
[ ! -e "$HOME/.wine" ]
|
|
}
|
|
|
|
@test "removes graywolf's service, its state and the sibling clone" {
|
|
mkdir -p "$HAMPACK_STATE"
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
[ ! -e "$HAMPACK_STATE" ]
|
|
[ ! -e "$SIBLING" ]
|
|
}
|
|
|
|
@test "removes the radio command, but not someone else's" {
|
|
ln -s "$SIBLING/radio" "$HOME/.local/bin/radio"
|
|
remove
|
|
[ ! -L "$HOME/.local/bin/radio" ]
|
|
|
|
setup
|
|
echo theirs > "$HOME/.local/bin/radio"
|
|
remove
|
|
[ "$(cat "$HOME/.local/bin/radio")" = theirs ]
|
|
}
|
|
|
|
@test "takes you out of the uucp group only if HamPack put you in" {
|
|
echo uucp > "$FAKE_GROUPS"
|
|
mkdir -p "$HAMPACK_STATE"
|
|
echo uucp > "$HAMPACK_STATE/added-groups"
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
grep -qx "gpasswd -d $USER uucp" "$STUB_LOG"
|
|
! grep -qx uucp "$FAKE_GROUPS"
|
|
|
|
setup
|
|
echo uucp > "$FAKE_GROUPS"
|
|
remove
|
|
! grep -q gpasswd "$STUB_LOG"
|
|
grep -qx uucp "$FAKE_GROUPS"
|
|
}
|
|
|
|
@test "stops and removes the rigctld service radio configure set up" {
|
|
local unit="$HOME/.config/systemd/user/hampack-rigctld.service"
|
|
mkdir -p "$(dirname "$unit")"
|
|
echo "[Service]" > "$unit"
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
grep -qx "systemctl --user disable --now hampack-rigctld" "$STUB_LOG"
|
|
[ ! -e "$unit" ]
|
|
}
|
|
|
|
@test "removes the flrig autostart radio configure added, and no other" {
|
|
mkdir -p "$HOME/.config/autostart"
|
|
printf '[Desktop Entry]\nExec=flrig\nX-HamPack=radio configure --flrig\n' > "$HOME/.config/autostart/hampack-flrig.desktop"
|
|
printf '[Desktop Entry]\nExec=flrig\n' > "$HOME/.config/autostart/my-flrig.desktop"
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
[ ! -e "$HOME/.config/autostart/hampack-flrig.desktop" ]
|
|
[ -e "$HOME/.config/autostart/my-flrig.desktop" ]
|
|
}
|
|
|
|
@test "removes HamPack's udev rule" {
|
|
mkdir -p "$HAMPACK_UDEV_RULES_DIR"
|
|
echo rule > "$HAMPACK_UDEV_RULES_DIR/70-hampack-cm108.rules"
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
grep -qx "sudo rm -f $HAMPACK_UDEV_RULES_DIR/70-hampack-cm108.rules" "$STUB_LOG"
|
|
}
|
|
|
|
@test "does nothing unless confirmed" {
|
|
mark_installed fldigi
|
|
mkdir -p "$HAMPACK_STATE"
|
|
echo fldigi > "$HAMPACK_STATE/installed-packages"
|
|
remove n
|
|
[ -e "$FAKE_PACMAN_DB/fldigi" ]
|
|
[ -d "$SIBLING" ]
|
|
}
|
|
|
|
@test "stops xara's user service and keeps the user's xara settings" {
|
|
mkdir -p "$HOME/.config/systemd/user" "$HOME/.config/xara"
|
|
touch "$HOME/.config/systemd/user/xara.service" "$HOME/.config/xara/xara.conf"
|
|
remove
|
|
[ "$status" -eq 0 ]
|
|
grep -qx "systemctl --user disable --now xara" "$STUB_LOG"
|
|
[ -f "$HOME/.config/xara/xara.conf" ]
|
|
[[ "$output" == *"xara settings are still in ~/.config/xara"* ]]
|
|
}
|