Harden install, update and uninstall; add shared lib and tests

Updates
- install-compiled.sh never prompts: unknown versions rebuild, a missing
  version= fails
- Detect VARA Terminal by "VARA Terminal.exe" in drive_c/VARA, not by
  the folder VARA HF also uses
- install-windows-apps.sh checks first: nothing is downloaded and
  winetricks doesn't run unless a product is missing, and installers
  only run with a desktop session
- Flatpaks install system-wide from flathub and honor skip-packages
- Rewrite desktop files on every run so icon paths stay right; add the
  missing QtTermTCP desktop file
- Build steps can't read the rest of the conf through stdin

Uninstall
- update.sh records the packages and Flatpaks HamPack itself installed;
  hampackremove removes only those that nothing else needs, and lists
  the rest
- Read package lists from packages.conf instead of copies, remove
  files from install manifests, conf install paths and older builds,
  and revert the Wine Decorated setting

Security
- Replace the NOPASSWD sudoers file with a sudo keepalive, and delete a
  leftover /etc/sudoers.d/hampack
- Verify binaries.conf downloads against sha256=; pin dx.py to a commit
- Graywolf's web UI listens on 127.0.0.1; update.sh manages its unit
- Install direwolf and kiwix through a staging directory with
  install_staged, so nothing in ~/.local ends up owned by root; hand
  back any root-owned files left by older builds
- Use private temp directories instead of fixed /tmp paths

Code quality
- Shared lib.sh: conf parser, variable expansion, version records,
  install tracking, staged installs, sudo keepalive
- bats tests covering first install and update paths, Makefile with
  lint/test/hooks, pre-commit hook
- patch-potacat.sh uses jq; drop stale kiwix version entries

README: fill in what gets installed, uninstall and graywolf notes,
development section, typo and Matrix link fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-08 09:55:13 -07:00
co-authored by Claude Opus 5.5
parent ebda32d567
commit 0b471c9771
26 changed files with 1525 additions and 1015 deletions
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env bats
#
# install-windows-apps.sh, install-flatpaks.sh and patch-potacat.sh
load helpers
setup() {
setup_fake_home
fake_coredesktop
stub curl 'exit 1'
}
install_all_windows_apps() {
local c="$HOME/.wine/drive_c"
mkdir -p "$c/VARA" "$c/VARA FM" "$c/RMS Express"
touch "$c/VARA/VARA.exe" "$c/VARA/VARA Terminal.exe" "$c/VARA FM/VARAFM.exe" "$c/RMS Express/RMS Express.exe"
}
@test "windows apps: when all are installed, nothing is downloaded or run" {
install_all_windows_apps
export DISPLAY=:0
run bash "$REPO/install-windows-apps.sh"
[ "$status" -eq 0 ]
! grep -qE '^(curl|winetricks|wine) ' "$STUB_LOG"
}
@test "windows apps: VARA Terminal is installed even when VARA HF is" {
install_all_windows_apps
rm "$HOME/.wine/drive_c/VARA/VARA Terminal.exe"
export DISPLAY=:0
run bash "$REPO/install-windows-apps.sh"
[[ "$output" == *"VARA HF is already installed"* ]]
[[ "$output" == *"VARA Terminal was not installed"* ]]
grep -q "^curl .*VARA%20Products" "$STUB_LOG"
}
@test "windows apps: without a desktop session, nothing is downloaded and the update isn't failed" {
run bash "$REPO/install-windows-apps.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"without a desktop session"* ]]
! grep -q '^curl ' "$STUB_LOG"
}
@test "windows apps: winetricks runs only once" {
export DISPLAY=:0
mkdir -p "$HOME/.wine"
bash "$REPO/install-windows-apps.sh" || true
bash "$REPO/install-windows-apps.sh" || true
[ "$(grep -c '^winetricks ' "$STUB_LOG")" -eq 1 ]
}
@test "flatpaks: installs missing ones from flathub and records only those" {
local first second
first="$(all_hampack_flatpaks | sed -n 1p)"
second="$(all_hampack_flatpaks | sed -n 2p)"
touch "$FAKE_FLATPAKS/$first"
run bash "$REPO/install-flatpaks.sh"
[ "$status" -eq 0 ]
grep -qx "flatpak install --system --noninteractive flathub $second" "$STUB_LOG"
[ "$(cat "$HAMPACK_STATE/installed-flatpaks")" = "$second" ]
}
@test "flatpaks: update with everything installed installs nothing" {
local pak
for pak in $(all_hampack_flatpaks); do touch "$FAKE_FLATPAKS/$pak"; done
run bash "$REPO/install-flatpaks.sh"
[ "$status" -eq 0 ]
! grep -q '^flatpak install' "$STUB_LOG"
}
@test "patch-potacat removes deb and rpm targets in both forms" {
local pkg="$BATS_TEST_TMPDIR/package.json"
echo '{"build":{"linux":{"target":["AppImage","deb",{"target":"rpm"}],"category":"Utility"}}}' > "$pkg"
run bash "$REPO/patch-potacat.sh" "$pkg"
[ "$status" -eq 0 ]
[ "$(jq -c '.build.linux' "$pkg")" = '{"target":["AppImage"],"category":"Utility"}' ]
}
@test "patch-potacat leaves a package.json without targets alone" {
local pkg="$BATS_TEST_TMPDIR/package.json"
echo '{"name":"x"}' > "$pkg"
run bash "$REPO/patch-potacat.sh" "$pkg"
[ "$status" -eq 0 ]
[ "$(jq -c . "$pkg")" = '{"name":"x"}' ]
}