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>
150 lines
5.5 KiB
Bash
150 lines
5.5 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Purpose : Keep HamPack current (run by CoreDesktop's `update`, and by install.sh)
|
|
|
|
SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
COREDESKTOP="$HOME/.local/share/coredesktop"
|
|
source "$COREDESKTOP/utils.sh"
|
|
|
|
# Config files and build steps refer to files in this repo through $HAMPACK_DIR
|
|
export HAMPACK_DIR="$SELF"
|
|
source "$SELF/lib.sh"
|
|
|
|
FAILED=()
|
|
|
|
# Run one update step; a failure is reported but doesn't stop the later steps
|
|
step() {
|
|
local name="$1"
|
|
shift
|
|
echo "→ $name..."
|
|
if ! "$@"; then
|
|
echo "✗ $name failed."
|
|
FAILED+=("$name")
|
|
fi
|
|
}
|
|
|
|
remove_stale_files() {
|
|
# The HamPack GUI app (a Go program) was removed, along with its source and build hook
|
|
rm -f "$HOME/.local/bin/hampack"
|
|
rm -f "$HOME/.local/share/applications/hampack.desktop"
|
|
rm -f "$HOME"/.local/share/icons/hicolor/*/apps/computer.young.HamPack.png
|
|
rm -rf "$HOME/.local/share/HamPack/hampack-src"
|
|
rm -rf "$HOME/.local/share/HamPack/desktop/icons/hicolor"
|
|
rm -f "$COREDESKTOP"/updates.d/*hampack-build*
|
|
# Replaced by CoreDesktop's `update` and `sibling add`
|
|
rm -f "$HOME/.local/bin/hampackupdate" "$HOME/.local/bin/hampackrefresh"
|
|
# Paracon is now installed without the version in its file name
|
|
rm -f "$HOME"/.local/bin/paracon_*.pyz
|
|
# Hooks from before HamPack was a sibling; 71-siblings.sh now runs this script
|
|
rm -f "$COREDESKTOP"/updates.d/[0-9][0-9][0-9]-hampack-*
|
|
# Versions recorded under app names HamPack no longer uses
|
|
forget_version Kiwix-Desktop
|
|
forget_version Kiwix-Tools
|
|
# Build directories from before builds used a private temporary directory
|
|
rm -rf /tmp/hampack-build /tmp/windowsapps 2> /dev/null
|
|
# The passwordless sudoers file the old installer used, if a killed install left it behind
|
|
sudo rm -f /etc/sudoers.d/hampack
|
|
# Builds used to run `sudo make install` into ~/.local, leaving files there owned by root
|
|
local dirs=() dir
|
|
for dir in bin lib include share/applications share/doc share/icons share/man share/metainfo share/direwolf; do
|
|
[ -d "$HOME/.local/$dir" ] && dirs+=("$HOME/.local/$dir")
|
|
done
|
|
[ ${#dirs[@]} -eq 0 ] ||
|
|
find "${dirs[@]}" -xdev -user root -print0 2> /dev/null | xargs -0 -r sudo chown -h "$USER:"
|
|
return 0
|
|
}
|
|
|
|
install_tools() {
|
|
mkdir -p "$HOME/.local/bin"
|
|
install_script "$SELF/hampackremove" "$HOME/.local/bin/hampackremove"
|
|
}
|
|
|
|
# Install the packages in packages.conf, and record the ones that weren't
|
|
# already installed, so hampackremove removes those and nothing the user had before
|
|
install_hampack_packages() {
|
|
source "$SELF/packages.conf"
|
|
local pkg missing=() added=() status=0
|
|
|
|
for pkg in "${UTILITIES[@]}" "${APPLICATIONS[@]}"; do
|
|
is_installed "$pkg" || missing+=("$pkg")
|
|
done
|
|
|
|
install_packages "${UTILITIES[@]}" && install_packages "${APPLICATIONS[@]}" || status=1
|
|
|
|
for pkg in "${missing[@]}"; do
|
|
is_installed "$pkg" && added+=("$pkg")
|
|
done
|
|
record_installed installed-packages "${added[@]}"
|
|
return $status
|
|
}
|
|
|
|
install_not1mm() {
|
|
if uv tool list 2> /dev/null | grep -q '^not1mm '; then
|
|
uv tool upgrade not1mm
|
|
else
|
|
uv tool install not1mm
|
|
fi
|
|
}
|
|
|
|
# not1mm installs its own launcher only on first run, so install it up front
|
|
install_not1mm_desktop() {
|
|
local data
|
|
data=$(echo "$(uv tool dir)"/not1mm/lib/python3*/site-packages/not1mm/data)
|
|
[ -f "$data/k6gte-not1mm.desktop" ] || return 1
|
|
for size in 32 64 128; do
|
|
xdg-icon-resource install --size "$size" --context apps --mode user \
|
|
"$data/k6gte.not1mm-$size.png" k6gte-not1mm || return 1
|
|
done
|
|
xdg-desktop-menu install --mode user "$data/k6gte-not1mm.desktop"
|
|
}
|
|
|
|
# Install graywolf's systemd service once graywolf is built, and reinstall it
|
|
# when systemd/graywolf.service changes. To change how graywolf runs (e.g. to
|
|
# reach its web UI from other machines), use `sudo systemctl edit graywolf`:
|
|
# a drop-in survives updates, while edits to the unit file itself don't.
|
|
install_graywolf_service() {
|
|
[ -x "$HOME/.local/bin/graywolf" ] || return 0
|
|
|
|
local unit=/etc/systemd/system/graywolf.service rendered
|
|
rendered="$(sed "s|HAMPACK_USER|$USER|g; s|HAMPACK_HOME|$HOME|g" "$SELF/systemd/graywolf.service")"
|
|
mkdir -p "$HOME/.local/share/graywolf"
|
|
getent group dialout > /dev/null || sudo groupadd dialout || return 1
|
|
|
|
if [ "$(cat "$unit" 2> /dev/null)" != "$rendered" ]; then
|
|
echo "Installing $unit..."
|
|
printf '%s\n' "$rendered" | sudo tee "$unit" > /dev/null || return 1
|
|
sudo systemctl daemon-reload || return 1
|
|
sudo systemctl try-restart graywolf
|
|
fi
|
|
enable_services graywolf
|
|
}
|
|
|
|
# --- Main ---
|
|
|
|
echo "Updating HamPack..."
|
|
|
|
# Builds and package installs need sudo; ask now rather than partway through.
|
|
# Under CoreDesktop's `update`, sudo already has the password and doesn't ask.
|
|
if ! start_sudo_keepalive; then
|
|
echo "HamPack needs sudo to install packages and applications."
|
|
exit 1
|
|
fi
|
|
|
|
step "Removing stale HamPack files" remove_stale_files
|
|
step "Installing HamPack tools" install_tools
|
|
step "Installing HamPack packages" install_hampack_packages
|
|
step "Installing Flatpak applications" bash "$SELF/install-flatpaks.sh"
|
|
step "Installing pre-built binaries" bash "$SELF/install-binaries.sh"
|
|
step "Installing compiled applications" bash "$SELF/install-compiled.sh"
|
|
step "Installing graywolf service" install_graywolf_service
|
|
step "Installing Windows applications" bash "$SELF/install-windows-apps.sh"
|
|
step "Installing not1mm" install_not1mm
|
|
step "Installing not1mm desktop file" install_not1mm_desktop
|
|
|
|
if (( ${#FAILED[@]} > 0 )); then
|
|
echo "HamPack updated, with errors in: ${FAILED[*]}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ HamPack updated."
|