@@ -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
@@ -491,11 +495,11 @@ function get_channel_a_and_version_a() {
491495 local -n gcaava_version_a_ref=" ${gcaava_version_a_varname} "
492496 local major_a major_b channel version
493497
494- major_a=$( echo " $ {new_channel_prev_version} " | cut -d . -f 1 )
495- major_b=$( echo " $ {new_channel_new_version} " | cut -d . -f 1 )
498+ major_a=${new_channel_prev_version%% . * }
499+ major_b=${new_channel_new_version%% . * }
496500 # When the major version for the new channel is different, a transition has happened and we can find the previous release in the old channel
497- if [ " ${major_a} " != " ${major_b} " ]; then
498- case " ${new_channel} " in
501+ if [[ ${major_a} != " ${major_b} " ] ]; then
502+ case ${new_channel} in
499503 lts)
500504 channel=stable
501505 ;;
@@ -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.
521553function channel_version() (
@@ -528,17 +560,24 @@ function channel_version() (
528560 # traps.
529561 trap ' rm "${tmp_version_txt}"' EXIT
530562
563+ curl_to_stdout " https://${channel} .release.flatcar-linux.net/${board} /current/version.txt" > " ${tmp_version_txt} "
564+ source " ${tmp_version_txt} "
565+ echo " ${FLATCAR_VERSION} "
566+ )
567+ # --
568+
569+ function curl_to_stdout() {
570+ local url=${1} ; shift
571+
531572 curl \
532573 -fsSL \
533574 --retry-delay 1 \
534575 --retry 60 \
535576 --retry-connrefused \
536577 --retry-max-time 60 \
537578 --connect-timeout 20 \
538- " https://${channel} .release.flatcar-linux.net/${board} /current/version.txt" > " ${tmp_version_txt} "
539- source " ${tmp_version_txt} "
540- echo " ${FLATCAR_VERSION} "
541- )
579+ " ${url} "
580+ }
542581# --
543582
544583# Prints some reports using scripts from the passed path to
0 commit comments