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.
This commit is contained in:
Krzesimir Nowak 2023-11-27 11:28:57 +01:00
parent 3e8bd5b8ee
commit 1c2fec4abc

View File

@ -355,7 +355,11 @@ function prepare_env_vars_and_params_for_release() {
board="${arch}-usr" board="${arch}-usr"
new_channel="${ppfr_channel}" new_channel="${ppfr_channel}"
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}") new_channel_prev_version=$(channel_version "${new_channel}" "${board}")
fi
channel_a='' channel_a=''
version_a='' version_a=''
get_channel_a_and_version_a "${new_channel}" "${new_channel_prev_version}" "${ppfr_version}" "${board}" 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 the latest release for given channel and board. For lts channel
# gets a version of the latest LTS. Runs in a subshell. # gets a version of the latest LTS. Runs in a subshell.
function channel_version() ( function channel_version() (