diff mbox series

[v2,7/7] tests/docker: use direct RUNC call in debian-toolchain

Message ID 20221013154705.1846261-8-alex.bennee@linaro.org
State New
Headers show
Series testing/next (configure, RUNC, win32|64) | expand

Commit Message

Alex Bennée Oct. 13, 2022, 3:47 p.m. UTC
We don't really need stuff from docker.py to do the build as we have
everything we need with a direct call. We do need to tweak the
dockerfiles so we can redo the UID/name mapping as the last step.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/docker/Makefile.include                 | 38 ++++++++++---------
 .../dockerfiles/debian-hexagon-cross.docker   |  5 +++
 .../dockerfiles/debian-toolchain.docker       |  5 +++
 3 files changed, 31 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index c87f14477a..c34b3d1340 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -7,6 +7,8 @@  SPACE := $(NULL) #
 COMMA := ,
 
 HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m))
+USER = $(if $(NOUSER),,$(shell id -un))
+UID = $(if $(NOUSER),,$(shell id -u))
 
 DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles
 ifeq ($(HOST_ARCH),x86_64)
@@ -90,23 +92,25 @@  docker-image-debian-native: DOCKER_REGISTRY=
 # alpine has no adduser
 docker-image-alpine: NOUSER=1
 
-debian-toolchain-run = \
-	$(if $(NOCACHE), 						\
-		$(call quiet-command,					\
-			$(DOCKER_SCRIPT) build -t qemu/$1 -f $< 	\
-			$(if $V,,--quiet) --no-cache 			\
-			--registry $(DOCKER_REGISTRY) --extra-files	\
-			$(DOCKER_FILES_DIR)/$1.d/build-toolchain.sh,	\
-			"BUILD", $1),				        \
-		$(call quiet-command,					\
-			$(DOCKER_SCRIPT) fetch $(if $V,,--quiet)	\
-				qemu/$1 $(DOCKER_REGISTRY),		\
-			"FETCH", $1)					\
-		$(call quiet-command,					\
-			$(DOCKER_SCRIPT) update $(if $V,,--quiet) 	\
-				qemu/$1 				\
-				$(if $(NOUSER),,--add-current-user) 	\
-			"PREPARE", $1))
+debian-toolchain-run = 					\
+	$(call quiet-command,           	        \
+		$(RUNC) pull                            \
+                $(if $V,,--quiet)                       \
+                $(DOCKER_REGISTRY)/qemu/$1,             \
+                "FETCH", $1);				\
+         $(call quiet-command,                          \
+                $(RUNC) build                           \
+		$(if $V,,--quiet)                       \
+		$(if $(NOCACHE),--no-cache)		\
+		$(if $(NOUSER),,			\
+			--build-arg USER=$(USER)	\
+			--build-arg UID=$(UID))		\
+		-t qemu/$1                              \
+                -f -                                    \
+                $(DOCKER_FILES_DIR)/$1.d                \
+                <  $<,                                  \
+                "BUILD", $1)
+
 debian-toolchain = $(call debian-toolchain-run,$(patsubst docker-image-%,%,$1))
 
 docker-image-debian-hexagon-cross: $(DOCKER_FILES_DIR)/debian-hexagon-cross.docker \
diff --git a/tests/docker/dockerfiles/debian-hexagon-cross.docker b/tests/docker/dockerfiles/debian-hexagon-cross.docker
index 8d219bb81d..13fab3032a 100644
--- a/tests/docker/dockerfiles/debian-hexagon-cross.docker
+++ b/tests/docker/dockerfiles/debian-hexagon-cross.docker
@@ -48,3 +48,8 @@  RUN apt update && \
     apt build-dep -yy --arch-only qemu
 COPY --from=0 /usr/local /usr/local
 ENV PATH $PATH:/usr/local/bin/
+
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
diff --git a/tests/docker/dockerfiles/debian-toolchain.docker b/tests/docker/dockerfiles/debian-toolchain.docker
index d3d4d3344e..85e88f1ebb 100644
--- a/tests/docker/dockerfiles/debian-toolchain.docker
+++ b/tests/docker/dockerfiles/debian-toolchain.docker
@@ -35,3 +35,8 @@  RUN cd /root && ./build-toolchain.sh
 # then copying the built toolchain from stage 0.
 FROM docker.io/library/debian:bullseye-slim
 COPY --from=0 /usr/local /usr/local
+
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi