mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-02 08:17:01 +00:00
Merge pull request #6481 from fidencio/topic/cache-artefacts
packaging / kata-deploy builds: Add the ability to cache and consume cached components
This commit is contained in:
commit
96252db787
@ -43,6 +43,7 @@ RUN apt-get update && \
|
||||
git \
|
||||
make \
|
||||
unzip \
|
||||
wget \
|
||||
xz-utils && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists
|
||||
|
||||
|
@ -32,6 +32,9 @@ readonly nydus_builder="${static_build_dir}/nydus/build.sh"
|
||||
|
||||
readonly rootfs_builder="${repo_root_dir}/tools/packaging/guest-image/build_image.sh"
|
||||
|
||||
readonly jenkins_url="http://jenkins.katacontainers.io"
|
||||
readonly cached_artifacts_path="lastSuccessfulBuild/artifact/artifacts"
|
||||
|
||||
ARCH=$(uname -m)
|
||||
|
||||
workdir="${WORKDIR:-$PWD}"
|
||||
@ -87,14 +90,82 @@ EOF
|
||||
exit "${return_code}"
|
||||
}
|
||||
|
||||
|
||||
cleanup_and_fail() {
|
||||
rm -f "${component_tarball_path}"
|
||||
return 1
|
||||
}
|
||||
|
||||
install_cached_tarball_component() {
|
||||
local component="${1}"
|
||||
local jenkins_build_url="${2}"
|
||||
local current_version="${3}"
|
||||
local current_image_version="${4}"
|
||||
local component_tarball_name="${5}"
|
||||
local component_tarball_path="${6}"
|
||||
|
||||
local cached_version=$(curl -sfL "${jenkins_build_url}/latest" | awk '{print $1}') || cached_version="none"
|
||||
local cached_image_version=$(curl -sfL "${jenkins_build_url}/latest_image" | awk '{print $1}') || cached_image_version="none"
|
||||
|
||||
[ "${cached_image_version}" != "${current_image_version}" ] && return 1
|
||||
[ "${cached_version}" != "${current_version}" ] && return 1
|
||||
|
||||
info "Using cached tarball of ${component}"
|
||||
echo "Downloading tarball from: ${jenkins_build_url}/${component_tarball_name}"
|
||||
wget "${jenkins_build_url}/${component_tarball_name}" || return cleanup_and_fail
|
||||
wget "${jenkins_build_url}/sha256sum-${component_tarball_name}" || return cleanup_and_fail
|
||||
sha256sum -c "sha256sum-${component_tarball_name}" || return cleanup_and_fail
|
||||
mv "${component_tarball_name}" "${component_tarball_path}"
|
||||
}
|
||||
|
||||
#Install guest image
|
||||
install_image() {
|
||||
local jenkins="${jenkins_url}/job/kata-containers-main-rootfs-image-$(uname -m)/${cached_artifacts_path}"
|
||||
local component="rootfs-image"
|
||||
|
||||
local osbuilder_last_commit="$(get_last_modification "${repo_root_dir}/tools/osbuilder")"
|
||||
local guest_image_last_commit="$(get_last_modification "${repo_root_dir}/tools/packaging/guest-image")"
|
||||
local agent_last_commit="$(get_last_modification "${repo_root_dir}/src/agent")"
|
||||
local libs_last_commit="$(get_last_modification "${repo_root_dir}/src/libs")"
|
||||
local gperf_version="$(get_from_kata_deps "externals.gperf.version")"
|
||||
local libseccomp_version="$(get_from_kata_deps "externals.libseccomp.version")"
|
||||
local rust_version="$(get_from_kata_deps "languages.rust.meta.newest-version")"
|
||||
|
||||
install_cached_tarball_component \
|
||||
"${component}" \
|
||||
"${jenkins}" \
|
||||
"${osbuilder_last_commit}-${guest_image_last_commit}-${agent_last_commit}-${libs_last_commit}-${gperf_version}-${libseccomp_version}-${rust_version}-image" \
|
||||
"" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "Create image"
|
||||
"${rootfs_builder}" --imagetype=image --prefix="${prefix}" --destdir="${destdir}"
|
||||
}
|
||||
|
||||
#Install guest initrd
|
||||
install_initrd() {
|
||||
local jenkins="${jenkins_url}/job/kata-containers-main-rootfs-initrd-$(uname -m)/${cached_artifacts_path}"
|
||||
local component="rootfs-initrd"
|
||||
|
||||
local osbuilder_last_commit="$(get_last_modification "${repo_root_dir}/tools/osbuilder")"
|
||||
local guest_image_last_commit="$(get_last_modification "${repo_root_dir}/tools/packaging/guest-image")"
|
||||
local agent_last_commit="$(get_last_modification "${repo_root_dir}/src/agent")"
|
||||
local libs_last_commit="$(get_last_modification "${repo_root_dir}/src/libs")"
|
||||
local gperf_version="$(get_from_kata_deps "externals.gperf.version")"
|
||||
local libseccomp_version="$(get_from_kata_deps "externals.libseccomp.version")"
|
||||
local rust_version="$(get_from_kata_deps "languages.rust.meta.newest-version")"
|
||||
|
||||
install_cached_tarball_component \
|
||||
"${component}" \
|
||||
"${jenkins}" \
|
||||
"${osbuilder_last_commit}-${guest_image_last_commit}-${agent_last_commit}-${libs_last_commit}-${gperf_version}-${libseccomp_version}-${rust_version}-initrd" \
|
||||
"" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "Create initrd"
|
||||
"${rootfs_builder}" --imagetype=initrd --prefix="${prefix}" --destdir="${destdir}"
|
||||
}
|
||||
@ -102,13 +173,35 @@ install_initrd() {
|
||||
#Install kernel asset
|
||||
install_kernel() {
|
||||
export kernel_version="$(yq r $versions_yaml assets.kernel.version)"
|
||||
local kernel_kata_config_version="$(cat ${repo_root_dir}/tools/packaging/kernel/kata_config_version)"
|
||||
|
||||
install_cached_tarball_component \
|
||||
"kernel" \
|
||||
"${jenkins_url}/job/kata-containers-main-kernel-$(uname -m)/${cached_artifacts_path}" \
|
||||
"${kernel_version}-${kernel_kata_config_version}" \
|
||||
"$(get_kernel_image_name)" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
DESTDIR="${destdir}" PREFIX="${prefix}" "${kernel_builder}" -f -v "${kernel_version}"
|
||||
}
|
||||
|
||||
#Install dragonball experimental kernel asset
|
||||
install_dragonball_experimental_kernel() {
|
||||
info "build dragonball experimental kernel"
|
||||
export kernel_version="$(yq r $versions_yaml assets.dragonball-kernel-experimental.version)"
|
||||
export kernel_version="$(yq r $versions_yaml assets.kernel-dragonball-experimental.version)"
|
||||
local kernel_kata_config_version="$(cat ${repo_root_dir}/tools/packaging/kernel/kata_config_version)"
|
||||
|
||||
install_cached_tarball_component \
|
||||
"kernel-dragonball-experimental" \
|
||||
"${jenkins_url}/job/kata-containers-main-kernel-dragonball-experimental-$(uname -m)/${cached_artifacts_path}" \
|
||||
"${kernel_version}-${kernel_kata_config_version}" \
|
||||
"$(get_kernel_image_name)" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "kernel version ${kernel_version}"
|
||||
DESTDIR="${destdir}" PREFIX="${prefix}" "${kernel_builder}" -e -t dragonball -v ${kernel_version}
|
||||
}
|
||||
@ -117,21 +210,51 @@ install_dragonball_experimental_kernel() {
|
||||
install_experimental_kernel() {
|
||||
info "build experimental kernel"
|
||||
export kernel_version="$(yq r $versions_yaml assets.kernel-experimental.tag)"
|
||||
local kernel_kata_config_version="$(cat ${repo_root_dir}/tools/packaging/kernel/kata_config_version)"
|
||||
|
||||
install_cached_tarball_component \
|
||||
"kernel-experimental" \
|
||||
"${jenkins_url}/job/kata-containers-main-kernel-experimental-$(uname -m)/${cached_artifacts_path}" \
|
||||
"${kernel_version}-${kernel_kata_config_version}" \
|
||||
"$(get_kernel_image_name)" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "Kernel version ${kernel_version}"
|
||||
DESTDIR="${destdir}" PREFIX="${prefix}" "${kernel_builder}" -f -b experimental -v ${kernel_version}
|
||||
}
|
||||
|
||||
# Install static qemu asset
|
||||
install_qemu() {
|
||||
info "build static qemu"
|
||||
export qemu_repo="$(yq r $versions_yaml assets.hypervisor.qemu.url)"
|
||||
export qemu_version="$(yq r $versions_yaml assets.hypervisor.qemu.version)"
|
||||
|
||||
install_cached_tarball_component \
|
||||
"QEMU" \
|
||||
"${jenkins_url}/job/kata-containers-main-qemu-$(uname -m)/${cached_artifacts_path}" \
|
||||
"${qemu_version}-$(calc_qemu_files_sha256sum)" \
|
||||
"$(get_qemu_image_name)" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "build static qemu"
|
||||
"${qemu_builder}"
|
||||
tar xvf "${builddir}/kata-static-qemu.tar.gz" -C "${destdir}"
|
||||
}
|
||||
|
||||
# Install static firecracker asset
|
||||
install_firecracker() {
|
||||
install_cached_tarball_component \
|
||||
"firecracker" \
|
||||
"${jenkins_url}/job/kata-containers-main-firecracker-$(uname -m)/${cached_artifacts_path}" \
|
||||
"$(get_from_kata_deps "assets.hypervisor.firecracker.version")" \
|
||||
"" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "build static firecracker"
|
||||
"${firecracker_builder}"
|
||||
info "Install static firecracker"
|
||||
@ -142,6 +265,15 @@ install_firecracker() {
|
||||
|
||||
# Install static cloud-hypervisor asset
|
||||
install_clh() {
|
||||
install_cached_tarball_component \
|
||||
"cloud-hypervisor" \
|
||||
"${jenkins_url}/job/kata-containers-main-clh-$(uname -m)/${cached_artifacts_path}" \
|
||||
"$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version")" \
|
||||
"" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
if [[ "${ARCH}" == "x86_64" ]]; then
|
||||
export features="tdx"
|
||||
fi
|
||||
@ -155,6 +287,15 @@ install_clh() {
|
||||
|
||||
# Install static virtiofsd asset
|
||||
install_virtiofsd() {
|
||||
install_cached_tarball_component \
|
||||
"virtiofsd" \
|
||||
"${jenkins_url}/job/kata-containers-main-virtiofsd-$(uname -m)/${cached_artifacts_path}" \
|
||||
"$(get_from_kata_deps "externals.virtiofsd.version")-$(get_from_kata_deps "externals.virtiofsd.toolchain")" \
|
||||
"$(get_virtiofsd_image_name)" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "build static virtiofsd"
|
||||
"${virtiofsd_builder}"
|
||||
info "Install static virtiofsd"
|
||||
@ -164,6 +305,15 @@ install_virtiofsd() {
|
||||
|
||||
# Install static nydus asset
|
||||
install_nydus() {
|
||||
install_cached_tarball_component \
|
||||
"nydus" \
|
||||
"${jenkins_url}/job/kata-containers-main-nydus-$(uname -m)/${cached_artifacts_path}" \
|
||||
"$(get_from_kata_deps "externals.nydus.version")" \
|
||||
"" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
info "build static nydus"
|
||||
"${nydus_builder}"
|
||||
info "Install static nydus"
|
||||
@ -175,8 +325,22 @@ install_nydus() {
|
||||
|
||||
#Install all components that are not assets
|
||||
install_shimv2() {
|
||||
GO_VERSION="$(yq r ${versions_yaml} languages.golang.meta.newest-version)"
|
||||
RUST_VERSION="$(yq r ${versions_yaml} languages.rust.meta.newest-version)"
|
||||
local shim_v2_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime")"
|
||||
local runtime_rs_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime-rs")"
|
||||
local protocols_last_commit="$(get_last_modification "${repo_root_dir}/src/libs/protocols")"
|
||||
local GO_VERSION="$(get_from_kata_deps "languages.golang.meta.newest-version")"
|
||||
local RUST_VERSION="$(get_from_kata_deps "languages.rust.meta.newest-version")"
|
||||
local shim_v2_version="${shim_v2_last_commit}-${protocols_last_commit}-${runtime_rs_last_commit}-${GO_VERSION}-${RUST_VERSION}"
|
||||
|
||||
install_cached_tarball_component \
|
||||
"shim-v2" \
|
||||
"${jenkins_url}/job/kata-containers-main-shim-v2-$(uname -m)/${cached_artifacts_path}" \
|
||||
"${shim_v2_version}" \
|
||||
"$(get_shim_v2_image_name)" \
|
||||
"${final_tarball_name}" \
|
||||
"${final_tarball_path}" \
|
||||
&& return 0
|
||||
|
||||
export GO_VERSION
|
||||
export RUST_VERSION
|
||||
DESTDIR="${destdir}" PREFIX="${prefix}" "${shimv2_builder}"
|
||||
@ -192,6 +356,11 @@ handle_build() {
|
||||
info "DESTDIR ${destdir}"
|
||||
local build_target
|
||||
build_target="$1"
|
||||
|
||||
export final_tarball_path="${workdir}/kata-static-${build_target}.tar.xz"
|
||||
export final_tarball_name="$(basename ${final_tarball_path})"
|
||||
rm -f ${final_tarball_name}
|
||||
|
||||
case "${build_target}" in
|
||||
all)
|
||||
install_clh
|
||||
@ -232,12 +401,11 @@ handle_build() {
|
||||
;;
|
||||
esac
|
||||
|
||||
tarball_name="${workdir}/kata-static-${build_target}.tar.xz"
|
||||
(
|
||||
if [ ! -f "${final_tarball_path}" ]; then
|
||||
cd "${destdir}"
|
||||
sudo tar cvfJ "${tarball_name}" "."
|
||||
)
|
||||
tar tvf "${tarball_name}"
|
||||
sudo tar cvfJ "${final_tarball_path}" "."
|
||||
fi
|
||||
tar tvf "${final_tarball_path}"
|
||||
}
|
||||
|
||||
silent_mode_error_trap() {
|
||||
|
@ -556,7 +556,7 @@ main() {
|
||||
case "${arch_target}" in
|
||||
"aarch64")
|
||||
build_type="arm-experimental"
|
||||
kernel_version=$(get_from_kata_deps "assets.arm-kernel-experimental.version")
|
||||
kernel_version=$(get_from_kata_deps "assets.kernel-arm-experimental.version")
|
||||
;;
|
||||
*)
|
||||
info "No arch-specific experimental kernel supported, using experimental one instead"
|
||||
@ -564,7 +564,7 @@ main() {
|
||||
;;
|
||||
esac
|
||||
elif [[ ${build_type} == "dragonball-experimental" ]]; then
|
||||
kernel_version=$(get_from_kata_deps "assets.dragonball-kernel-experimental.version")
|
||||
kernel_version=$(get_from_kata_deps "assets.kernel-dragonball-experimental.version")
|
||||
elif [[ "${conf_guest}" != "" ]]; then
|
||||
#If specifying a tag for kernel_version, must be formatted version-like to avoid unintended parsing issues
|
||||
kernel_version=$(get_from_kata_deps "assets.kernel.${conf_guest}.version" 2>/dev/null || true)
|
||||
|
@ -1 +1 @@
|
||||
101
|
||||
102
|
||||
|
@ -106,6 +106,7 @@ get_kata_hash() {
|
||||
get_last_modification() {
|
||||
local file="${1}"
|
||||
|
||||
pushd ${repo_root_dir} &> /dev/null
|
||||
# This is a workaround needed for when running this code on Jenkins
|
||||
git config --global --add safe.directory ${repo_root_dir} &> /dev/null
|
||||
|
||||
@ -113,6 +114,7 @@ get_last_modification() {
|
||||
[ $(git status --porcelain | grep "${file#${repo_root_dir}/}" | wc -l) -gt 0 ] && dirty="-dirty"
|
||||
|
||||
echo "$(git log -1 --pretty=format:"%H" ${file})${dirty}"
|
||||
popd &> /dev/null
|
||||
}
|
||||
|
||||
# $1 - The tag to be pushed to the registry
|
||||
@ -129,3 +131,75 @@ push_to_registry() {
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_kernel_image_name() {
|
||||
kernel_script_dir="${repo_root_dir}/tools/packaging/static-build/kernel"
|
||||
echo "${BUILDER_REGISTRY}:kernel-$(get_last_modification ${kernel_script_dir})-$(uname -m)"
|
||||
}
|
||||
|
||||
sha256sum_from_files() {
|
||||
local files_in=${@:-}
|
||||
local files=""
|
||||
local shasum=""
|
||||
|
||||
# Process the input files:
|
||||
# - discard the files/directories that don't exist.
|
||||
# - find the files if it is a directory
|
||||
for f in $files_in; do
|
||||
if [ -d "$f" ]; then
|
||||
files+=" $(find $f -type f)"
|
||||
elif [ -f "$f" ]; then
|
||||
files+=" $f"
|
||||
fi
|
||||
done
|
||||
# Return in case there is none input files.
|
||||
[ -n "$files" ] || return 0
|
||||
|
||||
# Alphabetically sorting the files.
|
||||
files="$(echo $files | tr ' ' '\n' | LC_ALL=C sort -u)"
|
||||
# Concate the files and calculate a hash.
|
||||
shasum="$(cat $files | sha256sum -b)" || true
|
||||
if [ -n "$shasum" ];then
|
||||
# Return only the SHA field.
|
||||
echo $(awk '{ print $1 }' <<< $shasum)
|
||||
fi
|
||||
}
|
||||
|
||||
calc_qemu_files_sha256sum() {
|
||||
local files="${repo_root_dir}/tools/packaging/qemu \
|
||||
${repo_root_dir}/tools/packaging/static-build/qemu.blacklist \
|
||||
${repo_root_dir}/tools/packaging/static-build/scripts"
|
||||
|
||||
sha256sum_from_files "$files"
|
||||
}
|
||||
|
||||
get_qemu_image_name() {
|
||||
qemu_script_dir="${repo_root_dir}/tools/packaging/static-build/qemu"
|
||||
echo "${BUILDER_REGISTRY}:qemu-$(get_last_modification ${qemu_script_dir})-$(uname -m)"
|
||||
}
|
||||
|
||||
get_shim_v2_image_name() {
|
||||
shim_v2_script_dir="${repo_root_dir}/tools/packaging/static-build/shim-v2"
|
||||
echo "${BUILDER_REGISTRY}:shim-v2-go-$(get_from_kata_deps "languages.golang.meta.newest-version")-rust-$(get_from_kata_deps "languages.rust.meta.newest-version")-$(get_last_modification ${shim_v2_script_dir})-$(uname -m)"
|
||||
}
|
||||
|
||||
get_virtiofsd_image_name() {
|
||||
ARCH=$(uname -m)
|
||||
case ${ARCH} in
|
||||
"aarch64")
|
||||
libc="musl"
|
||||
;;
|
||||
"ppc64le")
|
||||
libc="gnu"
|
||||
;;
|
||||
"s390x")
|
||||
libc="gnu"
|
||||
;;
|
||||
"x86_64")
|
||||
libc="musl"
|
||||
;;
|
||||
esac
|
||||
|
||||
virtiofsd_script_dir="${repo_root_dir}/tools/packaging/static-build/virtiofsd"
|
||||
echo "${BUILDER_REGISTRY}:virtiofsd-$(get_from_kata_deps "externals.virtiofsd.toolchain")-${libc}-$(get_last_modification ${virtiofsd_script_dir})-$(uname -m)"
|
||||
}
|
||||
|
200
tools/packaging/static-build/cache_components_main.sh
Executable file
200
tools/packaging/static-build/cache_components_main.sh
Executable file
@ -0,0 +1,200 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) 2022 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
source "${script_dir}/../scripts/lib.sh"
|
||||
|
||||
KERNEL_FLAVOUR="${KERNEL_FLAVOUR:-kernel}" # kernel | kernel-experimental | kernel-arm-experimetnal | kernel-dragonball-experimental
|
||||
ROOTFS_IMAGE_TYPE="${ROOTFS_IMAGE_TYPE:-image}" # image | initrd
|
||||
|
||||
cache_clh_artifacts() {
|
||||
local clh_tarball_name="kata-static-cloud-hypervisor.tar.xz"
|
||||
local current_clh_version="$(get_from_kata_deps "assets.hypervisor.cloud_hypervisor.version")"
|
||||
create_cache_asset "${clh_tarball_name}" "${current_clh_version}" ""
|
||||
}
|
||||
|
||||
cache_firecracker_artifacts() {
|
||||
local fc_tarball_name="kata-static-firecracker.tar.xz"
|
||||
local current_fc_version="$(get_from_kata_deps "assets.hypervisor.firecracker.version")"
|
||||
create_cache_asset "${fc_tarball_name}" "${current_fc_version}" ""
|
||||
}
|
||||
|
||||
cache_kernel_artifacts() {
|
||||
local kernel_tarball_name="kata-static-${KERNEL_FLAVOUR}.tar.xz"
|
||||
local current_kernel_image="$(get_kernel_image_name)"
|
||||
local current_kernel_kata_config_version="$(cat ${repo_root_dir}/tools/packaging/kernel/kata_config_version)"
|
||||
local current_kernel_version="$(get_from_kata_deps "assets.${KERNEL_FLAVOUR}.version")-${current_kernel_kata_config_version}"
|
||||
create_cache_asset "${kernel_tarball_name}" "${current_kernel_version}" "${current_kernel_image}"
|
||||
}
|
||||
|
||||
cache_nydus_artifacts() {
|
||||
local nydus_tarball_name="kata-static-nydus.tar.xz"
|
||||
local current_nydus_version="$(get_from_kata_deps "externals.nydus.version")"
|
||||
create_cache_asset "${nydus_tarball_name}" "${current_nydus_version}" ""
|
||||
}
|
||||
|
||||
cache_qemu_artifacts() {
|
||||
local qemu_tarball_name="kata-static-qemu.tar.xz"
|
||||
local current_qemu_version=$(get_from_kata_deps "assets.hypervisor.qemu.version")
|
||||
local qemu_sha=$(calc_qemu_files_sha256sum)
|
||||
local current_qemu_image="$(get_qemu_image_name)"
|
||||
create_cache_asset "${qemu_tarball_name}" "${current_qemu_version}-${qemu_sha}" "${current_qemu_image}"
|
||||
}
|
||||
|
||||
cache_rootfs_artifacts() {
|
||||
local osbuilder_last_commit="$(get_last_modification "${repo_root_dir}/tools/osbuilder")"
|
||||
local guest_image_last_commit="$(get_last_modification "${repo_root_dir}/tools/packaging/guest-image")"
|
||||
local agent_last_commit="$(get_last_modification "${repo_root_dir}/src/agent")"
|
||||
local libs_last_commit="$(get_last_modification "${repo_root_dir}/src/libs")"
|
||||
local gperf_version="$(get_from_kata_deps "externals.gperf.version")"
|
||||
local libseccomp_version="$(get_from_kata_deps "externals.libseccomp.version")"
|
||||
local rust_version="$(get_from_kata_deps "languages.rust.meta.newest-version")"
|
||||
local rootfs_tarball_name="kata-static-rootfs-${ROOTFS_IMAGE_TYPE}.tar.xz"
|
||||
local current_rootfs_version="${osbuilder_last_commit}-${guest_image_last_commit}-${agent_last_commit}-${libs_last_commit}-${gperf_version}-${libseccomp_version}-${rust_version}-${ROOTFS_IMAGE_TYPE}"
|
||||
create_cache_asset "${rootfs_tarball_name}" "${current_rootfs_version}" ""
|
||||
}
|
||||
|
||||
cache_shim_v2_artifacts() {
|
||||
local shim_v2_tarball_name="kata-static-shim-v2.tar.xz"
|
||||
local shim_v2_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime")"
|
||||
local protocols_last_commit="$(get_last_modification "${repo_root_dir}/src/libs/protocols")"
|
||||
local runtime_rs_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime-rs")"
|
||||
local golang_version="$(get_from_kata_deps "languages.golang.meta.newest-version")"
|
||||
local rust_version="$(get_from_kata_deps "languages.rust.meta.newest-version")"
|
||||
local current_shim_v2_version="${shim_v2_last_commit}-${protocols_last_commit}-${runtime_rs_last_commit}-${golang_version}-${rust_version}"
|
||||
local current_shim_v2_image="$(get_shim_v2_image_name)"
|
||||
create_cache_asset "${shim_v2_tarball_name}" "${current_shim_v2_version}" "${current_shim_v2_image}"
|
||||
}
|
||||
|
||||
cache_virtiofsd_artifacts() {
|
||||
local virtiofsd_tarball_name="kata-static-virtiofsd.tar.xz"
|
||||
local current_virtiofsd_version="$(get_from_kata_deps "externals.virtiofsd.version")-$(get_from_kata_deps "externals.virtiofsd.toolchain")"
|
||||
local current_virtiofsd_image="$(get_virtiofsd_image_name)"
|
||||
create_cache_asset "${virtiofsd_tarball_name}" "${current_virtiofsd_version}" "${current_virtiofsd_image}"
|
||||
}
|
||||
|
||||
create_cache_asset() {
|
||||
local component_name="${1}"
|
||||
local component_version="${2}"
|
||||
local component_image="${3}"
|
||||
|
||||
sudo cp "${repo_root_dir}/tools/packaging/kata-deploy/local-build/build/${component_name}" .
|
||||
sudo chown -R "${USER}:${USER}" .
|
||||
sha256sum "${component_name}" > "sha256sum-${component_name}"
|
||||
cat "sha256sum-${component_name}"
|
||||
echo "${component_version}" > "latest"
|
||||
cat "latest"
|
||||
echo "${component_image}" > "latest_image"
|
||||
cat "latest_image"
|
||||
}
|
||||
|
||||
help() {
|
||||
echo "$(cat << EOF
|
||||
Usage: $0 "[options]"
|
||||
Description:
|
||||
Builds the cache of several kata components.
|
||||
Options:
|
||||
-c Cloud hypervisor cache
|
||||
-F Firecracker cache
|
||||
-k Kernel cache
|
||||
* Export KERNEL_FLAVOUR="kernel|kernek-experimental|kernel-arm-experimental|kernel-dragonball-experimental" for a specific build
|
||||
The default KERNEL_FLAVOUR value is "kernel"
|
||||
-n Nydus cache
|
||||
-q QEMU cache
|
||||
-r RootFS cache
|
||||
* Export ROOTFS_IMAGE_TYPE="image|initrd" for one of those two types
|
||||
The default ROOTFS_IMAGE_TYPE value is "image"
|
||||
-s Shim v2 cache
|
||||
-v VirtioFS cache
|
||||
-h Shows help
|
||||
EOF
|
||||
)"
|
||||
}
|
||||
|
||||
main() {
|
||||
local cloud_hypervisor_component="${cloud_hypervisor_component:-}"
|
||||
local firecracker_component="${firecracker_component:-}"
|
||||
local kernel_component="${kernel_component:-}"
|
||||
local nydus_component="${nydus_component:-}"
|
||||
local qemu_component="${qemu_component:-}"
|
||||
local rootfs_component="${rootfs_component:-}"
|
||||
local shim_v2_component="${shim_v2_component:-}"
|
||||
local virtiofsd_component="${virtiofsd_component:-}"
|
||||
local OPTIND
|
||||
while getopts ":cFknqrsvh:" opt
|
||||
do
|
||||
case "$opt" in
|
||||
c)
|
||||
cloud_hypervisor_component="1"
|
||||
;;
|
||||
F)
|
||||
firecracker_component="1"
|
||||
;;
|
||||
k)
|
||||
kernel_component="1"
|
||||
;;
|
||||
n)
|
||||
nydus_component="1"
|
||||
;;
|
||||
q)
|
||||
qemu_component="1"
|
||||
;;
|
||||
r)
|
||||
rootfs_component="1"
|
||||
;;
|
||||
s)
|
||||
shim_v2_component="1"
|
||||
;;
|
||||
v)
|
||||
virtiofsd_component="1"
|
||||
;;
|
||||
h)
|
||||
help
|
||||
exit 0;
|
||||
;;
|
||||
:)
|
||||
echo "Missing argument for -$OPTARG";
|
||||
help
|
||||
exit 1;
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
[[ -z "${cloud_hypervisor_component}" ]] && \
|
||||
[[ -z "${firecracker_component}" ]] && \
|
||||
[[ -z "${kernel_component}" ]] && \
|
||||
[[ -z "${nydus_component}" ]] && \
|
||||
[[ -z "${qemu_component}" ]] && \
|
||||
[[ -z "${rootfs_component}" ]] && \
|
||||
[[ -z "${shim_v2_component}" ]] && \
|
||||
[[ -z "${virtiofsd_component}" ]] && \
|
||||
help && die "Must choose at least one option"
|
||||
|
||||
mkdir -p "${WORKSPACE}/artifacts"
|
||||
pushd "${WORKSPACE}/artifacts"
|
||||
echo "Artifacts:"
|
||||
|
||||
[ "${cloud_hypervisor_component}" == "1" ] && cache_clh_artifacts
|
||||
[ "${firecracker_component}" == "1" ] && cache_firecracker_artifacts
|
||||
[ "${kernel_component}" == "1" ] && cache_kernel_artifacts
|
||||
[ "${nydus_component}" == "1" ] && cache_nydus_artifacts
|
||||
[ "${qemu_component}" == "1" ] && cache_qemu_artifacts
|
||||
[ "${rootfs_component}" == "1" ] && cache_rootfs_artifacts
|
||||
[ "${shim_v2_component}" == "1" ] && cache_shim_v2_artifacts
|
||||
[ "${virtiofsd_component}" == "1" ] && cache_virtiofsd_artifacts
|
||||
|
||||
ls -la "${WORKSPACE}/artifacts/"
|
||||
popd
|
||||
sync
|
||||
}
|
||||
|
||||
main "$@"
|
@ -16,7 +16,7 @@ readonly kernel_builder="${repo_root_dir}/tools/packaging/kernel/build-kernel.sh
|
||||
|
||||
DESTDIR=${DESTDIR:-${PWD}}
|
||||
PREFIX=${PREFIX:-/opt/kata}
|
||||
container_image="${KERNEL_CONTAINER_BUILDER:-${BUILDER_REGISTRY}:kernel-$(get_last_modification ${script_dir})-$(uname -m)}"
|
||||
container_image="${KERNEL_CONTAINER_BUILDER:-$(get_kernel_image_name)}"
|
||||
|
||||
sudo docker pull ${container_image} || \
|
||||
(sudo docker build -t "${container_image}" "${script_dir}" && \
|
||||
|
@ -38,7 +38,7 @@ CACHE_TIMEOUT=$(date +"%Y-%m-%d")
|
||||
[ -n "${build_suffix}" ] && HYPERVISOR_NAME="kata-qemu-${build_suffix}" || HYPERVISOR_NAME="kata-qemu"
|
||||
[ -n "${build_suffix}" ] && PKGVERSION="kata-static-${build_suffix}" || PKGVERSION="kata-static"
|
||||
|
||||
container_image="${QEMU_CONTAINER_BUILDER:-${BUILDER_REGISTRY}:qemu-$(get_last_modification ${script_dir})-$(uname -m)}"
|
||||
container_image="${QEMU_CONTAINER_BUILDER:-$(get_qemu_image_name)}"
|
||||
|
||||
sudo docker pull ${container_image} || (sudo "${container_engine}" build \
|
||||
--build-arg CACHE_TIMEOUT="${CACHE_TIMEOUT}" \
|
||||
|
@ -19,7 +19,7 @@ RUST_VERSION=${RUST_VERSION}
|
||||
|
||||
DESTDIR=${DESTDIR:-${PWD}}
|
||||
PREFIX=${PREFIX:-/opt/kata}
|
||||
container_image="${SHIM_V2_CONTAINER_BUILDER:-${BUILDER_REGISTRY}:shim-v2-go-${GO_VERSION}-rust-${RUST_VERSION}-$(get_last_modification ${script_dir})-$(uname -m)}"
|
||||
container_image="${SHIM_V2_CONTAINER_BUILDER:-$(get_shim_v2_image_name)}"
|
||||
|
||||
sudo docker pull ${container_image} || \
|
||||
(sudo docker build \
|
||||
|
@ -48,7 +48,7 @@ case ${ARCH} in
|
||||
;;
|
||||
esac
|
||||
|
||||
container_image="${VIRTIOFSD_CONTAINER_BUILDER:-${BUILDER_REGISTRY}:virtiofsd-${virtiofsd_toolchain}-${libc}-$(get_last_modification ${script_dir})-$(uname -m)}"
|
||||
container_image="${VIRTIOFSD_CONTAINER_BUILDER:-$(get_virtiofsd_image_name)}"
|
||||
|
||||
sudo docker pull ${container_image} || \
|
||||
(sudo docker build \
|
||||
|
@ -177,12 +177,12 @@ assets:
|
||||
url: "https://cdn.kernel.org/pub/linux/kernel/v5.x/"
|
||||
tag: "v5.13.10"
|
||||
|
||||
arm-kernel-experimental:
|
||||
kernel-arm-experimental:
|
||||
description: "Linux kernel with cpu/mem hotplug support on arm64"
|
||||
url: "https://cdn.kernel.org/pub/linux/kernel/v5.x/"
|
||||
version: "v5.15.7"
|
||||
|
||||
dragonball-kernel-experimental:
|
||||
kernel-dragonball-experimental:
|
||||
description: "Linux kernel with Dragonball VMM optimizations like upcall"
|
||||
url: "https://cdn.kernel.org/pub/linux/kernel/v5.x/"
|
||||
version: "v5.10.25"
|
||||
|
Loading…
Reference in New Issue
Block a user