mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-07-25 14:18:54 +00:00
static-build: drop cross-build container handling
The shared lib.sh exported CROSS_BUILD/TARGET_ARCH/BUILDX/PLATFORM so the per-component static-build scripts could switch to `-cross-build` builder images, run `docker buildx build --platform=...` under QEMU emulation and, for shim-v2, swap in the messense/rust-musl-cross image with a matching cross CC. These cross paths are not exercised on our side (all builds run on native-arch runners), so remove them: builder images are now built with a plain `docker build`, and shim-v2 builds runtime-rs natively without the musl-cross image or CC override. Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com> Assisted-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,16 +19,7 @@ short_commit_length=10
|
||||
|
||||
gh_cli="gh-cli"
|
||||
|
||||
#for cross build
|
||||
CROSS_BUILD=${CROSS_BUILD-:}
|
||||
BUILDX=""
|
||||
PLATFORM=""
|
||||
TARGET_ARCH=${TARGET_ARCH:-$(uname -m)}
|
||||
ARCH=${ARCH:-$(uname -m)}
|
||||
[[ "${TARGET_ARCH}" == "aarch64" ]] && TARGET_ARCH=arm64
|
||||
TARGET_OS=${TARGET_OS:-linux}
|
||||
# shellcheck disable=SC2034
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && BUILDX=buildx && PLATFORM="--platform=${TARGET_OS}/${TARGET_ARCH}"
|
||||
|
||||
install_yq() {
|
||||
pushd "${repo_root_dir}" || return
|
||||
|
||||
@@ -15,12 +15,10 @@ readonly agent_builder="${script_dir}/build-static-agent.sh"
|
||||
source "${script_dir}/../../scripts/lib.sh"
|
||||
|
||||
container_image="${AGENT_CONTAINER_BUILDER:-$(get_agent_image_name)}"
|
||||
# shellcheck disable=SC2154
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && container_image="${container_image}-cross-build"
|
||||
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
docker pull "${container_image}" || \
|
||||
(docker ${BUILDX} build ${PLATFORM} \
|
||||
(docker build \
|
||||
--build-arg RUST_TOOLCHAIN="$(get_from_kata_deps ".languages.rust.meta.newest-version")" \
|
||||
-t "${container_image}" "${script_dir}" && \
|
||||
# No-op unless PUSH_TO_REGISTRY is exported as "yes"
|
||||
|
||||
@@ -27,12 +27,10 @@ readonly BUSYBOX_URL="${busybox_url}"
|
||||
|
||||
|
||||
container_image="${BUSYBOX_CONTAINER_BUILDER:-$(get_busybox_image_name)}"
|
||||
# shellcheck disable=SC2154
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && container_image="${container_image}-cross-build"
|
||||
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
docker pull "${container_image}" || \
|
||||
(docker ${BUILDX} build ${PLATFORM} \
|
||||
(docker build \
|
||||
-t "${container_image}" "${script_dir}" \
|
||||
# No-op unless PUSH_TO_REGISTRY is exported as "yes"
|
||||
push_to_registry "${container_image}")
|
||||
|
||||
@@ -33,12 +33,10 @@ nvat_version="${nvat_version:-}"
|
||||
[[ -n "${nvat_version}" ]] || nvat_version=$(get_from_kata_deps ".externals.nvidia.nvat.version" 2>/dev/null || true)
|
||||
|
||||
container_image="${COCO_GUEST_COMPONENTS_CONTAINER_BUILDER:-$(get_coco_guest_components_image_name)}"
|
||||
# shellcheck disable=SC2154
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && container_image="${container_image}-cross-build"
|
||||
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
docker pull "${container_image}" || \
|
||||
(docker ${BUILDX} build ${PLATFORM} \
|
||||
(docker build \
|
||||
--build-arg RUST_TOOLCHAIN="${coco_guest_components_toolchain}" \
|
||||
--build-arg NVAT_VERSION="${nvat_version}" \
|
||||
-t "${container_image}" "${script_dir}" && \
|
||||
|
||||
@@ -27,12 +27,10 @@ package_output_dir="${package_output_dir:-}"
|
||||
[[ -n "${pause_image_version}" ]] || die "Failed to get pause image version or commit"
|
||||
|
||||
container_image="${PAUSE_IMAGE_CONTAINER_BUILDER:-$(get_pause_image_name)}"
|
||||
# shellcheck disable=SC2154
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && container_image="${container_image}-cross-build"
|
||||
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
docker pull "${container_image}" || \
|
||||
(docker ${BUILDX} build ${PLATFORM} \
|
||||
(docker build \
|
||||
-t "${container_image}" "${script_dir}" && \
|
||||
# No-op unless PUSH_TO_REGISTRY is exported as "yes"
|
||||
push_to_registry "${container_image}")
|
||||
|
||||
@@ -19,7 +19,6 @@ VMM_CONFIGS="qemu fc"
|
||||
GO_VERSION=${GO_VERSION}
|
||||
# shellcheck disable=SC2269
|
||||
RUST_VERSION=${RUST_VERSION}
|
||||
CC=""
|
||||
|
||||
RUNTIME_CHOICE="${RUNTIME_CHOICE:-both}"
|
||||
DESTDIR=${DESTDIR:-${PWD}}
|
||||
@@ -38,9 +37,6 @@ case "${RUNTIME_CHOICE}" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && container_image_bk="${container_image}" && container_image="${container_image}-cross-build"
|
||||
|
||||
# Variants (targets) that build a measured rootfs as of now are:
|
||||
# - rootfs-image (the base image, measured; root hash labelled "base")
|
||||
# - rootfs-image-confidential (monolithic CoCo image, root hash "confidential")
|
||||
@@ -105,7 +101,7 @@ GO_EXTRA_OPTS+="$(read_verity_param "nvidia" "KERNELVERITYPARAMS_NV_BASE")"
|
||||
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
docker pull "${container_image}" || \
|
||||
(docker ${BUILDX} build ${PLATFORM} \
|
||||
(docker build \
|
||||
--build-arg GO_VERSION="${GO_VERSION}" \
|
||||
--build-arg RUST_VERSION="${RUST_VERSION}" \
|
||||
-t "${container_image}" \
|
||||
@@ -113,30 +109,21 @@ docker pull "${container_image}" || \
|
||||
push_to_registry "${container_image}")
|
||||
|
||||
arch=${ARCH:-$(uname -m)}
|
||||
GCC_ARCH=${arch}
|
||||
if [[ "${arch}" = "ppc64le" ]]; then
|
||||
GCC_ARCH="powerpc64le"
|
||||
arch="ppc64"
|
||||
fi
|
||||
|
||||
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} ${EXTRA_OPTS}${RUST_EXTRA_OPTS}"
|
||||
|
||||
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}" \
|
||||
@@ -154,8 +141,6 @@ fi
|
||||
|
||||
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)" \
|
||||
|
||||
@@ -17,12 +17,10 @@ source "${script_dir}/../../scripts/lib.sh"
|
||||
tool="${1}"
|
||||
|
||||
container_image="${TOOLS_CONTAINER_BUILDER:-$(get_tools_image_name)}"
|
||||
# shellcheck disable=SC2154
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && container_image="${container_image}-cross-build"
|
||||
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
docker pull "${container_image}" || \
|
||||
(docker ${BUILDX} build ${PLATFORM} \
|
||||
(docker build \
|
||||
--build-arg GO_TOOLCHAIN="$(get_from_kata_deps ".languages.golang.meta.newest-version")" \
|
||||
--build-arg RUST_TOOLCHAIN="$(get_from_kata_deps ".languages.rust.meta.newest-version")" \
|
||||
-t "${container_image}" "${script_dir}" && \
|
||||
|
||||
@@ -52,12 +52,10 @@ case ${ARCH} in
|
||||
esac
|
||||
|
||||
container_image="${VIRTIOFSD_CONTAINER_BUILDER:-$(get_virtiofsd_image_name)}"
|
||||
# shellcheck disable=SC2154
|
||||
[[ "${CROSS_BUILD}" == "true" ]] && container_image="${container_image}-cross-build"
|
||||
|
||||
# shellcheck disable=SC2154,SC2086
|
||||
docker pull "${container_image}" || \
|
||||
(docker ${BUILDX} build ${PLATFORM} \
|
||||
(docker build \
|
||||
--build-arg RUST_TOOLCHAIN="${virtiofsd_toolchain}" \
|
||||
-t "${container_image}" "${script_dir}/${libc}" && \
|
||||
# No-op unless PUSH_TO_REGISTRY is exported as "yes"
|
||||
|
||||
Reference in New Issue
Block a user