diff --git a/compile.conf b/compile.conf index a3741f1..064d34c 100644 --- a/compile.conf +++ b/compile.conf @@ -7,6 +7,7 @@ steps=cd src && make && make hamclock-web-1600x960 && mkdir -p $HOME/.local/bin [openhamclock] version=26.1.3 +type=npm git=https://github.com/accius/openhamclock.git install=$HOME/.local/bin/openhamclock steps=npm ci| cp .env.example .env| sudo rm -rf $HOME/.local/bin/openhamclock && mkdir -p $HOME/.local/bin/openhamclock && cp -r . $HOME/.local/bin/openhamclock diff --git a/install-compiled.sh b/install-compiled.sh index f562047..b5065cc 100755 --- a/install-compiled.sh +++ b/install-compiled.sh @@ -11,6 +11,18 @@ VERSION_FILE="$HOME/.local/state/HamPackServer/.installed_versions" get_installed_version() { local app="$1" local gui="$2" + local type="$3" + local install_path="$4" + + # For npm apps, read version from package.json in the install directory + if [ "$type" = "npm" ] && [ -f "$install_path/package.json" ]; then + local ver + ver=$(grep -m1 '"version"' "$install_path/package.json" | grep -oP '\d+\.\d+[\.\d]*') + if [ -n "$ver" ]; then + echo "$ver" + return + fi + fi # Skip --version check for GUI apps as it would launch them if [ "$gui" != "true" ]; then @@ -68,15 +80,16 @@ needs_update() { local install_path="$2" local latest="$3" local gui="$4" + local type="$5" # Not installed at all - if ! command -v "$app" &> /dev/null && [ ! -f "$install_path" ]; then + if ! command -v "$app" &> /dev/null && [ ! -f "$install_path" ] && [ ! -d "$install_path" ]; then echo " $app is not installed." return 0 fi local installed - installed=$(get_installed_version "$app" "$gui") + installed=$(get_installed_version "$app" "$gui" "$type" "$install_path") if [ "$installed" = "unknown" ]; then if ask_user_proceed "$app" "$latest"; then @@ -224,12 +237,13 @@ process_app() { local version="$6" local desktop="$7" local gui="$8" + local type="$9" echo "" echo "=== $app ===" # Check if already installed - if command -v "$app" &> /dev/null || [ -f "$install_path" ]; then + if command -v "$app" &> /dev/null || [ -f "$install_path" ] || [ -d "$install_path" ]; then if [ -z "$version" ]; then echo " $app is already installed, skipping." return @@ -243,7 +257,7 @@ process_app() { echo " Skipping $app." return fi - elif ! needs_update "$app" "$install_path" "$version" "$gui"; then + elif ! needs_update "$app" "$install_path" "$version" "$gui" "$type"; then return fi @@ -264,8 +278,9 @@ process_conf() { # Collect all app configs into parallel arrays first, so stdin is # free for interactive prompts when process_app runs afterwards - local -a all_apps all_git all_wget all_install all_steps all_versions all_desktops all_guis + local -a all_apps all_git all_wget all_install all_steps all_versions all_desktops all_guis all_types local idx=0 + local type="" while IFS= read -r line || [ -n "$line" ]; do [[ -z "$line" || "$line" == \#* ]] && continue @@ -275,10 +290,11 @@ process_conf() { all_apps[$idx]="$app"; all_git[$idx]="$git_url"; all_wget[$idx]="$wget_url" all_install[$idx]="$install_path"; all_steps[$idx]="$steps" all_versions[$idx]="$version"; all_desktops[$idx]="$desktop"; all_guis[$idx]="$gui" + all_types[$idx]="$type" idx=$((idx + 1)) fi app="${BASH_REMATCH[1]}" - git_url="" wget_url="" install_path="" steps="" version="" desktop="" gui="" + git_url="" wget_url="" install_path="" steps="" version="" desktop="" gui="" type="" continue fi @@ -300,6 +316,7 @@ process_conf() { version) version="$value" ;; desktop) desktop="$value" ;; gui) gui="$value" ;; + type) type="$value" ;; esac done < "$CONF_FILE" @@ -309,13 +326,15 @@ process_conf() { all_apps[$idx]="$app"; all_git[$idx]="$git_url"; all_wget[$idx]="$wget_url" all_install[$idx]="$install_path"; all_steps[$idx]="$steps" all_versions[$idx]="$version"; all_desktops[$idx]="$desktop"; all_guis[$idx]="$gui" - ((idx++)) + all_types[$idx]="$type" + idx=$((idx + 1)) fi # Now process each app — stdin is the terminal, so read -rp works for ((i=0; i