tools: add script to pull virtiofsd

Right now this is very much x86_64 specific, but I'd like to count on
the maintainers of the other architectures to expand it.

Also, the name as it's now may be misleading, as we're actually only
pulling the binary that's statically built using `musl` and released as
part of virtiofsd official releases.  But we'll need to build it for the
other architectures, thus I'm following the naming of the scripts used
by the other components.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2022-05-11 19:32:29 +02:00
parent dbedea5086
commit 8e2042d055

View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# Copyright (c) 2022 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
set -o errexit
set -o nounset
set -o pipefail
ARCH=$(uname -m)
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/../../scripts/lib.sh"
virtiofsd_version="${virtiofsd_version:-}"
[ -n "$virtiofsd_version" ] || virtiofsd_version=$(get_from_kata_deps "externals.virtiofsd.version")
[ -n "$virtiofsd_version" ] || die "failed to get virtiofsd version"
if [ "${ARCH}" != "x86_64" ]; then
info "Only x86_64 binaries are distributed as part of the virtiofsd releases" && exit 1
fi
pull_virtiofsd_released_binary() {
info "Download virtiofsd version: ${virtiofsd_version}"
virtiofsd_zip=$(get_from_kata_deps "externals.virtiofsd.meta.binary")
[ -n "${virtiofsd_zip}" ] || die "failed to get virtiofsd binary URL"
mkdir -p virtiofsd
pushd virtiofsd
curl --fail -L ${virtiofsd_zip} -o virtiofsd.zip || return 1
unzip virtiofsd.zip
mv -f target/x86_64-unknown-linux-musl/release/virtiofsd virtiofsd
chmod +x virtiofsd
rm -rf target
rm virtiofsd.zip
popd
}
pull_virtiofsd_released_binary