installing direwolf fixes

This commit is contained in:
David Young
2026-03-26 13:17:15 -06:00
parent f7569179bf
commit eb69f1876c
7 changed files with 564 additions and 14 deletions

237
install-binaries.sh Executable file
View File

@@ -0,0 +1,237 @@
#!/bin/bash
#
# Purpose: Download and install pre-built binaries from binaries.conf
CONF_FILE="$HOME/.local/share/HamPack/binaries.conf"
TMP_DIR="/tmp/hampack-build"
VERSION_FILE="$HOME/.local/state/HamPack/.installed_versions"
# Get the installed version of an app
get_installed_version() {
local app="$1"
if [ -f "$VERSION_FILE" ]; then
local stored
stored=$(grep "^$app=" "$VERSION_FILE" | cut -d'=' -f2)
if [ -n "$stored" ]; then
echo "$stored"
return
fi
fi
echo "unknown"
}
# Save installed version to version file
save_installed_version() {
local app="$1"
local version="$2"
touch "$VERSION_FILE"
if grep -q "^$app=" "$VERSION_FILE"; then
sed -i "s/^$app=.*/$app=$version/" "$VERSION_FILE"
else
echo "$app=$version" >> "$VERSION_FILE"
fi
}
# Check if an update is needed
needs_update() {
local app="$1"
local install_path="$2"
local latest="$3"
if [ ! -f "$install_path" ]; then
echo " $app is not installed."
return 0
fi
local installed
installed=$(get_installed_version "$app")
if [ "$installed" = "unknown" ]; then
echo " Warning: could not determine installed version of $app."
echo " binaries.conf specifies version $latest."
read -rp " Download and install $app anyway? [y/N] " response
if [[ "$response" =~ ^[yY] ]]; then
return 0
else
return 1
fi
fi
echo " Installed version : $installed"
echo " Latest version : $latest"
if [ "$installed" = "$latest" ]; then
echo " $app is up to date, skipping."
return 1
fi
echo " Update available for $app."
return 0
}
# Download binary and place it at the install path
download_binary() {
local app="$1"
local url="$2"
local install_path="$3"
local filename="${url##*/}"
local tmp_file="$TMP_DIR/$filename"
echo " Downloading $url..."
wget -q "$url" -O "$tmp_file"
mkdir -p "$(dirname "$install_path")"
mv "$tmp_file" "$install_path"
chmod +x "$install_path"
echo " Installed to $install_path"
}
# Generate and install a .desktop file
install_desktop() {
local app="$1"
local install_path="$2"
local exec_cmd="$3"
local comment="$4"
local icon="$5"
local categories="$6"
[ -z "$categories" ] && categories="HamRadio;"
[ -z "$exec_cmd" ] && exec_cmd="$install_path"
local desktop_dir="$HOME/.local/share/applications"
mkdir -p "$desktop_dir"
local desktop_file="$desktop_dir/$app.desktop"
echo " Generating desktop file $desktop_file..."
cat > "$desktop_file" <<EOF
[Desktop Entry]
Type=Application
Name=$app
Exec=$exec_cmd
Comment=$comment
Icon=$icon
Categories=$categories
EOF
chmod +x "$desktop_file"
echo " Desktop file installed."
}
# Process a single app
process_app() {
local app="$1"
local url="$2"
local install_path="$3"
local version="$4"
local gui="$5"
local exec_cmd="$6"
local comment="$7"
local icon="$8"
local categories="$9"
echo ""
echo "=== $app ==="
if [ -z "$url" ]; then
echo " Error: no url specified for $app, skipping."
return
fi
if [ -z "$install_path" ]; then
echo " Error: no install path specified for $app, skipping."
return
fi
if [ -f "$install_path" ]; then
if [ -z "$version" ]; then
echo " $app is already installed, skipping."
return
fi
if ! needs_update "$app" "$install_path" "$version"; then
return
fi
else
echo " $app is not installed."
fi
download_binary "$app" "$url" "$install_path"
if [ "$gui" = "true" ]; then
install_desktop "$app" "$install_path" "$exec_cmd" "$comment" "$icon" "$categories"
fi
if [ -n "$version" ]; then
save_installed_version "$app" "$version"
fi
echo " $app installed successfully."
}
# Parse binaries.conf and process each app
process_conf() {
local app="" url="" install_path="" version="" gui="" exec_cmd="" comment="" icon="" categories=""
while IFS= read -r line || [ -n "$line" ]; do
[[ -z "$line" || "$line" == \#* ]] && continue
if [[ "$line" =~ ^\[(.+)\]$ ]]; then
if [ -n "$app" ]; then
process_app "$app" "$url" "$install_path" "$version" "$gui" "$exec_cmd" "$comment" "$icon" "$categories"
fi
app="${BASH_REMATCH[1]}"
url="" install_path="" version="" gui="" exec_cmd="" comment="" icon="" categories=""
continue
fi
local key="${line%%=*}"
local value="${line#*=}"
value=$(eval echo "$value")
case "$key" in
url) url="$value" ;;
install) install_path="$value" ;;
version) version="$value" ;;
gui) gui="$value" ;;
exec) exec_cmd="$value" ;;
comment) comment="$value" ;;
icon) icon="$value" ;;
categories) categories="$value" ;;
esac
done < "$CONF_FILE"
# Process the last app in the file
if [ -n "$app" ]; then
process_app "$app" "$url" "$install_path" "$version" "$gui" "$exec_cmd" "$comment" "$icon" "$categories"
fi
}
# --- Main ---
if [ ! -f "$CONF_FILE" ]; then
echo "Error: $CONF_FILE not found."
exit 1
fi
mkdir -p "$TMP_DIR"
mkdir -p "$HOME/.local/state/HamPack"
mkdir -p "$HOME/.local/bin"
echo "Starting HamPack binary installs..."
process_conf
echo ""
echo "Updating desktop database..."
update-desktop-database "$HOME/.local/share/applications/"
echo ""
echo "Cleaning up..."
rm -rf "$TMP_DIR"
echo "All done."