diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries-in-docker.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries-in-docker.sh index 410ba5297..7b19deb5e 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries-in-docker.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries-in-docker.sh @@ -108,6 +108,7 @@ KBUILD_SIGN_PIN=${KBUILD_SIGN_PIN:-} GUEST_HOOKS_TARBALL_NAME="${GUEST_HOOKS_TARBALL_NAME:-}" EXTRA_PKGS="${EXTRA_PKGS:-}" AGENT_POLICY="${AGENT_POLICY:-yes}" +RUNTIME_CHOICE="${RUNTIME_CHOICE:-both}" docker run \ -v $HOME/.docker:/root/.docker \ @@ -143,6 +144,7 @@ docker run \ --env GUEST_HOOKS_TARBALL_NAME="${GUEST_HOOKS_TARBALL_NAME}" \ --env EXTRA_PKGS="${EXTRA_PKGS}" \ --env AGENT_POLICY="${AGENT_POLICY}" \ + --env RUNTIME_CHOICE="${RUNTIME_CHOICE}" \ --env AA_KBC="${AA_KBC:-}" \ --env HKD_PATH="$(realpath "${HKD_PATH:-}" 2> /dev/null || true)" \ --env SE_KERNEL_PARAMS="${SE_KERNEL_PARAMS:-}" \ diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh index 1838ac2e7..f5d8b427c 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -57,6 +57,7 @@ PUSH_TO_REGISTRY="${PUSH_TO_REGISTRY:-}" KERNEL_HEADERS_PKG_TYPE="${KERNEL_HEADERS_PKG_TYPE:-deb}" RELEASE="${RELEASE:-"no"}" KBUILD_SIGN_PIN="${KBUILD_SIGN_PIN:-}" +RUNTIME_CHOICE="${RUNTIME_CHOICE:-both}" workdir="${WORKDIR:-$PWD}" @@ -897,6 +898,7 @@ install_shimv2() { export GO_VERSION export RUST_VERSION export MEASURED_ROOTFS + export RUNTIME_CHOICE DESTDIR="${destdir}" PREFIX="${prefix}" "${shimv2_builder}" } diff --git a/tools/packaging/static-build/shim-v2/build.sh b/tools/packaging/static-build/shim-v2/build.sh index 3944b0928..3baef6d80 100755 --- a/tools/packaging/static-build/shim-v2/build.sh +++ b/tools/packaging/static-build/shim-v2/build.sh @@ -18,12 +18,23 @@ GO_VERSION=${GO_VERSION} RUST_VERSION=${RUST_VERSION} CC="" +RUNTIME_CHOICE="${RUNTIME_CHOICE:-both}" DESTDIR=${DESTDIR:-${PWD}} PREFIX=${PREFIX:-/opt/kata} container_image="${SHIM_V2_CONTAINER_BUILDER:-$(get_shim_v2_image_name)}" EXTRA_OPTS="${EXTRA_OPTS:-""}" +case "${RUNTIME_CHOICE}" in + "go"|"rust"|"both") + echo "Building ${RUNTIME_CHOICE} runtime(s)" + ;; + *) + echo "Invalid option for RUNTIME_CHOICE: ${RUNTIME_CHOICE}" + exit 1 + ;; +esac + [ "${CROSS_BUILD}" == "true" ] && container_image_bk="${container_image}" && container_image="${container_image}-cross-build" if [ "${MEASURED_ROOTFS}" == "yes" ]; then info "Enable rootfs measurement config" @@ -53,40 +64,48 @@ if [ ${arch} = "ppc64le" ]; then arch="ppc64" fi -#Build rust project using cross build musl image to speed up -[[ "${CROSS_BUILD}" == "true" && ${ARCH} != "s390x" ]] && container_image="messense/rust-musl-cross:${GCC_ARCH}-musl" && CC=${GCC_ARCH}-unknown-linux-musl-gcc +case "${RUNTIME_CHOICE}" in + "rust"|"both") + #Build rust project using cross build musl image to speed up + [[ "${CROSS_BUILD}" == "true" && ${ARCH} != "s390x" ]] && container_image="messense/rust-musl-cross:${GCC_ARCH}-musl" && CC=${GCC_ARCH}-unknown-linux-musl-gcc -docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ - --env CROSS_BUILD=${CROSS_BUILD} \ - --env ARCH=${ARCH} \ - --env CC="${CC}" \ - -w "${repo_root_dir}/src/runtime-rs" \ - --user "$(id -u)":"$(id -g)" \ - "${container_image}" \ - bash -c "make clean-generated-files && make PREFIX=${PREFIX} QEMUCMD=qemu-system-${arch}" + docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ + --env CROSS_BUILD=${CROSS_BUILD} \ + --env ARCH=${ARCH} \ + --env CC="${CC}" \ + -w "${repo_root_dir}/src/runtime-rs" \ + --user "$(id -u)":"$(id -g)" \ + "${container_image}" \ + bash -c "make clean-generated-files && make PREFIX=${PREFIX} QEMUCMD=qemu-system-${arch}" -docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ - --env CROSS_BUILD=${CROSS_BUILD} \ - --env ARCH=${ARCH} \ - --env CC="${CC}" \ - -w "${repo_root_dir}/src/runtime-rs" \ - --user "$(id -u)":"$(id -g)" \ - "${container_image}" \ - bash -c "make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install" + docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ + --env CROSS_BUILD=${CROSS_BUILD} \ + --env ARCH=${ARCH} \ + --env CC="${CC}" \ + -w "${repo_root_dir}/src/runtime-rs" \ + --user "$(id -u)":"$(id -g)" \ + "${container_image}" \ + bash -c "make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install" + ;; +esac -[ "${CROSS_BUILD}" == "true" ] && container_image="${container_image_bk}-cross-build" +case "${RUNTIME_CHOICE}" in + "go"|"both") + [ "${CROSS_BUILD}" == "true" ] && container_image="${container_image_bk}-cross-build" -docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ - -w "${repo_root_dir}/src/runtime" \ - --user "$(id -u)":"$(id -g)" \ - "${container_image}" \ - bash -c "make clean-generated-files && make PREFIX=${PREFIX} QEMUCMD=qemu-system-${arch} ${EXTRA_OPTS}" + docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ + -w "${repo_root_dir}/src/runtime" \ + --user "$(id -u)":"$(id -g)" \ + "${container_image}" \ + bash -c "make clean-generated-files && make PREFIX=${PREFIX} QEMUCMD=qemu-system-${arch} ${EXTRA_OPTS}" -docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ - -w "${repo_root_dir}/src/runtime" \ - --user "$(id -u)":"$(id -g)" \ - "${container_image}" \ - bash -c "make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" ${EXTRA_OPTS} install" + docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ + -w "${repo_root_dir}/src/runtime" \ + --user "$(id -u)":"$(id -g)" \ + "${container_image}" \ + bash -c "make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" ${EXTRA_OPTS} install" + ;; +esac for vmm in ${VMM_CONFIGS}; do config_file="${DESTDIR}/${PREFIX}/share/defaults/kata-containers/configuration-${vmm}.toml"