Check HamPack's Flatpaks can open serial ports, in hampackcheck

`hampackcheck packages` (and so the weekly `make check-packages`) now
asks Flathub's API for each Flatpak's permissions, and fails if its
devices don't include all, without which it can't see /dev/ttyUSB0 to
control a radio itself, or if Flathub can't say. WSJT-X and QLog both
have it.

radio configure doesn't need it: it points them at rigctld over the
network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-28 14:06:33 -07:00
co-authored by Claude Opus 5.5
parent 0c2f9b5316
commit c409a6cb17
5 changed files with 48 additions and 8 deletions
-2
View File
@@ -19,8 +19,6 @@ control a radio, with rigctld started when the radio is plugged in.
interface whose radio has no CAT (a Digirig or AIOC on a handheld):
Dire Wolf's `PTT CM108`, Graywolf's cm108 method. HamPack's udev rule
already lets you open the card's `hidraw` device
- [ ] Check that the WSJT-X and QLog Flatpaks can open serial ports
(`--device=all`), in `hampackcheck` or the smoketest
- [ ] Later: run `radio configure` when a known radio is plugged in (a udev
rule starting a systemd user unit)
+1 -1
View File
@@ -95,7 +95,7 @@ HamPack is a set of Bash scripts. `install.sh` runs once, from `sibling add`; `u
- `make lint` runs shellcheck on every script
- `make test` runs the bats tests in `tests/`, which stub out sudo, pacman, Flatpak and systemd, so they're safe to run. They also check the conf files for missing or misspelt fields
- `make check-packages` checks that every package in `packages.conf` is in the Arch repos or the AUR, and every Flatpak is on Flathub (run `sudo pacman -Sy` first). It catches packages that were renamed or dropped upstream, but not a typo that happens to be another package's name
- `make check-packages` checks that every package in `packages.conf` is in the Arch repos or the AUR, and every Flatpak is on Flathub, with access to devices so it can open a radio's serial port (run `sudo pacman -Sy` first). It catches packages that were renamed or dropped upstream, but not a typo that happens to be another package's name
- `make hooks` runs `make lint test` before each commit
- `coredesktop-dev smoketest run --with HamPack` installs, updates and removes HamPack on a virtual machine with CoreDesktop, for what the bats tests' fakes can't check. See `smoketest/README.md`
- `TEST.md` lists the checks that need real radios or a real login, with tables for the results
+17 -3
View File
@@ -14,6 +14,7 @@ COMPILE_CONF="${HAMPACK_COMPILE_CONF:-$HAMPACK_DIR/compile.conf}"
PACKAGES_CONF="${HAMPACK_PACKAGES_CONF:-$HAMPACK_DIR/packages.conf}"
AUR_RPC="https://aur.archlinux.org/rpc/v5/info"
FLATHUB_API="https://flathub.org/api/v2/appstream"
FLATHUB_SUMMARY="https://flathub.org/api/v2/summary"
# Fetch latest release tag via GitHub API, stripping leading "v"
github_latest() {
@@ -104,7 +105,8 @@ check_compiled() {
}
# Check that each package in packages.conf is in pacman's sync databases (as
# a package or a group) or on the AUR, and each Flatpak is on Flathub. Repo
# a package or a group) or on the AUR, and each Flatpak is on Flathub, with
# access to devices: they're radio programs, which open serial ports. Repo
# packages are looked up locally, so run `pacman -Sy` first for fresh results.
# A name that's only provided by another package still installs, but is
# reported so packages.conf can use the real name.
@@ -143,13 +145,25 @@ check_packages() {
done
fi
local devices
for p in "${flatpak_ids[@]}"; do
code="$(curl -s -o /dev/null -w '%{http_code}' "$FLATHUB_API/$p")"
case "$code" in
200) echo " $p is on Flathub" ;;
404) echo " $p is not on Flathub ** MISSING **"; status=1 ;;
*) echo " $p couldn't be checked: Flathub answered ${code:-nothing}"; status=1 ;;
404) echo " $p is not on Flathub ** MISSING **"; status=1; continue ;;
*) echo " $p couldn't be checked: Flathub answered ${code:-nothing}"; status=1; continue ;;
esac
# Without devices=all (its finish-args' --device=all), a Flatpak sees no
# /dev/ttyUSB0, so it can't control a radio itself
if ! devices="$(set -o pipefail; curl -sf "$FLATHUB_SUMMARY/$p" | jq -er '.metadata.permissions.devices // [] | join(",")')"; then
echo " $p's permissions couldn't be checked"
status=1
elif [[ ",$devices," == *,all,* ]]; then
echo " $p can open serial ports (devices=all)"
else
echo " $p can't open serial ports: its devices are \"${devices:-none}\", not all ** NO SERIAL PORTS **"
status=1
fi
done
return $status
+2 -1
View File
@@ -58,7 +58,8 @@ APPLICATIONS=(
gridtracker2
)
# Flatpaks, installed system-wide from Flathub
# Flatpaks, installed system-wide from Flathub. Each needs devices=all, to
# open a radio's serial port; `hampackcheck packages` checks Flathub's build has it
FLATPAKS=(
io.sourceforge.wsjt.wsjtx
io.github.foldynl.QLog
+28 -1
View File
@@ -31,6 +31,10 @@ setup() {
esac
done
echo "]}" ;;
https://flathub.org/api/v2/summary/*)
f="$FAKE_NET/summary-${url##*/}"
[ -f "$f" ] || exit 22
cat "$f" ;;
https://flathub.org/*)
grep -qxF "${url##*/}" "$FAKE_NET/flathub" 2>/dev/null && echo 200 || echo 404 ;;
*)
@@ -55,6 +59,14 @@ setup() {
esac'
}
# A Flatpak on Flathub, with these devices: flathub_app ID [DEVICES...]
flathub_app() {
local id="$1"
shift
echo "$id" >> "$FAKE_NET/flathub"
jq -n --args '{metadata: {permissions: {devices: $ARGS.positional, shared: ["network"]}}}' "$@" > "$FAKE_NET/summary-$id"
}
tags() { local repo="$1"; shift; printf 'abc\trefs/tags/%s\n' "$@" > "$FAKE_NET/tags-$repo"; }
packages_conf() {
@@ -166,9 +178,10 @@ EOF
echo repo-pkg > "$FAKE_NET/repo"
echo a-group > "$FAKE_NET/groups"
echo aur-pkg > "$FAKE_NET/aur"
echo org.example.App > "$FAKE_NET/flathub"
flathub_app org.example.App all
run "$REPO/hampackcheck" packages
[ "$status" -eq 0 ]
[[ "$output" == *"org.example.App can open serial ports (devices=all)"* ]]
[[ "$output" == *"3 packages, 2 in the repos"* ]]
[[ "$output" == *"aur-pkg is on the AUR"* ]]
[[ "$output" == *"org.example.App is on Flathub"* ]]
@@ -187,6 +200,20 @@ EOF
[[ "$output" != *"repo-pkg is"* ]]
}
@test "hampackcheck: a Flatpak that can't open serial ports fails the check" {
packages_conf "" "" "org.example.Dri
org.example.None
org.example.Unknown"
flathub_app org.example.Dri dri
flathub_app org.example.None
echo org.example.Unknown >> "$FAKE_NET/flathub"
run "$REPO/hampackcheck" packages
[ "$status" -eq 1 ]
[[ "$output" == *"org.example.Dri can't open serial ports: its devices are \"dri\", not all ** NO SERIAL PORTS **"* ]]
[[ "$output" == *"org.example.None can't open serial ports: its devices are \"none\", not all"* ]]
[[ "$output" == *"org.example.Unknown's permissions couldn't be checked"* ]]
}
@test "hampackcheck: a name only provided by another package passes, with a note" {
packages_conf "old-name" "" ""
echo "old-name=new-name" > "$FAKE_NET/provides"