Skip to content

Commit 1c2fec4

Browse files
committed
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.
1 parent 3e8bd5b commit 1c2fec4

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

ci-automation/image_changes.sh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ function prepare_env_vars_and_params_for_release() {
355355
board="${arch}-usr"
356356

357357
new_channel="${ppfr_channel}"
358-
new_channel_prev_version=$(channel_version "${new_channel}" "${board}")
358+
if [[ ${new_channel} = 'lts' ]]; then
359+
new_channel_prev_version=$(lts_channel_version "${ppfr_version_id%%.*}" "${board}")
360+
else
361+
new_channel_prev_version=$(channel_version "${new_channel}" "${board}")
362+
fi
359363
channel_a=''
360364
version_a=''
361365
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() {
516520
}
517521
# --
518522

523+
function lts_channel_version() (
524+
local major=${1}; shift
525+
local board=${1}; shift
526+
527+
local tmp_lts_info tmp_version_txt
528+
tmp_lts_info=$(mktemp)
529+
tmp_version_txt=$(mktemp)
530+
# This function runs in a subshell, so we can have our own scoped
531+
# traps.
532+
trap 'rm "${tmp_lts_info}" "${tmp_version_txt}"' EXIT
533+
curl_to_stdout 'https://lts.release.flatcar-linux.net/lts-info' >"${tmp_lts_info}"
534+
local line tuple lts_major year
535+
while read -r line; do
536+
# each line is major:year:(supported|unsupported)
537+
mapfile -t tuple <<<"${line//:/$'\n'}"
538+
lts_major="${tuple[0]}"
539+
if [[ ${lts_major} = "${major}" ]]; then
540+
year="${tuple[1]}"
541+
break
542+
fi
543+
done <"${tmp_lts_info}"
544+
545+
curl_to_stdout "https://lts.release.flatcar-linux.net/${board}/current-${year}/version.txt" >"${tmp_version_txt}"
546+
source "${tmp_version_txt}"
547+
echo "${FLATCAR_VERSION}"
548+
)
549+
# --
550+
519551
# Gets the latest release for given channel and board. For lts channel
520552
# gets a version of the latest LTS. Runs in a subshell.
521553
function channel_version() (

0 commit comments

Comments
 (0)