From c9b291509d865e51994c75de4b08f8eb9fcab815 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 19 May 2022 14:33:13 +0100 Subject: [PATCH 1/5] snap: Fix whitespace Remove trailing space. Signed-off-by: James O. D. Hunt --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 06f2899b6..68d9369fb 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -321,7 +321,7 @@ parts: after: [godeps] override-build: | arch=$(uname -m) - if [ "{$arch}" == "aarch64" ] || [ "${arch}" == "x64_64" ]; then + if [ "{$arch}" == "aarch64" ] || [ "${arch}" == "x64_64" ]; then sudo apt-get -y update sudo apt-get -y install ca-certificates curl gnupg lsb-release curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg From 43de5440e5cab6ef337c1943cfc6ebd9d6b6b545 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 19 May 2022 14:34:34 +0100 Subject: [PATCH 2/5] snap: Fix unbound variable error Don't assume `GITHUB_REF` is set. Signed-off-by: James O. D. Hunt --- snap/snapcraft.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 68d9369fb..be13a7314 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -21,8 +21,8 @@ parts: version="9999" kata_url="https://github.com/kata-containers/kata-containers" - if echo "${GITHUB_REF}" | grep -q -E "^refs/tags"; then - version=$(echo ${GITHUB_REF} | cut -d/ -f3) + if echo "${GITHUB_REF:-}" | grep -q -E "^refs/tags"; then + version=$(echo ${GITHUB_REF:-} | cut -d/ -f3) git checkout ${version} fi From d7b4ce049ec56539743c5c41dcdc8a56ca98471a Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 19 May 2022 14:35:35 +0100 Subject: [PATCH 3/5] snap: Remove unused variable Remove the unused `kata_url` variable and use the value in the `website` YAML metadata instead. Signed-off-by: James O. D. Hunt --- snap/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index be13a7314..b5f5815b5 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,4 +1,5 @@ name: kata-containers +website: https://github.com/kata-containers/kata-containers summary: Build lightweight VMs that seamlessly plug into the containers ecosystem description: | Kata Containers is an open source project and community working to build a @@ -19,7 +20,6 @@ parts: - git-extras override-pull: | version="9999" - kata_url="https://github.com/kata-containers/kata-containers" if echo "${GITHUB_REF:-}" | grep -q -E "^refs/tags"; then version=$(echo ${GITHUB_REF:-} | cut -d/ -f3) From 27d903b76a76ce7c1b5dcbbafbfbadb8b421d2c3 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Thu, 19 May 2022 14:38:01 +0100 Subject: [PATCH 4/5] snap: Put the yq binary in the staging bin directory Rather than putting the `yq` binary in the staging directory itself, put it in the `bin/` sub-directory. Signed-off-by: James O. D. Hunt --- snap/snapcraft.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index b5f5815b5..e2dea40f6 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -46,7 +46,8 @@ parts: # put everything in stage cd ${SNAPCRAFT_STAGE} - yq_path="./yq" + mkdir -p "${SNAPCRAFT_STAGE}/bin/" + yq_path="${SNAPCRAFT_STAGE}/bin/yq" yq_pkg="github.com/mikefarah/yq" goos="linux" case "$(uname -m)" in @@ -82,7 +83,7 @@ parts: override-build: | [ "$(uname -m)" = "ppc64le" ] || [ "$(uname -m)" = "s390x" ] && sudo apt-get --no-install-recommends install -y protobuf-compiler - yq=${SNAPCRAFT_STAGE}/yq + yq=${SNAPCRAFT_STAGE}/bin/yq # set GOPATH export GOPATH=${SNAPCRAFT_STAGE}/gopath @@ -185,7 +186,7 @@ parts: - bison - flex override-build: | - yq=${SNAPCRAFT_STAGE}/yq + yq=${SNAPCRAFT_STAGE}/bin/yq export PATH="${PATH}:${SNAPCRAFT_STAGE}" export GOPATH=${SNAPCRAFT_STAGE}/gopath kata_dir=${GOPATH}/src/github.com/${SNAPCRAFT_PROJECT_NAME}/${SNAPCRAFT_PROJECT_NAME} @@ -249,7 +250,7 @@ parts: - libselinux1-dev - ninja-build override-build: | - yq=${SNAPCRAFT_STAGE}/yq + yq=${SNAPCRAFT_STAGE}/bin/yq export GOPATH=${SNAPCRAFT_STAGE}/gopath export GO111MODULE="auto" kata_dir=${GOPATH}/src/github.com/${SNAPCRAFT_PROJECT_NAME}/${SNAPCRAFT_PROJECT_NAME} From 49361749ed3b85c812150b94fd1ae5498bcb20f5 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Mon, 23 May 2022 10:34:56 +0100 Subject: [PATCH 5/5] snap: Build and package rust version of virtiofsd Update the snap config file to build the rust version of `virtiofsd` for x86_64, but build QEMU's C version for other platforms. Fixes: #4261. Signed-off-by: James O. D. Hunt --- snap/snapcraft.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index e2dea40f6..94fd2a8c9 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -317,6 +317,41 @@ parts: # Hack: move qemu to / "snap/kata-containers/current/": "./" + virtiofsd: + plugin: nil + after: [godeps] + override-build: | + # Currently, only one platform uses the new rust virtiofsd. The + # others make use of QEMU's C implementation. + # + # See "tools/packaging/scripts/configure-hypervisor.sh". + if [ "$(uname -m)" = 'x86_64' ] + then + echo "INFO: Building rust version of virtiofsd" + else + echo "INFO: Building QEMU's C version of virtiofsd" + # Handled by the 'qemu' part, so nothing more to do here. + exit 0 + fi + + # put everything in stage + cd ${SNAPCRAFT_STAGE} + + export PATH="$PATH:${SNAPCRAFT_STAGE}/bin" + export GOPATH=${SNAPCRAFT_STAGE}/gopath + + kata_dir=${GOPATH}/src/github.com/${SNAPCRAFT_PROJECT_NAME}/${SNAPCRAFT_PROJECT_NAME} + cd "${kata_dir}" + # Download the rust implementation of virtiofsd + tools/packaging/static-build/virtiofsd/build-static-virtiofsd.sh + sudo install \ + --owner='root' \ + --group='root' \ + --mode=0755 \ + -D \ + --target-directory="${SNAPCRAFT_PART_INSTALL}/usr/libexec/" \ + virtiofsd/virtiofsd + cloud-hypervisor: plugin: nil after: [godeps]