From fd8dcfffd4eb2a8763b054bff24b13f9ea95eb48 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Sun, 4 Jun 2023 19:06:26 +0200 Subject: [PATCH] fix(fluidd): fall back to latest stable url if fetching tags fails Signed-off-by: Dominik Willner --- scripts/fluidd.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/scripts/fluidd.sh b/scripts/fluidd.sh index 42fda1d..345a1c4 100644 --- a/scripts/fluidd.sh +++ b/scripts/fluidd.sh @@ -341,27 +341,28 @@ function compare_fluidd_versions() { #================================================# function get_fluidd_download_url() { - local fl_tags tags latest_tag latest_url stable_tag stable_url url + local releases_by_tag tags tag unstable_url url - fl_tags="https://api.github.com/repos/fluidd-core/fluidd/tags" - tags=$(curl -s "${fl_tags}" | grep "name" | cut -d'"' -f4) - - ### latest download url including pre-releases (alpha, beta, rc) - latest_tag=$(echo "${tags}" | head -1) - latest_url="https://github.com/fluidd-core/fluidd/releases/download/${latest_tag}/fluidd.zip" - - ### get stable fluidd download url - stable_tag=$(echo "${tags}" | grep -E "^v([0-9]+\.?){3}$" | head -1) - stable_url="https://github.com/fluidd-core/fluidd/releases/download/${stable_tag}/fluidd.zip" + ### latest stable download url + url="https://github.com/fluidd-core/fluidd/releases/latest/download/fluidd.zip" read_kiauh_ini "${FUNCNAME[0]}" if [[ ${fluidd_install_unstable} == "true" ]]; then - url="${latest_url}" - echo "${url}" - else - url="${stable_url}" - echo "${url}" + releases_by_tag="https://api.github.com/repos/fluidd-core/fluidd/tags" + tags=$(curl -s "${releases_by_tag}" | grep "name" | cut -d'"' -f4) + tag=$(echo "${tags}" | head -1) + + ### latest unstable download url including pre-releases (alpha, beta, rc) + unstable_url="https://github.com/fluidd-core/fluidd/releases/download/${tag}/fluidd.zip" + + if [[ ${unstable_url} == *"download//"* ]]; then + warn_msg "Download URL broken! Falling back to URL of latest stable release!" + else + url=${unstable_url} + fi fi + + echo "${url}" } function fluidd_port_check() {