Commit fbc4119e88 for qemu.org
commit fbc4119e8860613c9d3c911a0162b0b0b015dd31
Author: Alex Bennée <alex.bennee@linaro.org>
Date: Thu Sep 17 17:55:51 2026 +0100
tests/tcg: use --add-current-user when building containers
As the meson tcg build routes the container builds through docker.py
we can also clean up its hack which involved appending a RUN line to
the dockerfile. All the dockerfiles that care will work with the
--build-arg.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Tested-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20260917165602.3405537-8-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 315fa2ff84..6090a9dc95 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -297,13 +297,6 @@ def build_image(self, tag, docker_dir, dockerfile,
dir=docker_dir, suffix=".docker")
tmp_df.write(dockerfile)
- if user:
- uid = os.getuid()
- uname = getpass.getuser()
- tmp_df.write("\n")
- tmp_df.write("RUN id %s 2>/dev/null || useradd -u %d -U %s" %
- (uname, uid, uname))
-
tmp_df.write("\n")
tmp_df.write("LABEL com.qemu.dockerfile-checksum=%s\n" % (checksum))
for f, c in extra_files_cksum:
@@ -315,6 +308,12 @@ def build_image(self, tag, docker_dir, dockerfile,
if self._buildkit:
build_args += ["--build-arg", "BUILDKIT_INLINE_CACHE=1"]
+ if user:
+ uid = os.getuid()
+ uname = getpass.getuser()
+ build_args += ["--build-arg", "USER=%s" % uname,
+ "--build-arg", "UID=%s" % uid]
+
if registry is not None:
pull_args = ["pull", "%s/%s" % (registry, tag)]
self._do(pull_args, quiet=quiet)
diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
index 0604c4b90b..814f2f8cd8 100644
--- a/tests/tcg/meson.build
+++ b/tests/tcg/meson.build
@@ -255,7 +255,8 @@ foreach target, plan: tcg_tests
image_name = 'image-' + cc_dockerfile
has_docker = docker_host_arch_supported and docker_supported
if cc_dockerfile not in image_targets and has_docker
- cmd = [docker_wrapper, 'build', '-f', dockerfile, '-t', 'qemu/' + cc_dockerfile]
+ cmd = [docker_wrapper, 'build', '-f', dockerfile, '-t', 'qemu/' + cc_dockerfile,
+ '--add-current-user']
t = custom_target(image_name, command: cmd,
build_by_default: false,
output: 'no_output_' + image_name)