`radio` lists each radio plugged into USB: its serial ports, the sound card that came with it (the same USB device, or behind the radio's own hub), and its model and Hamlib model number. Icoms are recognised by their USB serial number. `radio detect --probe` asks the others with the CAT ID; command or Icom's CI-V transceiver ID, at the usual baud rates, on ports no other program has open; `radio probe PORT` asks one port. It drops DTR and RTS as soon as a port opens. The radios it knows are in radios.conf. update.sh links ~/.local/bin/radio to the clone, unless a different radio is already there, and adds you to uucp, which owns serial ports on Arch. hampackremove removes the link, and takes you out of uucp only if HamPack put you in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
133 lines
4.7 KiB
Bash
133 lines
4.7 KiB
Bash
#!/usr/bin/env bats
|
|
#
|
|
# update.sh as run on first install (by install.sh) and on later updates
|
|
# (by CoreDesktop's `update`)
|
|
|
|
load helpers
|
|
|
|
setup() {
|
|
setup_fake_home
|
|
fake_coredesktop
|
|
# No apps to download or build; those scripts have their own tests
|
|
export HAMPACK_BINARIES_CONF="$BATS_TEST_TMPDIR/empty.conf"
|
|
export HAMPACK_COMPILE_CONF="$BATS_TEST_TMPDIR/empty.conf"
|
|
: > "$HAMPACK_BINARIES_CONF"
|
|
local data="$BATS_TEST_TMPDIR/uv-tools/not1mm/lib/python3.13/site-packages/not1mm/data"
|
|
mkdir -p "$data"
|
|
touch "$data/k6gte-not1mm.desktop"
|
|
export UV_TOOL_DIR="$BATS_TEST_TMPDIR/uv-tools"
|
|
stub uv '
|
|
case "$1 $2" in
|
|
"tool list") [ -f "$HOME/not1mm" ] && echo "not1mm v1.0" ;;
|
|
"tool install") touch "$HOME/not1mm" ;;
|
|
"tool dir") echo "$UV_TOOL_DIR" ;;
|
|
esac
|
|
exit 0'
|
|
}
|
|
|
|
@test "first install records only the packages and Flatpaks it installed" {
|
|
mark_installed cmake wine
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"HamPack updated."* ]]
|
|
# Everything on the list is installed now
|
|
local pkg
|
|
for pkg in $(all_hampack_packages); do [ -f "$FAKE_PACMAN_DB/$pkg" ]; done
|
|
# but what was there before isn't recorded as HamPack's
|
|
! grep -qx cmake "$HAMPACK_STATE/installed-packages"
|
|
! grep -qx wine "$HAMPACK_STATE/installed-packages"
|
|
grep -qx hamlib "$HAMPACK_STATE/installed-packages"
|
|
[ "$(wc -l < "$HAMPACK_STATE/installed-flatpaks")" -eq "$(all_hampack_flatpaks | wc -l)" ]
|
|
grep -qx "uv tool install not1mm" "$STUB_LOG"
|
|
[ -x "$HOME/.local/bin/hampackremove" ]
|
|
[ "$(readlink "$HOME/.local/bin/radio")" = "$REPO/radio" ]
|
|
"$HOME/.local/bin/radio" help | grep -q "Usage: radio"
|
|
}
|
|
|
|
@test "adds you to the uucp group once, and records it" {
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"Added you to the uucp group"*"Log out and back in"* ]]
|
|
grep -qx "usermod -aG uucp $USER" "$STUB_LOG"
|
|
grep -qx uucp "$HAMPACK_STATE/added-groups"
|
|
|
|
: > "$STUB_LOG"
|
|
run bash "$REPO/update.sh"
|
|
[[ "$output" != *"Added you to the uucp group"* ]]
|
|
! grep -q usermod "$STUB_LOG"
|
|
}
|
|
|
|
@test "doesn't claim the uucp group if you were already in it" {
|
|
echo uucp > "$FAKE_GROUPS"
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 0 ]
|
|
! grep -q usermod "$STUB_LOG"
|
|
[ ! -e "$HAMPACK_STATE/added-groups" ]
|
|
}
|
|
|
|
@test "update leaves alone a radio command that isn't HamPack's" {
|
|
echo "theirs" > "$HOME/.local/bin/radio"
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"Not installing HamPack's radio command"* ]]
|
|
[ "$(cat "$HOME/.local/bin/radio")" = theirs ]
|
|
}
|
|
|
|
@test "a later update installs and records nothing new" {
|
|
bash "$REPO/update.sh"
|
|
cp "$HAMPACK_STATE/installed-packages" "$BATS_TEST_TMPDIR/before"
|
|
: > "$STUB_LOG"
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 0 ]
|
|
! grep -q '^yay -S' "$STUB_LOG"
|
|
! grep -q '^flatpak install' "$STUB_LOG"
|
|
grep -qx "uv tool upgrade not1mm" "$STUB_LOG"
|
|
cmp "$HAMPACK_STATE/installed-packages" "$BATS_TEST_TMPDIR/before"
|
|
}
|
|
|
|
@test "an update after install from before records: existing packages aren't claimed" {
|
|
local pkg
|
|
for pkg in $(all_hampack_packages); do mark_installed "$pkg"; done
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 0 ]
|
|
[ ! -s "$HAMPACK_STATE/installed-packages" ]
|
|
}
|
|
|
|
@test "update removes stale state from older HamPack versions" {
|
|
mkdir -p "$HAMPACK_STATE"
|
|
printf 'Kiwix-Desktop=2.75.1\nkiwix-desktop=2.5.1\nKiwix-Tools=3.8.2\n' > "$HAMPACK_STATE/.installed_versions"
|
|
mark_installed $(all_hampack_packages)
|
|
printf 'fldigi\nlibappindicator-gtk3\nzim-tools\nzimwriterfs\n' > "$HAMPACK_STATE/installed-packages"
|
|
touch "$HOME/.local/bin/hampackupdate"
|
|
run bash "$REPO/update.sh"
|
|
[ "$(cat "$HAMPACK_STATE/.installed_versions")" = "kiwix-desktop=2.5.1" ]
|
|
[ "$(cat "$HAMPACK_STATE/installed-packages")" = "$(printf 'fldigi\nlibappindicator\nzim-tools')" ]
|
|
[ ! -e "$HOME/.local/bin/hampackupdate" ]
|
|
grep -qx "sudo rm -f /etc/sudoers.d/hampack" "$STUB_LOG"
|
|
}
|
|
|
|
@test "graywolf's service is installed and enabled once graywolf is built" {
|
|
run bash "$REPO/update.sh"
|
|
! grep -q "graywolf.service" "$STUB_LOG"
|
|
|
|
touch "$HOME/.local/bin/graywolf"
|
|
chmod +x "$HOME/.local/bin/graywolf"
|
|
: > "$STUB_LOG"
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 0 ]
|
|
grep -qx "sudo tee /etc/systemd/system/graywolf.service" "$STUB_LOG"
|
|
grep -qx "enable_services graywolf" "$STUB_LOG"
|
|
}
|
|
|
|
@test "the graywolf web UI listens only on this machine" {
|
|
grep -q -- "-http 127.0.0.1:8080" "$REPO/systemd/graywolf.service"
|
|
}
|
|
|
|
@test "a failing step is reported and the rest still run" {
|
|
stub flatpak 'exit 1'
|
|
run bash "$REPO/update.sh"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"errors in: Installing Flatpak applications"* ]]
|
|
grep -qx "uv tool install not1mm" "$STUB_LOG"
|
|
}
|