libappindicator-gtk3 and zimwriterfs aren't packages any more; they installed only because libappindicator and zim-tools provide them. But hampackremove couldn't match those names with what's installed, so it never removed them. zim-tools was already listed, so zimwriterfs goes. Updates rename the old names in the record of installed packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
102 lines
3.7 KiB
Bash
102 lines
3.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" ]
|
|
}
|
|
|
|
@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"
|
|
}
|