@@ -355,7 +355,11 @@ function prepare_env_vars_and_params_for_release() {
355
355
board=" ${arch} -usr"
356
356
357
357
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
359
363
channel_a=' '
360
364
version_a=' '
361
365
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() {
491
495
local -n gcaava_version_a_ref=" ${gcaava_version_a_varname} "
492
496
local major_a major_b channel version
493
497
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%% . * }
496
500
# 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
499
503
lts)
500
504
channel=stable
501
505
;;
@@ -516,6 +520,34 @@ function get_channel_a_and_version_a() {
516
520
}
517
521
# --
518
522
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
+
519
551
# Gets the latest release for given channel and board. For lts channel
520
552
# gets a version of the latest LTS. Runs in a subshell.
521
553
function channel_version() (
@@ -528,17 +560,24 @@ function channel_version() (
528
560
# traps.
529
561
trap ' rm "${tmp_version_txt}"' EXIT
530
562
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
+
531
572
curl \
532
573
-fsSL \
533
574
--retry-delay 1 \
534
575
--retry 60 \
535
576
--retry-connrefused \
536
577
--retry-max-time 60 \
537
578
--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
+ }
542
581
# --
543
582
544
583
# Prints some reports using scripts from the passed path to
0 commit comments