diff --git a/tools/packaging/scripts/lib.sh b/tools/packaging/scripts/lib.sh index 6f006c1f9e..61776bcbff 100644 --- a/tools/packaging/scripts/lib.sh +++ b/tools/packaging/scripts/lib.sh @@ -175,3 +175,8 @@ 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)" +} diff --git a/tools/packaging/static-build/cache_components_main.sh b/tools/packaging/static-build/cache_components_main.sh index c5d49f773a..ef9cf6b9c9 100755 --- a/tools/packaging/static-build/cache_components_main.sh +++ b/tools/packaging/static-build/cache_components_main.sh @@ -62,6 +62,18 @@ cache_rootfs_artifacts() { 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}" +} + create_cache_asset() { local component_name="${1}" local component_version="${2}" @@ -93,6 +105,7 @@ Usage: $0 "[options]" -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 -h Shows help EOF )" @@ -105,8 +118,9 @@ main() { local nydus_component="${nydus_component:-}" local qemu_component="${qemu_component:-}" local rootfs_component="${rootfs_component:-}" + local shim_v2_component="${shim_v2_component:-}" local OPTIND - while getopts ":cFknqrh:" opt + while getopts ":cFknqrsh:" opt do case "$opt" in c) @@ -127,6 +141,9 @@ main() { r) rootfs_component="1" ;; + s) + shim_v2_component="1" + ;; h) help exit 0; @@ -146,6 +163,7 @@ main() { [[ -z "${nydus_component}" ]] && \ [[ -z "${qemu_component}" ]] && \ [[ -z "${rootfs_component}" ]] && \ + [[ -z "${shim_v2_component}" ]] && \ help && die "Must choose at least one option" mkdir -p "${WORKSPACE}/artifacts" @@ -158,6 +176,7 @@ main() { [ "${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 ls -la "${WORKSPACE}/artifacts/" popd diff --git a/tools/packaging/static-build/shim-v2/build.sh b/tools/packaging/static-build/shim-v2/build.sh index 35ebabcab9..d948ae1e86 100755 --- a/tools/packaging/static-build/shim-v2/build.sh +++ b/tools/packaging/static-build/shim-v2/build.sh @@ -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 \