utils: Fix containerd installation

Fix bug introduced inadvertently on #3330 which fixes the Kata
installation, but unfortunately breaks installing containerd.

The new approach is to check that the download URL matches a
project-specific regular expression.

Also improves the architecture test to handle the containerd
architecture name (`amd64` rather than `x86_64`).

Fixes: #3674.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2022-02-15 13:31:30 +00:00
parent ae21fcc799
commit 601be4e63b

View File

@ -136,16 +136,31 @@ github_get_release_file_url()
local url="${1:-}" local url="${1:-}"
local version="${2:-}" local version="${2:-}"
download_urls=$(curl -sL "$url" |\ local arch=$(uname -m)
local regex=""
case "$url" in
*kata*)
regex="kata-static-.*-${arch}.tar.xz"
;;
*containerd*)
[ "$arch" = "x86_64" ] && arch="amd64"
regex="containerd-.*-linux-${arch}.tar.gz"
;;
*) die "invalid url: '$url'" ;;
esac
local download_url
download_url=$(curl -sL "$url" |\
jq --arg version "$version" \ jq --arg version "$version" \
-r '.[] | select(.tag_name == $version) | .assets[].browser_download_url' |\ -r '.[] | select(.tag_name == $version) | .assets[].browser_download_url' |\
grep static) grep "/${regex}$")
[ -z "$download_urls" ] && die "Cannot determine download URL for version $version ($url)" [ -z "$download_url" ] && die "Cannot determine download URL for version $version ($url)"
local arch=$(uname -m)
local download_url=$(grep "$arch" <<< "$download_urls")
[ -z "$download_url" ] && die "No release for architecture '$arch' ($url)"
echo "$download_url" echo "$download_url"
} }