From 0210db6e34b01044e8b50ed82abd76892fc379ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 14 Sep 2023 14:36:02 +0200 Subject: [PATCH] ci: cache: Install ORAS in the kata-deploy binaries builder container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ORAS is the tool which will help us to deal with our artefacts being pushed to and pulled from a container registry. As both the push to and the pull from will be done inside the kata-deploy binaries builder container, we need it installed there. Signed-off-by: Fabiano FidĂȘncio (cherry picked from commit be2eb7b378ee1cc79fe7b5a3a71a2a1a12a21759) --- .../local-build/dockerbuild/Dockerfile | 4 +- .../local-build/dockerbuild/install_oras.sh | 49 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 tools/packaging/kata-deploy/local-build/dockerbuild/install_oras.sh diff --git a/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile b/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile index 51e7ba4311..a29514968b 100644 --- a/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile +++ b/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile @@ -7,10 +7,11 @@ ENV DEBIAN_FRONTEND=noninteractive ENV INSTALL_IN_GOPATH=false COPY install_yq.sh /usr/bin/install_yq.sh +COPY install_oras.sh /usr/bin/install_oras.sh SHELL ["/bin/bash", "-o", "pipefail", "-c"] -# Install yq and docker +# Install yq, oras, and docker RUN apt-get update && \ apt-get install -y --no-install-recommends \ ca-certificates \ @@ -18,6 +19,7 @@ RUN apt-get update && \ sudo && \ apt-get clean && rm -rf /var/lib/apt/lists/ && \ install_yq.sh && \ + install_oras.sh && \ curl -fsSL https://get.docker.com -o get-docker.sh && \ if uname -m | grep -Eq 's390x|ppc64le'; then export VERSION="v20.10" && \ sed -i 's/\//g' get-docker.sh; fi && \ diff --git a/tools/packaging/kata-deploy/local-build/dockerbuild/install_oras.sh b/tools/packaging/kata-deploy/local-build/dockerbuild/install_oras.sh new file mode 100755 index 0000000000..973a102050 --- /dev/null +++ b/tools/packaging/kata-deploy/local-build/dockerbuild/install_oras.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# Copyright (c) 2023 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -o errexit +set -o nounset +set -o pipefail + +install_dest="/usr/local/bin" + +function get_installed_oras_version() { + oras version | grep Version | sed -e s/Version:// | tr -d [:blank:] +} + +oras_required_version="v1.1.0" +if command -v oras; then + if [[ "${oras_required_version}" == "v$(get_installed_oras_version)" ]]; then + echo "ORAS is already installed in the system" + exit 0 + fi + + echo "Proceeding to cleanup the previous installed version of ORAS, and install the version specified in the versions.yaml file" + oras_system_path=$(which oras) + sudo rm -f ${oras_system_path} +fi + +arch=$(uname -m) +if [ "${arch}" = "ppc64le" ]; then + echo "An ORAS release for ppc64le is not available yet." + exit 0 +fi +if [ "${arch}" = "x86_64" ]; then + arch="amd64" +fi +if [ "${arch}" = "aarch64" ]; then + arch="arm64" +fi +oras_tarball="oras_${oras_required_version#v}_linux_${arch}.tar.gz" + +echo "Downloading ORAS ${oras_required_version}" +sudo curl -OL https://github.com/oras-project/oras/releases/download/${oras_required_version}/${oras_tarball} + +echo "Installing ORAS to ${install_dest}" +sudo mkdir -p "${install_dest}" +sudo tar -C "${install_dest}" -xzf "${oras_tarball}" +sudo rm -f "${oras_tarball}"