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:
co-authored by
Claude Opus 5.5
parent
ebda32d567
commit
0b471c9771
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
setup() {
|
||||
setup_fake_home
|
||||
export HAMPACK_COMPILE_CONF="$BATS_TEST_TMPDIR/compile.conf"
|
||||
REPO_URL="file://$BATS_TEST_TMPDIR/upstream"
|
||||
git init -q "$BATS_TEST_TMPDIR/upstream"
|
||||
git -C "$BATS_TEST_TMPDIR/upstream" -c user.email=t@t -c user.name=t commit -q --allow-empty -m init
|
||||
}
|
||||
|
||||
@test "first install builds each app and records its version" {
|
||||
cat > "$HAMPACK_COMPILE_CONF" << EOF
|
||||
[app]
|
||||
version=1.0
|
||||
git=$REPO_URL
|
||||
install=\$HOME/.local/bin/app
|
||||
gui=true
|
||||
desktop=\$HAMPACK_DIR/desktop/yaac.desktop
|
||||
steps=mkdir sub, cd sub, touch \$HOME/.local/bin/app
|
||||
EOF
|
||||
run bash "$REPO/install-compiled.sh"
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "$HOME/.local/bin/app" ]
|
||||
grep -qx "app=1.0" "$HAMPACK_STATE/.installed_versions"
|
||||
grep -q "Icon=$REPO/desktop/icons/yaaclogo.png" "$HOME/.local/share/applications/yaac.desktop"
|
||||
}
|
||||
|
||||
@test "a failing step stops that build, records nothing, and later apps still build" {
|
||||
cat > "$HAMPACK_COMPILE_CONF" << EOF
|
||||
[bad]
|
||||
version=1.0
|
||||
git=$REPO_URL
|
||||
install=\$HOME/.local/bin/bad
|
||||
steps=true, false, touch \$HOME/.local/bin/bad
|
||||
|
||||
[good]
|
||||
version=2.0
|
||||
git=$REPO_URL
|
||||
install=\$HOME/.local/bin/good
|
||||
steps=touch \$HOME/.local/bin/good
|
||||
EOF
|
||||
run bash "$REPO/install-compiled.sh"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"step failed: false"* ]]
|
||||
[[ "$output" == *"Failed to install: bad"* ]]
|
||||
[ ! -e "$HOME/.local/bin/bad" ]
|
||||
[ -f "$HOME/.local/bin/good" ]
|
||||
! grep -q "^bad=" "$HAMPACK_STATE/.installed_versions"
|
||||
}
|
||||
|
||||
@test "update skips up-to-date apps without fetching, but refreshes desktop files" {
|
||||
cat > "$HAMPACK_COMPILE_CONF" << EOF
|
||||
[app]
|
||||
version=1.0
|
||||
git=file:///nonexistent
|
||||
install=\$HOME/.local/bin/app
|
||||
desktop=\$HAMPACK_DIR/desktop/yaac.desktop
|
||||
steps=false
|
||||
EOF
|
||||
touch "$HOME/.local/bin/app"
|
||||
mkdir -p "$HAMPACK_STATE"
|
||||
echo "app=1.0" > "$HAMPACK_STATE/.installed_versions"
|
||||
run bash "$REPO/install-compiled.sh"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"up to date"* ]]
|
||||
[ -f "$HOME/.local/share/applications/yaac.desktop" ]
|
||||
}
|
||||
|
||||
@test "update rebuilds when the version changes or isn't recorded, without asking" {
|
||||
cat > "$HAMPACK_COMPILE_CONF" << EOF
|
||||
[changed]
|
||||
version=2.0
|
||||
git=$REPO_URL
|
||||
install=\$HOME/.local/bin/changed
|
||||
steps=echo built > \$HOME/.local/bin/changed
|
||||
|
||||
[unrecorded]
|
||||
version=1.0
|
||||
git=$REPO_URL
|
||||
install=\$HOME/.local/bin/unrecorded
|
||||
steps=echo built > \$HOME/.local/bin/unrecorded
|
||||
EOF
|
||||
touch "$HOME/.local/bin/changed" "$HOME/.local/bin/unrecorded"
|
||||
mkdir -p "$HAMPACK_STATE"
|
||||
echo "changed=1.0" > "$HAMPACK_STATE/.installed_versions"
|
||||
run bash "$REPO/install-compiled.sh" < /dev/null
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat "$HOME/.local/bin/changed")" = built ]
|
||||
[ "$(cat "$HOME/.local/bin/unrecorded")" = built ]
|
||||
grep -qx "changed=2.0" "$HAMPACK_STATE/.installed_versions"
|
||||
}
|
||||
|
||||
@test "a step that reads stdin doesn't eat the rest of compile.conf" {
|
||||
cat > "$HAMPACK_COMPILE_CONF" << EOF
|
||||
[first]
|
||||
version=1.0
|
||||
git=$REPO_URL
|
||||
install=\$HOME/.local/bin/first
|
||||
steps=cat, touch \$HOME/.local/bin/first
|
||||
|
||||
[second]
|
||||
version=1.0
|
||||
git=$REPO_URL
|
||||
install=\$HOME/.local/bin/second
|
||||
steps=touch \$HOME/.local/bin/second
|
||||
EOF
|
||||
run bash "$REPO/install-compiled.sh"
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "$HOME/.local/bin/second" ]
|
||||
}
|
||||
|
||||
@test "an app missing version= fails instead of prompting" {
|
||||
printf '[app]\ngit=%s\ninstall=$HOME/x\nsteps=true\n' "$REPO_URL" > "$HAMPACK_COMPILE_CONF"
|
||||
run bash "$REPO/install-compiled.sh" < /dev/null
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"needs version="* ]]
|
||||
}
|
||||
|
||||
@test "the build directory is private and removed afterwards" {
|
||||
printf '[app]\nversion=1\ngit=%s\ninstall=$HOME/.local/bin/app\nsteps=pwd > $HOME/dir, touch $HOME/.local/bin/app\n' "$REPO_URL" > "$HAMPACK_COMPILE_CONF"
|
||||
run bash "$REPO/install-compiled.sh"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$(cat "$HOME/dir")" == "$TMPDIR"/hampack.* ]]
|
||||
[ ! -e "$(cat "$HOME/dir")" ]
|
||||
}
|
||||
Reference in New Issue
Block a user