From 7f6c512130d07d91cf8bcb1b2ef2e4b0bd350e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=99=93=E4=BC=9F?= Date: Mon, 1 Jun 2026 03:25:30 +0800 Subject: [PATCH 1/2] Make QEMU version and flags overridable via environment variables Allow customizing QEMUVERSION and QEMUFLAGS without modifying Makefiles, so that users can use different QEMU configurations for cross-arch builds. --- images/build/debian-base/Makefile | 5 +++-- images/build/distroless-iptables/Makefile | 5 +++-- images/build/setcap/Makefile | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/images/build/debian-base/Makefile b/images/build/debian-base/Makefile index 9a20a4f06ea..1c386c5816b 100755 --- a/images/build/debian-base/Makefile +++ b/images/build/debian-base/Makefile @@ -26,8 +26,9 @@ TAR_FILE ?= rootfs.tar ARCH ?= amd64 ALL_ARCH = amd64 arm arm64 ppc64le s390x -QEMUVERSION=7.2.0-1 +QEMUVERSION ?= 7.2.0-1 QEMUIMAGE ?= multiarch/qemu-user-static +QEMUFLAGS ?= --reset -p yes # This option is for running docker manifest command export DOCKER_CLI_EXPERIMENTAL := enabled @@ -75,7 +76,7 @@ build: clean umask 0022 # Enable execution of multi-architecture containers - docker run --rm --privileged $(QEMUIMAGE):$(QEMUVERSION) --reset -p yes + docker run --rm --privileged $(QEMUIMAGE):$(QEMUVERSION) $(QEMUFLAGS) docker buildx version BUILDER=$(shell docker buildx create --use) diff --git a/images/build/distroless-iptables/Makefile b/images/build/distroless-iptables/Makefile index ddddb96addf..bba03164407 100644 --- a/images/build/distroless-iptables/Makefile +++ b/images/build/distroless-iptables/Makefile @@ -30,8 +30,9 @@ BASE_REGISTRY?=registry.k8s.io/build-image GORUNNERIMAGE?=$(BASE_REGISTRY)/go-runner:$(GORUNNER_VERSION) -QEMUVERSION=7.2.0-1 +QEMUVERSION ?= 7.2.0-1 QEMUIMAGE ?= multiarch/qemu-user-static +QEMUFLAGS ?= --reset -p yes ifneq ($(ARCH), amd64) SKIP_WRAPPER_CHECK=--no-sanity-check @@ -47,7 +48,7 @@ build: umask 0022 # Enable execution of multi-architecture containers - docker run --rm --privileged $(QEMUIMAGE):$(QEMUVERSION) --reset -p yes + docker run --rm --privileged $(QEMUIMAGE):$(QEMUVERSION) $(QEMUFLAGS) docker buildx version BUILDER=$(shell docker buildx create --use) docker buildx build \ diff --git a/images/build/setcap/Makefile b/images/build/setcap/Makefile index 6bd7ce6c7ce..b4e3029c955 100644 --- a/images/build/setcap/Makefile +++ b/images/build/setcap/Makefile @@ -29,8 +29,9 @@ BASE_REGISTRY?=registry.k8s.io/build-image BASEIMAGE?=$(BASE_REGISTRY)/debian-base-$(ARCH):$(DEBIAN_BASE_VERSION) # Build args -QEMUVERSION=7.2.0-1 +QEMUVERSION ?= 7.2.0-1 QEMUIMAGE ?= multiarch/qemu-user-static +QEMUFLAGS ?= --reset -p yes # This option is for running docker manifest command export DOCKER_CLI_EXPERIMENTAL := enabled @@ -40,7 +41,7 @@ build: umask 0022 # Enable execution of multi-architecture containers - docker run --rm --privileged $(QEMUIMAGE):$(QEMUVERSION) --reset -p yes + docker run --rm --privileged $(QEMUIMAGE):$(QEMUVERSION) $(QEMUFLAGS) docker buildx version BUILDER=$(shell docker buildx create --use) docker buildx build \ From 9aa8a6fd6c7f6794a5d6948b9fbb7738f9999a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=99=93=E4=BC=9F?= Date: Mon, 1 Jun 2026 05:22:09 +0800 Subject: [PATCH 2/2] Make ALL_ARCH overridable via environment variables Use ?= instead of = for ALL_ARCH so it can be overridden, consistent with ARCH and the recent QEMU variable changes (7f6c5121). --- images/build/debian-base/Makefile | 2 +- images/build/distroless-iptables/Makefile | 2 +- images/build/setcap/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/images/build/debian-base/Makefile b/images/build/debian-base/Makefile index 1c386c5816b..db174a7694d 100755 --- a/images/build/debian-base/Makefile +++ b/images/build/debian-base/Makefile @@ -24,7 +24,7 @@ CONFIG ?= bookworm TAR_FILE ?= rootfs.tar ARCH ?= amd64 -ALL_ARCH = amd64 arm arm64 ppc64le s390x +ALL_ARCH ?= amd64 arm arm64 ppc64le s390x QEMUVERSION ?= 7.2.0-1 QEMUIMAGE ?= multiarch/qemu-user-static diff --git a/images/build/distroless-iptables/Makefile b/images/build/distroless-iptables/Makefile index bba03164407..b04f1cd18c3 100644 --- a/images/build/distroless-iptables/Makefile +++ b/images/build/distroless-iptables/Makefile @@ -24,7 +24,7 @@ BASEIMAGE ?= debian:bookworm-slim GORUNNER_VERSION ?= v2.4.0-go1.25.10-bookworm.0 ARCH?=amd64 -ALL_ARCH = amd64 arm arm64 ppc64le s390x +ALL_ARCH ?= amd64 arm arm64 ppc64le s390x BASE_REGISTRY?=registry.k8s.io/build-image diff --git a/images/build/setcap/Makefile b/images/build/setcap/Makefile index b4e3029c955..340715589ef 100644 --- a/images/build/setcap/Makefile +++ b/images/build/setcap/Makefile @@ -23,7 +23,7 @@ CONFIG ?= bookworm DEBIAN_BASE_VERSION ?= bookworm-v1.0.7 ARCH?=amd64 -ALL_ARCH = amd64 arm arm64 ppc64le s390x +ALL_ARCH ?= amd64 arm arm64 ppc64le s390x BASE_REGISTRY?=registry.k8s.io/build-image BASEIMAGE?=$(BASE_REGISTRY)/debian-base-$(ARCH):$(DEBIAN_BASE_VERSION)