Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] utils/docker-run: Allow running with Podman
@ 2024-05-31 10:44 Fiona Klute via buildroot
  2024-05-31 12:54 ` Yann E. MORIN
  0 siblings, 1 reply; 2+ messages in thread
From: Fiona Klute via buildroot @ 2024-05-31 10:44 UTC (permalink / raw)
  To: buildroot; +Cc: Fiona Klute, Ricardo Martincoski

Podman is command line compatible with Docker, there's no need to
require contributors to install Docker to run checks before sending
patches.

The additional "--userns=keep-id" option is necessary because unlike
Docker Podman creates a user namespace for containers by
default. Without keep-id the repository and pre-existing output files
belong to root inside the container namespace, breaking writes,
certain Git safety checks, and possibly all access (if the user is
using a strict umask).

Signed-off-by: Fiona Klute <fiona.klute+wiwa@gmx.de>
---
 utils/docker-run | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/utils/docker-run b/utils/docker-run
index 79694474c1..3dcabe2718 100755
--- a/utils/docker-run
+++ b/utils/docker-run
@@ -29,6 +29,16 @@ declare -a mountpoints=(
     "$(pwd)"
 )

+if command -v docker >/dev/null; then
+    DOCKER="docker"
+elif command -v podman >/dev/null; then
+    DOCKER="podman"
+    docker_opts+=( --userns=keep-id )
+else
+    echo "ERROR: Neither docker nor podman available!" >&2
+    exit 1
+fi
+
 # curl lists (and recognises and uses) other types of *_proxy variables,
 # but only those make sense for Buildroot:
 for env in all_proxy http_proxy https_proxy ftp_proxy no_proxy; do
@@ -84,4 +94,4 @@ if tty -s; then
     docker_opts+=( -t )
 fi

-exec docker run "${docker_opts[@]}" "${IMAGE}" "${@}"
+exec ${DOCKER} run "${docker_opts[@]}" "${IMAGE}" "${@}"
--
2.45.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] utils/docker-run: Allow running with Podman
  2024-05-31 10:44 [Buildroot] [PATCH 1/1] utils/docker-run: Allow running with Podman Fiona Klute via buildroot
@ 2024-05-31 12:54 ` Yann E. MORIN
  0 siblings, 0 replies; 2+ messages in thread
From: Yann E. MORIN @ 2024-05-31 12:54 UTC (permalink / raw)
  To: Fiona Klute; +Cc: Ricardo Martincoski, buildroot

Fiona, All,

On 2024-05-31 12:44 +0200, Fiona Klute via buildroot spake thusly:
> Podman is command line compatible with Docker, there's no need to
> require contributors to install Docker to run checks before sending
> patches.
> 
> The additional "--userns=keep-id" option is necessary because unlike
> Docker Podman creates a user namespace for containers by
> default. Without keep-id the repository and pre-existing output files
> belong to root inside the container namespace, breaking writes,
> certain Git safety checks, and possibly all access (if the user is
> using a strict umask).
> 
> Signed-off-by: Fiona Klute <fiona.klute+wiwa@gmx.de>

I have a hook that validates that the author has properly signed-off
their contribution, and your sub-addressing triggered the check. Damn, I
need to test for more corner-cases!

Applied to next, thanks.

Regards,
Yann E. MORIN.

> ---
>  utils/docker-run | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/docker-run b/utils/docker-run
> index 79694474c1..3dcabe2718 100755
> --- a/utils/docker-run
> +++ b/utils/docker-run
> @@ -29,6 +29,16 @@ declare -a mountpoints=(
>      "$(pwd)"
>  )
> 
> +if command -v docker >/dev/null; then
> +    DOCKER="docker"
> +elif command -v podman >/dev/null; then
> +    DOCKER="podman"
> +    docker_opts+=( --userns=keep-id )
> +else
> +    echo "ERROR: Neither docker nor podman available!" >&2
> +    exit 1
> +fi
> +
>  # curl lists (and recognises and uses) other types of *_proxy variables,
>  # but only those make sense for Buildroot:
>  for env in all_proxy http_proxy https_proxy ftp_proxy no_proxy; do
> @@ -84,4 +94,4 @@ if tty -s; then
>      docker_opts+=( -t )
>  fi
> 
> -exec docker run "${docker_opts[@]}" "${IMAGE}" "${@}"
> +exec ${DOCKER} run "${docker_opts[@]}" "${IMAGE}" "${@}"
> --
> 2.45.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-31 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-31 10:44 [Buildroot] [PATCH 1/1] utils/docker-run: Allow running with Podman Fiona Klute via buildroot
2024-05-31 12:54 ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox