Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: buildroot@buildroot.org
Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Subject: Re: [Buildroot] [PATCH] utils/docker-run: allow running without a tty
Date: Sun, 23 Apr 2023 19:37:32 +0200	[thread overview]
Message-ID: <20230423173732.GN2696@scaer> (raw)
In-Reply-To: <20230415194341.2346986-1-yann.morin.1998@free.fr>

All,

On 2023-04-15 21:43 +0200, Yann E. MORIN spake thusly:
> Currently, utils/docker-run spawns a container with a tty, so that he
> user can interact properly in the container.
> 
> However, that requires a tty when calling docker-run, which is not
> always guaranteed, e.g. if called from a git hook.
> 
> Since the script is a bash script already, we can use an array to store
> options passed to docker, and only add the -t option when there is
> actually a tty available.
> 
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Ricardo Martincoski <ricardo.martincoski@gmail.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
>  utils/docker-run | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/utils/docker-run b/utils/docker-run
> index 164e11c0e6..135a1451b6 100755
> --- a/utils/docker-run
> +++ b/utils/docker-run
> @@ -6,8 +6,15 @@ MAIN_DIR=$(readlink -f "${DIR}/..")
>  IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | \
>          sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g')
>  
> -exec docker run -it --rm \
> -    --user "$(id -u):$(id -g)" \
> -    --mount "type=bind,src=${MAIN_DIR},dst=${MAIN_DIR}" \
> -    --workdir "${MAIN_DIR}" \
> -    "${IMAGE}" "${@}"
> +declare -a docker_opts=(
> +    -i
> +    --rm
> +    --user "$(id -u):$(id -g)"
> +    --mount "type=bind,src=${MAIN_DIR},dst=${MAIN_DIR}"
> +    --workdir "${MAIN_DIR}"
> +)
> +if tty -s; then
> +    docker_opts+=( -t )
> +fi
> +
> +exec docker run "${docker_opts[@]}" "${IMAGE}" "${@}"
> -- 
> 2.25.1
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  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

  reply	other threads:[~2023-04-23 17:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15 19:43 [Buildroot] [PATCH] utils/docker-run: allow running without a tty Yann E. MORIN
2023-04-23 17:37 ` Yann E. MORIN [this message]
2023-05-02  6:30 ` Peter Korsgaard

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=20230423173732.GN2696@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=ricardo.martincoski@gmail.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