Source version.txt to get version information

This guards against possible quotes.
This commit is contained in:
Krzesimir Nowak 2023-10-12 15:39:20 +02:00
parent b54e9a6733
commit b313a9e42b
5 changed files with 17 additions and 19 deletions

View File

@ -49,7 +49,7 @@ case "${channel_name}" in
;;
alpha|beta|stable|lts)
link="https://${channel_name}.release.flatcar-linux.net/amd64-usr/current"
major=$(curl -sSL "${link}/version.txt" | awk -F= '/FLATCAR_BUILD=/{ print $2 }')
major=$(source <(curl -sSL "${link}/version.txt"); echo "${FLATCAR_BUILD}")
branch="flatcar-${major}"
;;
*)

View File

@ -40,7 +40,7 @@ jobs:
fi
rm -f lts-info
else
major=$(curl -fsSL --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 https://${{ matrix.branch }}.release.flatcar-linux.net/amd64-usr/current/version.txt | awk -F= '/FLATCAR_BUILD=/{ print $2 }')
major=$(source <(curl -fsSL --retry-delay 1 --retry 60 --retry-connrefused --retry-max-time 60 --connect-timeout 20 https://${{ matrix.branch }}.release.flatcar-linux.net/amd64-usr/current/version.txt); echo "${FLATCAR_BUILD}")
branch="flatcar-${major}"
fi
echo "BRANCH=${branch}" >>"${GITHUB_OUTPUT}"

View File

@ -42,9 +42,7 @@ if [[ "${CHANNEL}" = 'main' ]]; then
fi
# Pin the docker image version to that of the latest release in the channel.
docker_sdk_vernum="$(curl -s -S -f -L "${MIRROR_LINK}/version.txt" \
| grep -m 1 FLATCAR_SDK_VERSION= | cut -d = -f 2- \
)"
docker_sdk_vernum=$(source <(curl -s -S -f -L "${MIRROR_LINK}/version.txt"); echo "${FLATCAR_SDK_VERSION}")
docker_image_from_registry_or_buildcache "${sdk_name}" "${docker_sdk_vernum}"

View File

@ -235,21 +235,21 @@ function get_channel_a_and_version_a() {
# --
# Gets the latest release for given channel and board. For lts channel
# gets a version of the latest LTS.
function channel_version() {
# gets a version of the latest LTS. Runs in a subshell.
function channel_version() (
local channel=${1}; shift
local board=${1}; shift
curl \
-fsSL \
--retry-delay 1 \
--retry 60 \
--retry-connrefused \
--retry-max-time 60 \
--connect-timeout 20 \
"https://${channel}.release.flatcar-linux.net/${board}/current/version.txt" | \
grep -m 1 'FLATCAR_VERSION=' | cut -d = -f 2-
}
source <(curl \
-fsSL \
--retry-delay 1 \
--retry 60 \
--retry-connrefused \
--retry-max-time 60 \
--connect-timeout 20 \
"https://${channel}.release.flatcar-linux.net/${board}/current/version.txt")
echo "${FLATCAR_VERSION}"
)
# --
# Prints some reports using scripts from the passed path to

View File

@ -268,8 +268,8 @@ load_environment_var() {
local file="$1" name value
shift
for name in "$@"; do
value=$(grep "^${name}=" "${file}" | sed 's|"||g')
[[ -n "${value}" ]] && export "${value}"
value=$(source "${file}"; echo "${!name}")
[[ -n "${value}" ]] && export "${name}=${value}"
done
}