Skip to content

Commit

Permalink
utils: kata-manager: Fix containerd version check
Browse files Browse the repository at this point in the history
Contained release files include the version number without a "v" prefix.
However, the tag for the equivalent release does include it so handle
this distinction and also tighten up the Kata check by specifying an
explicit version number in the regex.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Oct 26, 2023
1 parent 346f195 commit ae3ea14
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions utils/kata-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ github_get_release_file_url()
local url="${1:-}"
local version="${2:-}"

# The version, less any leading 'v'
local version_number
version_number=${version#v}

local arch
arch=$(uname -m)
[ "$arch" = "x86_64" ] && arch="amd64"
Expand All @@ -151,11 +155,11 @@ github_get_release_file_url()

case "$url" in
*kata*)
regex="kata-static-.*-${arch}.tar.xz"
regex="kata-static-${version}-${arch}.tar.xz"
;;

*containerd*)
regex="containerd-.*-linux-${arch}.tar.gz"
regex="containerd-${version_number}-linux-${arch}.tar.gz"
;;

*) die "invalid url: '$url'" ;;
Expand All @@ -165,8 +169,10 @@ github_get_release_file_url()

download_url=$(curl -sL "$url" |\
jq --arg version "$version" \
-r '.[] | select(.tag_name == $version) | .assets[].browser_download_url' |\
grep "/${regex}$")
-r '.[] |
select( (.tag_name == $version) or (.tag_name == "v" + $version) ) |
.assets[].browser_download_url' |\
grep "/${regex}$")

download_url=$(echo "$download_url" | awk '{print $1}')

Expand Down

0 comments on commit ae3ea14

Please sign in to comment.