qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, "Li-Wen Hsu" <lwhsu@freebsd.org>,
	"Thomas Huth" <thuth@redhat.com>, "Kevin Wolf" <kwolf@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Qiuhao Li" <Qiuhao.Li@outlook.com>,
	"Beraldo Leal" <bleal@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Yonggang Luo" <luoyonggang@gmail.com>,
	"Ed Maste" <emaste@freebsd.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-block@nongnu.org,
	"Bastian Koppelmann" <kbastian@mail.uni-paderborn.de>,
	"John Snow" <jsnow@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Alexander Bulekov" <alxndr@bu.edu>,
	"Hanna Reitz" <hreitz@redhat.com>, "Bandan Das" <bsd@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Darren Kenny" <darren.kenny@oracle.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>
Subject: Re: [PATCH 3/7] tests/lcitool: append user setting stanza to dockerfiles
Date: Tue, 28 Feb 2023 10:38:20 +0000	[thread overview]
Message-ID: <Y/3ZnMeOFKD7rNSy@redhat.com> (raw)
In-Reply-To: <20230224180857.1050220-4-alex.bennee@linaro.org>

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.bennee@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 :|



  reply	other threads:[~2023-02-28 10:39 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 18:08 [PATCH 0/7] testing/next: docker.py removal and kaniko updates Alex Bennée
2023-02-24 18:08 ` [PATCH 1/7] configure: expose the direct container command Alex Bennée
2023-02-27 11:18   ` Daniel P. Berrangé
2023-02-28 11:54   ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 2/7] tests/dockerfiles: unify debian-toolchain references Alex Bennée
2023-02-27 11:14   ` Daniel P. Berrangé
2023-02-28 11:38   ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 3/7] tests/lcitool: append user setting stanza to dockerfiles Alex Bennée
2023-02-28 10:38   ` Daniel P. Berrangé [this message]
2023-02-24 18:08 ` [PATCH 4/7] tests/docker: add USER stanzas to non-lci images Alex Bennée
2023-02-28 10:40   ` Daniel P. Berrangé
2023-02-28 11:43   ` Philippe Mathieu-Daudé
2023-02-28 11:45     ` Daniel P. Berrangé
2023-02-28 12:18     ` Alex Bennée
2023-02-28 12:21       ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 5/7] tests/docker: use direct RUNC call to build containers Alex Bennée
2023-02-28 10:40   ` Daniel P. Berrangé
2023-02-28 11:55   ` Philippe Mathieu-Daudé
2023-02-24 18:08 ` [PATCH 6/7] tests/docker: use direct RUNC call to run test jobs Alex Bennée
2023-02-28 10:45   ` Daniel P. Berrangé
2023-02-24 18:08 ` [PATCH 7/7] tests/gitlab: use kaniko to build images Alex Bennée
2023-02-28 10:53   ` Daniel P. Berrangé
2023-02-28 11:58 ` [PATCH 0/7] testing/next: docker.py removal and kaniko updates Philippe Mathieu-Daudé
2023-02-28 12:58   ` Daniel P. Berrangé
2023-02-28 13:29     ` Philippe Mathieu-Daudé
2023-02-28 13:34       ` Daniel P. Berrangé
2023-02-28 13:57         ` Alex Bennée
2023-02-28 14:33           ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/3ZnMeOFKD7rNSy@redhat.com \
    --to=berrange@redhat.com \
    --cc=Qiuhao.Li@outlook.com \
    --cc=alex.bennee@linaro.org \
    --cc=alxndr@bu.edu \
    --cc=armbru@redhat.com \
    --cc=aurelien@aurel32.net \
    --cc=bleal@redhat.com \
    --cc=bsd@redhat.com \
    --cc=crosa@redhat.com \
    --cc=darren.kenny@oracle.com \
    --cc=emaste@freebsd.org \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kbastian@mail.uni-paderborn.de \
    --cc=kwolf@redhat.com \
    --cc=luoyonggang@gmail.com \
    --cc=lwhsu@freebsd.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pavel.dovgaluk@ispras.ru \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).