mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Differentiate build process for non-amd64 platforms
- reset `binfmt_misc` is needn't when the building platform is non-amd64 and the target arch is the same as building platform - non-amd64 platform doesn't supported cross-build well, and there is no binary of `qemu-user-static` able to do that, and thus skip the cross-build on non-amd64 platform. Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
parent
eb2b71c727
commit
721da10205
@ -140,24 +140,36 @@ build() {
|
|||||||
${SED} -i "s|BASEARCH|${arch}|g" $dockerfile_name
|
${SED} -i "s|BASEARCH|${arch}|g" $dockerfile_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform
|
# Only the cross-build on x86 is guaranteed by far, other arches like aarch64 doesn't support cross-build
|
||||||
if grep -q "CROSS_BUILD_" Dockerfile; then
|
# thus, there is no need to tackle a disability feature on those platforms, and also help to prevent from
|
||||||
if [[ "${arch}" == "amd64" ]]; then
|
# ending up a wrong image tag on non-amd64 platforms.
|
||||||
${SED} -i "/CROSS_BUILD_/d" Dockerfile
|
build_arch=$(uname -m)
|
||||||
else
|
if [[ ${build_arch} = "x86_64" ]]; then
|
||||||
${SED} -i "s|QEMUARCH|${QEMUARCHS[$arch]}|g" Dockerfile
|
# copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform
|
||||||
# Register qemu-*-static for all supported processors except the current one
|
if grep -q "CROSS_BUILD_" Dockerfile; then
|
||||||
echo "Registering qemu-*-static binaries in the kernel"
|
if [[ "${arch}" == "amd64" ]]; then
|
||||||
local sudo=""
|
${SED} -i "/CROSS_BUILD_/d" Dockerfile
|
||||||
if [[ $(id -u) != 0 ]]; then
|
else
|
||||||
sudo=sudo
|
${SED} -i "s|QEMUARCH|${QEMUARCHS[$arch]}|g" Dockerfile
|
||||||
|
# Register qemu-*-static for all supported processors except the current one
|
||||||
|
echo "Registering qemu-*-static binaries in the kernel"
|
||||||
|
local sudo=""
|
||||||
|
if [[ $(id -u) != 0 ]]; then
|
||||||
|
sudo=sudo
|
||||||
|
fi
|
||||||
|
${sudo} "${KUBE_ROOT}/third_party/multiarch/qemu-user-static/register/register.sh" --reset -p yes
|
||||||
|
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/"${QEMUVERSION}"/x86_64_qemu-"${QEMUARCHS[$arch]}"-static.tar.gz | tar -xz -C "${temp_dir}"
|
||||||
|
# Ensure we don't get surprised by umask settings
|
||||||
|
chmod 0755 "${temp_dir}/qemu-${QEMUARCHS[$arch]}-static"
|
||||||
|
${SED} -i "s/CROSS_BUILD_//g" Dockerfile
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
${sudo} "${KUBE_ROOT}/third_party/multiarch/qemu-user-static/register/register.sh" --reset -p yes
|
elif [[ "${QEMUARCHS[$arch]}" != "${build_arch}" ]]; then
|
||||||
curl -sSL https://github.com/multiarch/qemu-user-static/releases/download/"${QEMUVERSION}"/x86_64_qemu-"${QEMUARCHS[$arch]}"-static.tar.gz | tar -xz -C "${temp_dir}"
|
echo "skip cross-build $arch on non-supported platform ${build_arch}."
|
||||||
# Ensure we don't get surprised by umask settings
|
popd
|
||||||
chmod 0755 "${temp_dir}/qemu-${QEMUARCHS[$arch]}-static"
|
continue
|
||||||
${SED} -i "s/CROSS_BUILD_//g" Dockerfile
|
else
|
||||||
fi
|
${SED} -i "/CROSS_BUILD_/d" Dockerfile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker buildx build --progress=plain --no-cache --pull --output=type="${output_type}" --platform "${os_name}/${arch}" \
|
docker buildx build --progress=plain --no-cache --pull --output=type="${output_type}" --platform "${os_name}/${arch}" \
|
||||||
|
Loading…
Reference in New Issue
Block a user