From 1c2fec4abce62ac6688ee7a15b635c21eddb699a Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Mon, 27 Nov 2023 11:28:57 +0100 Subject: [PATCH] ci-automation/image-changes: Get proper version for LTS channel The refactored image changes script will eventually be run for the old LTS version, so make sure that the script for that channel will get a last release of old LTS instead of new LTS. --- ci-automation/image_changes.sh | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ci-automation/image_changes.sh b/ci-automation/image_changes.sh index d5ffa74752..6af4be47eb 100644 --- a/ci-automation/image_changes.sh +++ b/ci-automation/image_changes.sh @@ -355,7 +355,11 @@ function prepare_env_vars_and_params_for_release() { board="${arch}-usr" new_channel="${ppfr_channel}" - new_channel_prev_version=$(channel_version "${new_channel}" "${board}") + if [[ ${new_channel} = 'lts' ]]; then + new_channel_prev_version=$(lts_channel_version "${ppfr_version_id%%.*}" "${board}") + else + new_channel_prev_version=$(channel_version "${new_channel}" "${board}") + fi channel_a='' version_a='' get_channel_a_and_version_a "${new_channel}" "${new_channel_prev_version}" "${ppfr_version}" "${board}" channel_a version_a @@ -516,6 +520,34 @@ function get_channel_a_and_version_a() { } # -- +function lts_channel_version() ( + local major=${1}; shift + local board=${1}; shift + + local tmp_lts_info tmp_version_txt + tmp_lts_info=$(mktemp) + tmp_version_txt=$(mktemp) + # This function runs in a subshell, so we can have our own scoped + # traps. + trap 'rm "${tmp_lts_info}" "${tmp_version_txt}"' EXIT + curl_to_stdout 'https://lts.release.flatcar-linux.net/lts-info' >"${tmp_lts_info}" + local line tuple lts_major year + while read -r line; do + # each line is major:year:(supported|unsupported) + mapfile -t tuple <<<"${line//:/$'\n'}" + lts_major="${tuple[0]}" + if [[ ${lts_major} = "${major}" ]]; then + year="${tuple[1]}" + break + fi + done <"${tmp_lts_info}" + + curl_to_stdout "https://lts.release.flatcar-linux.net/${board}/current-${year}/version.txt" >"${tmp_version_txt}" + source "${tmp_version_txt}" + echo "${FLATCAR_VERSION}" +) +# -- + # Gets the latest release for given channel and board. For lts channel # gets a version of the latest LTS. Runs in a subshell. function channel_version() (