snap: clh: Re-use kata-deploy script here

The current snap build for clh is broken as it's not aware of how to
build the binary from sources.

Instead of fixing it here, let's take advantage of the kata-deploy
script, which is capable of building from sources, and re-use it here.

Fixes: #3693

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2022-02-20 20:16:30 +01:00
parent f31125fe92
commit a67b93bb03

View File

@ -320,17 +320,20 @@ parts:
plugin: nil plugin: nil
after: [godeps] after: [godeps]
override-build: | override-build: |
export GOPATH=${SNAPCRAFT_STAGE}/gopath sudo apt-get -y update
yq=${SNAPCRAFT_STAGE}/yq sudo apt-get -y install ca-certificates curl gnupg lsb-release
kata_dir=${GOPATH}/src/github.com/${SNAPCRAFT_PROJECT_NAME}/${SNAPCRAFT_PROJECT_NAME} curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
versions_file="${kata_dir}/versions.yaml" echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
version="$(${yq} r ${versions_file} assets.hypervisor.cloud_hypervisor.version)" sudo apt-get -y update
url="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/${version}" sudo apt-get -y install docker-ce docker-ce-cli containerd.io
curl -L ${url}/cloud-hypervisor-static -o cloud-hypervisor sudo systemctl start docker.socket
curl -LO ${url}/clh-remote
install -D cloud-hypervisor ${SNAPCRAFT_PART_INSTALL}/usr/bin/cloud-hypervisor export GOPATH=${SNAPCRAFT_STAGE}/gopath
install -D clh-remote ${SNAPCRAFT_PART_INSTALL}/usr/bin/clh-remote kata_dir=${GOPATH}/src/github.com/${SNAPCRAFT_PROJECT_NAME}/${SNAPCRAFT_PROJECT_NAME}
cd ${kata_dir}
sudo -E NO_TTY=true make cloud-hypervisor-tarball
tar xvJpf build/kata-static-cloud-hypervisor.tar.xz -C /tmp/
install -D /tmp/opt/kata/bin/cloud-hypervisor ${SNAPCRAFT_PART_INSTALL}/usr/bin/cloud-hypervisor
apps: apps:
runtime: runtime: