From 73a6b7a83bea3920732c5805ed2bc75b17b4c931 Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 30 Apr 2026 07:12:15 -0600 Subject: [PATCH] various updates --- binaries.conf | 2 +- compile.conf | 4 +- hampackcheck | 122 +++++++++++++++++++++++++++++++++ hampackrefresh | 2 +- hampackupdate | 178 +++++++++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 300 insertions(+), 8 deletions(-) create mode 100755 hampackcheck diff --git a/binaries.conf b/binaries.conf index 5752f47..b55f2c4 100644 --- a/binaries.conf +++ b/binaries.conf @@ -28,7 +28,7 @@ install=$HOME/.local/bin/ardopcf_amd64_Linux_64 gui=false [paracon] -version=1.30 +version=1.3.0 url=https://github.com/mfncooper/paracon/releases/download/v1.3.0/paracon_1.3.0.pyz install=$HOME/.local/bin/paracon_1.3.0.pyz gui=true diff --git a/compile.conf b/compile.conf index de84a62..b572526 100644 --- a/compile.conf +++ b/compile.conf @@ -24,7 +24,7 @@ gui=true steps=qmake, make, mv QtTermTCP $HOME/.local/bin/ [kiwix-desktop] -version=2.75.1 +version=2.5.1 git=https://github.com/kiwix/kiwix-desktop.git install=$HOME/.local/bin/kiwix-desktop gui=true @@ -51,7 +51,7 @@ gui=true steps=rm -rf $HOME/.local/bin/yaac, mkdir -p $HOME/.local/bin/yaac, mv /tmp/hampack-build/yaac/* $HOME/.local/bin/yaac/ [potacat] -version=1.5.10 +version=1.5.11 git=https://github.com/Waffleslop/POTACAT.git install=$HOME/.local/bin/POTACAT.AppImage desktop=$HOME/.local/share/HamPack/desktop/potacat.desktop diff --git a/hampackcheck b/hampackcheck new file mode 100755 index 0000000..f5c83e5 --- /dev/null +++ b/hampackcheck @@ -0,0 +1,122 @@ +#!/bin/bash +# +# Purpose: Check for available version updates in binaries.conf and compile.conf + +HAMPACK_DIR="${HAMPACK_DIR:-$HOME/.local/share/HamPack}" +BINARIES_CONF="${HAMPACK_BINARIES_CONF:-$HAMPACK_DIR/binaries.conf}" +COMPILE_CONF="${HAMPACK_COMPILE_CONF:-$HAMPACK_DIR/compile.conf}" + +# Extract "owner/repo" from a GitHub URL, or empty string if not GitHub +github_repo_from_url() { + local url="$1" + if [[ "$url" =~ github\.com/([^/]+)/([^/]+) ]]; then + echo "${BASH_REMATCH[1]}/${BASH_REMATCH[2]%.git}" + fi +} + +# Fetch latest release tag via GitHub API, stripping leading "v" +github_latest() { + local repo="$1" + curl -sf "https://api.github.com/repos/$repo/releases/latest" \ + | grep '"tag_name"' \ + | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/' \ + | sed 's/^v//' +} + +print_result() { + local app="$1" + local pinned="$2" + local latest="$3" + local manual_url="$4" + + if [ -n "$manual_url" ]; then + printf " %-20s pinned=%-15s (manual check: %s)\n" "$app" "$pinned" "$manual_url" + elif [ -z "$latest" ]; then + printf " %-20s pinned=%-15s (GitHub API unavailable)\n" "$app" "$pinned" + elif [ "$pinned" = "$latest" ]; then + printf " %-20s up to date (%s)\n" "$app" "$pinned" + else + printf " %-20s pinned=%-15s latest=%-15s ** UPDATE AVAILABLE **\n" "$app" "$pinned" "$latest" + fi +} + +check_app() { + local app="$1" + local version="$2" + local url="$3" # git= or url= field (may be GitHub) + local fallback="$4" # wget= or non-GitHub url for manual check + + [ -z "$app" ] || [ -z "$version" ] && return + + local gh_repo + gh_repo=$(github_repo_from_url "$url") + + if [ -n "$gh_repo" ]; then + print_result "$app" "$version" "$(github_latest "$gh_repo")" "" + else + print_result "$app" "$version" "" "${fallback:-$url}" + fi +} + +check_binaries() { + echo "=== binaries.conf ===" + local app="" version="" url="" + + while IFS= read -r line || [ -n "$line" ]; do + [[ -z "$line" || "$line" == \#* ]] && continue + + if [[ "$line" =~ ^\[(.+)\]$ ]]; then + check_app "$app" "$version" "$url" "" + app="${BASH_REMATCH[1]}" version="" url="" + continue + fi + + local key="${line%%=*}" value="${line#*=}" + case "$key" in + version) version="$value" ;; + url) url="$value" ;; + esac + done < "$BINARIES_CONF" + + check_app "$app" "$version" "$url" "" +} + +check_compiled() { + echo "" + echo "=== compile.conf ===" + local app="" version="" git_url="" wget_url="" + + while IFS= read -r line || [ -n "$line" ]; do + [[ -z "$line" || "$line" == \#* ]] && continue + + if [[ "$line" =~ ^\[(.+)\]$ ]]; then + check_app "$app" "$version" "$git_url" "$wget_url" + app="${BASH_REMATCH[1]}" version="" git_url="" wget_url="" + continue + fi + + local key="${line%%=*}" value="${line#*=}" + case "$key" in + version) version="$value" ;; + git) git_url="$value" ;; + wget) wget_url="$value" ;; + esac + done < "$COMPILE_CONF" + + check_app "$app" "$version" "$git_url" "$wget_url" +} + +# --- Main --- + +for conf in "$BINARIES_CONF" "$COMPILE_CONF"; do + if [ ! -f "$conf" ]; then + echo "Error: $conf not found." + exit 1 + fi +done + +echo "Checking HamPack application versions..." +check_binaries +check_compiled +echo "" +echo "Done." diff --git a/hampackrefresh b/hampackrefresh index 23501a2..30893c6 100755 --- a/hampackrefresh +++ b/hampackrefresh @@ -20,6 +20,6 @@ EOF clear print_logo -echo "Let's get the lastest changes to HamPack..." +echo "Let's ensure we get the lastest changes to HamPack..." wget -qO- https://gitea.young.computer/david/hampack/raw/branch/main/install.sh | bash diff --git a/hampackupdate b/hampackupdate index dca4ae5..3f23002 100755 --- a/hampackupdate +++ b/hampackupdate @@ -7,11 +7,11 @@ print_logo() { ██╗ ██╗ █████╗ ███╗ ███╗██████╗ █████╗ ██████╗██╗ ██╗ ██║ ██║██╔══██╗████╗ ████║██╔══██╗██╔══██╗██╔════╝██║ ██╔╝ - ███████║███████║██╔████╔██║██████╔╝███████║██║ █████╔╝ - ██╔══██║██╔══██║██║╚██╔╝██║██╔═══╝ ██╔══██║██║ ██╔═██╗ + ███████║███████║██╔████╔██║██████╔╝███████║██║ █████╔╝ + ██╔══██║██╔══██║██║╚██╔╝██║██╔═══╝ ██╔══██║██║ ██╔═██╗ ██║ ██║██║ ██║██║ ╚═╝ ██║██║ ██║ ██║╚██████╗██║ ██╗ - ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ - + ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ + EOF } @@ -41,10 +41,180 @@ else fi HAMPACK_DIR="$HOME/.local/share/HamPack" +VERSION_FILE="$HOME/.local/state/HamPack/.installed_versions" +COMPILE_CONF="$HAMPACK_DIR/compile.conf" +BINARIES_CONF="$HAMPACK_DIR/binaries.conf" echo "Pulling latest HamPack configuration..." git -C "$HAMPACK_DIR" pull +# ── GitHub version helpers ──────────────────────────────────────────────────── + +github_repo_from_url() { + local url="$1" + if [[ "$url" =~ github\.com/([^/]+)/([^/]+) ]]; then + echo "${BASH_REMATCH[1]}/${BASH_REMATCH[2]%.git}" + fi +} + +github_latest() { + local repo="$1" + curl -sf "https://api.github.com/repos/$repo/releases/latest" \ + | grep '"tag_name"' \ + | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/' \ + | sed 's/^v//' +} + +installed_version() { + local app="$1" + grep "^$app=" "$VERSION_FILE" 2>/dev/null | cut -d'=' -f2 +} + +# Update version= for an app in a conf file +set_conf_version() { + local conf="$1" app="$2" new_version="$3" + awk -v app="$app" -v ver="$new_version" ' + /^\[/ { in_app = ($0 == "[" app "]") } + in_app && /^version=/ { print "version=" ver; next } + { print } + ' "$conf" > "$conf.tmp" && mv "$conf.tmp" "$conf" +} + +# ── Check compiled apps (compile.conf) ─────────────────────────────────────── + +check_compiled() { + echo "" + echo "Checking compiled application versions..." + local app="" version="" git_url="" wget_url="" + + while IFS= read -r line || [ -n "$line" ]; do + [[ -z "$line" || "$line" == \#* ]] && continue + + if [[ "$line" =~ ^\[(.+)\]$ ]]; then + _check_compiled_app "$app" "$version" "$git_url" "$wget_url" + app="${BASH_REMATCH[1]}" version="" git_url="" wget_url="" + continue + fi + + local key="${line%%=*}" value="${line#*=}" + case "$key" in + version) version="$value" ;; + git) git_url="$value" ;; + wget) wget_url="$value" ;; + esac + done < "$COMPILE_CONF" + + _check_compiled_app "$app" "$version" "$git_url" "$wget_url" +} + +_check_compiled_app() { + local app="$1" version="$2" git_url="$3" wget_url="$4" + [ -z "$app" ] && return + + local source_url="${git_url:-$wget_url}" + local gh_repo + gh_repo=$(github_repo_from_url "$source_url") + + if [ -z "$gh_repo" ]; then + echo " $app: manual check needed: $source_url" + return + fi + + local latest + latest=$(github_latest "$gh_repo") + + if [ -z "$latest" ]; then + echo " $app: GitHub API unavailable, skipping" + return + fi + + local installed + installed=$(installed_version "$app") + local current="${installed:-$version}" + + if [ "$current" = "$latest" ]; then + echo " $app: up to date ($current)" + return + fi + + echo " $app: $current -> $latest" + + if [ -n "$git_url" ]; then + # git= apps: update version in conf and clear installed record so + # install-compiled.sh rebuilds from the freshly cloned HEAD + set_conf_version "$COMPILE_CONF" "$app" "$latest" + sed -i "/^$app=/d" "$VERSION_FILE" 2>/dev/null + echo " $app: queued for rebuild" + else + echo " $app: update available but URL is version-specific — update compile.conf manually" + fi +} + +# ── Check binary apps (binaries.conf) ──────────────────────────────────────── + +check_binaries() { + echo "" + echo "Checking binary application versions..." + local app="" version="" url="" + + while IFS= read -r line || [ -n "$line" ]; do + [[ -z "$line" || "$line" == \#* ]] && continue + + if [[ "$line" =~ ^\[(.+)\]$ ]]; then + _check_binary_app "$app" "$version" "$url" + app="${BASH_REMATCH[1]}" version="" url="" + continue + fi + + local key="${line%%=*}" value="${line#*=}" + case "$key" in + version) version="$value" ;; + url) url="$value" ;; + esac + done < "$BINARIES_CONF" + + _check_binary_app "$app" "$version" "$url" +} + +_check_binary_app() { + local app="$1" version="$2" url="$3" + [ -z "$app" ] && return + + local gh_repo + gh_repo=$(github_repo_from_url "$url") + + if [ -z "$gh_repo" ]; then + echo " $app: manual check needed: $url" + return + fi + + local latest + latest=$(github_latest "$gh_repo") + + if [ -z "$latest" ]; then + echo " $app: GitHub API unavailable, skipping" + return + fi + + local installed + installed=$(installed_version "$app") + local current="${installed:-$version}" + + if [ "$current" = "$latest" ]; then + echo " $app: up to date ($current)" + else + echo " $app: update available ($current -> $latest) — update binaries.conf to install" + fi +} + +# ── Main ───────────────────────────────────────────────────────────────────── + +mkdir -p "$HOME/.local/state/HamPack" + +check_compiled +check_binaries + +echo "" echo "Installing any new packages..." source "$HAMPACK_DIR/utils.sh" source "$HAMPACK_DIR/packages.conf"