diff --git a/compile.conf b/compile.conf index 6fa72c3..cbcd4f4 100644 --- a/compile.conf +++ b/compile.conf @@ -38,7 +38,7 @@ steps=/usr/lib/qt6/bin/qmake PREFIX=$HOME/.local "QMAKE_CXXFLAGS+=-Wno-error=sfi [kiwix-tools] version=3.8.2 git=https://github.com/kiwix/kiwix-tools.git -install=$HOME/.local/bin/kiwix-lib +install=$HOME/.local/bin/kiwix-serve steps=sudo chown -R $USER:$USER $HOME/.local/share/man, meson setup build --prefix=$HOME/.local, ninja -C build, ninja -C build install [Dump1090] diff --git a/install-binaries.sh b/install-binaries.sh index c9fd7c0..2681a0f 100755 --- a/install-binaries.sh +++ b/install-binaries.sh @@ -9,6 +9,16 @@ TMP_DIR="/tmp/hampack-build" VERSION_FILE="$HOME/.local/state/HamPack/.installed_versions" FAILED=() +# Expand $HOME, $HAMPACK_DIR and $USER in a config value. Unlike `eval echo`, +# this leaves everything else (semicolons, quotes, spacing) untouched. +expand_vars() { + local v="$1" + v="${v//\$HAMPACK_DIR/"$HAMPACK_DIR"}" + v="${v//\$HOME/"$HOME"}" + v="${v//\$USER/"$USER"}" + printf '%s\n' "$v" +} + # Get the installed version of an app get_installed_version() { local app="$1" @@ -197,7 +207,7 @@ process_conf() { local key="${line%%=*}" local value="${line#*=}" - value=$(eval echo "$value") + value=$(expand_vars "$value") case "$key" in url) url="$value" ;; diff --git a/install-compiled.sh b/install-compiled.sh index 33240c5..bd675b5 100755 --- a/install-compiled.sh +++ b/install-compiled.sh @@ -9,6 +9,16 @@ TMP_DIR="/tmp/hampack-build" VERSION_FILE="$HOME/.local/state/HamPack/.installed_versions" FAILED=() +# Expand $HOME, $HAMPACK_DIR and $USER in a config value. Unlike `eval echo`, +# this leaves everything else (semicolons, quotes, spacing) untouched. +expand_vars() { + local v="$1" + v="${v//\$HAMPACK_DIR/"$HAMPACK_DIR"}" + v="${v//\$HOME/"$HOME"}" + v="${v//\$USER/"$USER"}" + printf '%s\n' "$v" +} + # Get the installed version of an app get_installed_version() { local app="$1" @@ -239,11 +249,11 @@ run_steps() { if [ ! -d "$src_dir" ]; then echo " Error: source directory $src_dir not found." - exit 1 + return 1 fi echo " Changing into $src_dir..." - cd "$src_dir" + cd "$src_dir" || return 1 echo " Building $app..." IFS=',' read -ra step_list <<< "$steps" @@ -251,7 +261,10 @@ run_steps() { step="${step#"${step%%[![:space:]]*}"}" step="${step%"${step##*[![:space:]]}"}" echo " Running: $step" - eval "$step" + if ! eval "$step"; then + echo " Error: step failed: $step" + return 1 + fi done } @@ -294,13 +307,18 @@ process_app() { FAILED+=("$app") return fi - run_steps "$app" "$steps" + # Steps run in this shell (they may `cd`), so return to a safe directory afterwards + if ! run_steps "$app" "$steps"; then + cd "$HOME" || true + echo " Error: build of $app failed; version not recorded, will retry next update." + FAILED+=("$app") + return + fi + cd "$HOME" || true + install_desktop "$desktop" save_installed_version "$app" "$version" - # Return to a safe directory after build - cd "$HOME" - echo " $app $version installed successfully." } @@ -324,13 +342,13 @@ process_conf() { local value="${line#*=}" case "$key" in - git) git_url="$(eval echo "$value")" ;; + git) git_url="$(expand_vars "$value")" ;; ref) ref="$value" ;; - wget) wget_url="$(eval echo "$value")" ;; - install) install_path="$(eval echo "$value")" ;; + wget) wget_url="$(expand_vars "$value")" ;; + install) install_path="$(expand_vars "$value")" ;; steps) steps="$value" ;; version) version="$value" ;; - desktop) desktop="$(eval echo "$value")" ;; + desktop) desktop="$(expand_vars "$value")" ;; gui) gui="$value" ;; esac