On Fri, Feb 24, 2023 at 06:08:53PM +0000, Alex Bennée wrote: > For the cross-compilation use-case it is important to add the host > user to the dockerfile so we can map them to the docker environment > when cross-building files. > > Signed-off-by: Alex Bennée <alex.ben...@linaro.org> > --- > .gitlab-ci.d/cirrus/freebsd-12.vars | 5 +++++ > .gitlab-ci.d/cirrus/freebsd-13.vars | 5 +++++ > .gitlab-ci.d/cirrus/macos-12.vars | 5 +++++ > tests/docker/dockerfiles/alpine.docker | 5 +++++ > tests/docker/dockerfiles/centos8.docker | 5 +++++ > tests/docker/dockerfiles/debian-amd64-cross.docker | 5 +++++ > tests/docker/dockerfiles/debian-amd64.docker | 5 +++++ > tests/docker/dockerfiles/debian-arm64-cross.docker | 5 +++++ > tests/docker/dockerfiles/debian-armel-cross.docker | 5 +++++ > tests/docker/dockerfiles/debian-armhf-cross.docker | 5 +++++ > tests/docker/dockerfiles/debian-mips64el-cross.docker | 5 +++++ > tests/docker/dockerfiles/debian-mipsel-cross.docker | 5 +++++ > tests/docker/dockerfiles/debian-ppc64el-cross.docker | 5 +++++ > tests/docker/dockerfiles/debian-s390x-cross.docker | 5 +++++ > tests/docker/dockerfiles/fedora-win32-cross.docker | 5 +++++ > tests/docker/dockerfiles/fedora-win64-cross.docker | 5 +++++ > tests/docker/dockerfiles/fedora.docker | 5 +++++ > tests/docker/dockerfiles/opensuse-leap.docker | 5 +++++ > tests/docker/dockerfiles/ubuntu2004.docker | 5 +++++ > tests/docker/dockerfiles/ubuntu2204.docker | 5 +++++ > tests/lcitool/refresh | 11 ++++++++++- > 21 files changed, 110 insertions(+), 1 deletion(-)
> > diff --git a/.gitlab-ci.d/cirrus/freebsd-12.vars > b/.gitlab-ci.d/cirrus/freebsd-12.vars > index 44d8a2a511..0bff53be44 100644 > --- a/.gitlab-ci.d/cirrus/freebsd-12.vars > +++ b/.gitlab-ci.d/cirrus/freebsd-12.vars > @@ -14,3 +14,8 @@ PIP3='/usr/local/bin/pip-3.8' > PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache > cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex > fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi > libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm > lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy > py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 > rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir > virglrenderer vte3 zstd' > PYPI_PKGS='' > PYTHON='/usr/local/bin/python3' > +# 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 > \ No newline at end of file The cirrus/*.vars files aren't dockerfiles, they're shell scripts, so don't modify them > diff --git a/tests/docker/dockerfiles/alpine.docker > b/tests/docker/dockerfiles/alpine.docker > index 56cf14e553..7b82dec8e5 100644 > --- a/tests/docker/dockerfiles/alpine.docker > +++ b/tests/docker/dockerfiles/alpine.docker > @@ -124,3 +124,8 @@ ENV LANG "en_US.UTF-8" > ENV MAKE "/usr/bin/make" > ENV NINJA "/usr/bin/ninja" > ENV PYTHON "/usr/bin/python3" > +# 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 > \ No newline at end of file Add a trailing newline to these perhaps ? > diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh > index cc9e34ac87..88bf33fb74 100755 > --- a/tests/lcitool/refresh > +++ b/tests/lcitool/refresh > @@ -40,6 +40,15 @@ def atomic_write(filename, content): > tmp.unlink() > raise > > +# Optional user setting, this will always be the last thing added > +# so maximise the number of layers that are cached > +add_user_mapping = [ > + "# 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" > +] > > def generate(filename, cmd, trailer): > print("Generate %s" % filename) > @@ -51,9 +60,9 @@ def generate(filename, cmd, trailer): > content = lcitool.stdout.decode("utf8") > if trailer is not None: > content += trailer > + content += "\n".join(add_user_mapping) if filename.endswith(".docker"): content += "\n".join(add_user_mapping) to avoid splattering the cirrus vars files With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|