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>
106 lines
3.2 KiB
Bash
106 lines
3.2 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
setup() {
|
|
setup_fake_home
|
|
source "$REPO/lib.sh"
|
|
}
|
|
|
|
@test "expand_vars replaces only HOME, HAMPACK_DIR and USER" {
|
|
run expand_vars 'python $HOME/x.pyz; $HAMPACK_DIR/icon.png $USER'
|
|
[ "$output" = "python $HOME/x.pyz; $REPO/icon.png $USER" ]
|
|
}
|
|
|
|
@test "expand_vars keeps semicolons, quotes and spacing" {
|
|
run expand_vars "HamRadio;Utility;"
|
|
[ "$output" = "HamRadio;Utility;" ]
|
|
run expand_vars "it's (two spaces) & \$OTHER"
|
|
[ "$output" = "it's (two spaces) & \$OTHER" ]
|
|
}
|
|
|
|
collect() { SEEN+=("${CONF[_name]}:${CONF[version]}:${CONF[url]}"); }
|
|
|
|
@test "parse_conf calls back once per section, including the last, skipping comments" {
|
|
cat > "$BATS_TEST_TMPDIR/t.conf" << 'EOF'
|
|
# a comment
|
|
[one]
|
|
version=1
|
|
url=https://a/b?c=d=e
|
|
|
|
# an indented comment
|
|
[two]
|
|
version=2
|
|
EOF
|
|
SEEN=()
|
|
parse_conf "$BATS_TEST_TMPDIR/t.conf" collect
|
|
[ "${#SEEN[@]}" -eq 2 ]
|
|
[ "${SEEN[0]}" = "one:1:https://a/b?c=d=e" ]
|
|
[ "${SEEN[1]}" = "two:2:" ]
|
|
}
|
|
|
|
uses_regex() { [[ "x" =~ (x) ]]; SEEN+=("${CONF[_name]}"); }
|
|
|
|
@test "parse_conf section names survive callbacks that use =~" {
|
|
printf '[a]\n[b]\n[c]\n' > "$BATS_TEST_TMPDIR/t.conf"
|
|
SEEN=()
|
|
parse_conf "$BATS_TEST_TMPDIR/t.conf" uses_regex
|
|
[ "${SEEN[*]}" = "a b c" ]
|
|
}
|
|
|
|
swallow_stdin() { cat > /dev/null; SEEN+=("${CONF[_name]}"); }
|
|
|
|
@test "parse_conf callbacks can't swallow the rest of the file through stdin" {
|
|
printf '[a]\nx=1\n[b]\nx=2\n[c]\nx=3\n' > "$BATS_TEST_TMPDIR/t.conf"
|
|
SEEN=()
|
|
parse_conf "$BATS_TEST_TMPDIR/t.conf" swallow_stdin < /dev/null
|
|
[ "${SEEN[*]}" = "a b c" ]
|
|
}
|
|
|
|
@test "versions are saved, replaced and forgotten by exact name" {
|
|
save_installed_version dx.py abc
|
|
save_installed_version dxApy other
|
|
save_installed_version dx.py def
|
|
[ "$(get_recorded_version dx.py)" = "def" ]
|
|
[ "$(get_recorded_version dxApy)" = "other" ]
|
|
[ "$(grep -c '^dx\.py=' "$VERSION_FILE")" -eq 1 ]
|
|
forget_version dx.py
|
|
[ -z "$(get_recorded_version dx.py)" ]
|
|
[ "$(get_recorded_version dxApy)" = "other" ]
|
|
}
|
|
|
|
@test "get_recorded_version prints nothing without a version file" {
|
|
run get_recorded_version anything
|
|
[ "$status" -eq 0 ]
|
|
[ -z "$output" ]
|
|
}
|
|
|
|
@test "record_installed keeps a sorted list without duplicates" {
|
|
record_installed installed-packages b a
|
|
record_installed installed-packages a c
|
|
record_installed installed-packages
|
|
[ "$(recorded_installs installed-packages | tr '\n' ' ')" = "a b c " ]
|
|
}
|
|
|
|
@test "install_staged copies home files as the user, uses sudo outside home, and writes a manifest" {
|
|
local stage="$BATS_TEST_TMPDIR/stage"
|
|
mkdir -p "$stage$HOME/.local/bin" "$stage/etc/udev/rules.d"
|
|
echo new > "$stage$HOME/.local/bin/tool"
|
|
echo rule > "$stage/etc/udev/rules.d/99-test.rules"
|
|
echo old > "$HOME/.local/bin/tool"
|
|
|
|
HAMPACK_APP=testapp install_staged "$stage"
|
|
|
|
[ "$(cat "$HOME/.local/bin/tool")" = "new" ]
|
|
grep -qx "sudo cp -P --remove-destination $stage/etc/udev/rules.d/99-test.rules /etc/udev/rules.d/99-test.rules" "$STUB_LOG"
|
|
grep -qx "$HOME/.local/bin/tool" "$HAMPACK_STATE/manifests/testapp"
|
|
grep -qx "/etc/udev/rules.d/99-test.rules" "$HAMPACK_STATE/manifests/testapp"
|
|
}
|
|
|
|
@test "install_staged needs HAMPACK_APP" {
|
|
mkdir -p "$BATS_TEST_TMPDIR/stage"
|
|
unset HAMPACK_APP
|
|
run install_staged "$BATS_TEST_TMPDIR/stage"
|
|
[ "$status" -ne 0 ]
|
|
}
|