All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang
@ 2022-02-14 16:24 Luca Ceresoli
  2022-02-14 16:24 ` [Buildroot] [PATCH 2/2] utils/docker-run: allow interactive use Luca Ceresoli
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Luca Ceresoli @ 2022-02-14 16:24 UTC (permalink / raw)
  To: buildroot
  Cc: Luca Ceresoli, Giulio Benetti, Yann E . MORIN,
	Ricardo Martincoski

/usr/bin/bash does not exist on Ubuntu 2018.04. Use the more portable
alternative /bin/bash.

Note that currently "/usr/bin/bash" does not appear anywhere in the
Buildroot source code, while "/bin/bash" is used by many scripts.

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Fixes: 242e9d72e7d2 ("utils/docker-run: new script")
---
 utils/docker-run | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/docker-run b/utils/docker-run
index 0614f1325d78..979aec69b946 100755
--- a/utils/docker-run
+++ b/utils/docker-run
@@ -1,4 +1,4 @@
-#!/usr/bin/bash
+#!/bin/bash
 set -o errexit -o pipefail
 DIR=$(dirname "${0}")
 MAIN_DIR=$(readlink -f "${DIR}/..")
-- 
2.35.1

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

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

* [Buildroot] [PATCH 2/2] utils/docker-run: allow interactive use
  2022-02-14 16:24 [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang Luca Ceresoli
@ 2022-02-14 16:24 ` Luca Ceresoli
  2022-02-14 16:28   ` Giulio Benetti
  2022-02-14 16:36 ` [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang Yann E. MORIN
  2022-02-14 17:04 ` Yann E. MORIN
  2 siblings, 1 reply; 5+ messages in thread
From: Luca Ceresoli @ 2022-02-14 16:24 UTC (permalink / raw)
  To: buildroot
  Cc: Luca Ceresoli, Giulio Benetti, Yann E . MORIN,
	Ricardo Martincoski

Without -i, the container cannot be used interactively. Allow using it as
in:

  $ ./utils/docker-run
  + exec docker run -v /home/ceresoli/devel/buildroot:/home/br-user -it registry.gitlab.com/buildroot.org/buildroot/base:20220206.1756
  br-user@1e9508a4ccbb:~$ ls
  arch  board  boot  CHANGES  Config.in  Config.in.legacy  configs  COPYING  DEVELOPERS  docs  fs  linux	Makefile  Makefile.legacy  output  package  README  support  system  toolchain	utils
  br-user@1e9508a4ccbb:~$

Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
---
 utils/docker-run | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/docker-run b/utils/docker-run
index 979aec69b946..9fb895bcc628 100755
--- a/utils/docker-run
+++ b/utils/docker-run
@@ -7,4 +7,4 @@ IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | \
         sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g')
 
 set -x
-exec docker run -v "${MAIN_DIR}:/home/br-user" -t "${IMAGE}" "$@"
+exec docker run -v "${MAIN_DIR}:/home/br-user" -it "${IMAGE}" "$@"
-- 
2.35.1

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

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

* Re: [Buildroot] [PATCH 2/2] utils/docker-run: allow interactive use
  2022-02-14 16:24 ` [Buildroot] [PATCH 2/2] utils/docker-run: allow interactive use Luca Ceresoli
@ 2022-02-14 16:28   ` Giulio Benetti
  0 siblings, 0 replies; 5+ messages in thread
From: Giulio Benetti @ 2022-02-14 16:28 UTC (permalink / raw)
  To: Luca Ceresoli, buildroot; +Cc: Yann E . MORIN, Ricardo Martincoski

Hi Luca,

On 14/02/22 17:24, Luca Ceresoli wrote:
> Without -i, the container cannot be used interactively. Allow using it as
> in:
> 
>    $ ./utils/docker-run
>    + exec docker run -v /home/ceresoli/devel/buildroot:/home/br-user -it registry.gitlab.com/buildroot.org/buildroot/base:20220206.1756
>    br-user@1e9508a4ccbb:~$ ls
>    arch  board  boot  CHANGES  Config.in  Config.in.legacy  configs  COPYING  DEVELOPERS  docs  fs  linux	Makefile  Makefile.legacy  output  package  README  support  system  toolchain	utils
>    br-user@1e9508a4ccbb:~$
> 
> Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
> ---
>   utils/docker-run | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/docker-run b/utils/docker-run
> index 979aec69b946..9fb895bcc628 100755
> --- a/utils/docker-run
> +++ b/utils/docker-run
> @@ -7,4 +7,4 @@ IMAGE=$(grep ^image: "${MAIN_DIR}/.gitlab-ci.yml" | \
>           sed -e 's,^image: ,,g' | sed -e 's,\$CI_REGISTRY,registry.gitlab.com,g')
>   
>   set -x
> -exec docker run -v "${MAIN_DIR}:/home/br-user" -t "${IMAGE}" "$@"
> +exec docker run -v "${MAIN_DIR}:/home/br-user" -it "${IMAGE}" "$@"

Can you please also add --rm option too to avoid having a lot of exited 
containers?
It should go into another patch.

Thank you!
Best regards
-- 
Giulio Benetti
Benetti Engineering sas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang
  2022-02-14 16:24 [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang Luca Ceresoli
  2022-02-14 16:24 ` [Buildroot] [PATCH 2/2] utils/docker-run: allow interactive use Luca Ceresoli
@ 2022-02-14 16:36 ` Yann E. MORIN
  2022-02-14 17:04 ` Yann E. MORIN
  2 siblings, 0 replies; 5+ messages in thread
From: Yann E. MORIN @ 2022-02-14 16:36 UTC (permalink / raw)
  To: Luca Ceresoli; +Cc: Giulio Benetti, Ricardo Martincoski, buildroot

Luca, All,

On 2022-02-14 17:24 +0100, Luca Ceresoli spake thusly:
> /usr/bin/bash does not exist on Ubuntu 2018.04. Use the more portable
> alternative /bin/bash.
> 
> Note that currently "/usr/bin/bash" does not appear anywhere in the
> Buildroot source code, while "/bin/bash" is used by many scripts.

The real portable solution is to use /usr/bin/env, which is mandated by
POSIX:
    #!/usr/bin/env bash

and which we already use quite a bit:
    $ git grep 'env bash' |wc -l 
    34

(No need to respin, it can be fixed when applying, I guess...)

Regards,
Yann E. MORIN.

> Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
> Fixes: 242e9d72e7d2 ("utils/docker-run: new script")
> ---
>  utils/docker-run | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/docker-run b/utils/docker-run
> index 0614f1325d78..979aec69b946 100755
> --- a/utils/docker-run
> +++ b/utils/docker-run
> @@ -1,4 +1,4 @@
> -#!/usr/bin/bash
> +#!/bin/bash
>  set -o errexit -o pipefail
>  DIR=$(dirname "${0}")
>  MAIN_DIR=$(readlink -f "${DIR}/..")
> -- 
> 2.35.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

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

* Re: [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang
  2022-02-14 16:24 [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang Luca Ceresoli
  2022-02-14 16:24 ` [Buildroot] [PATCH 2/2] utils/docker-run: allow interactive use Luca Ceresoli
  2022-02-14 16:36 ` [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang Yann E. MORIN
@ 2022-02-14 17:04 ` Yann E. MORIN
  2 siblings, 0 replies; 5+ messages in thread
From: Yann E. MORIN @ 2022-02-14 17:04 UTC (permalink / raw)
  To: Luca Ceresoli; +Cc: Giulio Benetti, Ricardo Martincoski, buildroot

Luca, All,

Series of two applied to master, thanks.

As Giulio requested, an additional patch to use --rm would be nice.

And now there is something that strikes me: we bind-mount the Buildroot
tree as the home of the br-user, so we don't have any file from the
br-user avvailable at all, so we can as well run the container with the
local user, by running with:

        --user $(id -u):$(id -g)

This way, there wil no longer be any issue with file acccess rights.

There would however be the issue that the paths in the container would
not be the same as on the host, but we can also alleviate that isue by
doing the bind-mount in the same location (Docker creates the montpoint
if it does not exists prior do doing the mount), and change the cwd:

    exec docker run \
        -it --rm \
        --workdir "${MAIN_DIR}" \
        --mount "type=bind,src=${MAIN_DIR},dst=${MAIN_DIR}" \
        "${IMAGE}" \
        "$@"

Et voilà, that's much more interesting now! :-]

Care to send a patch please? ;-)

Regards,
Yann E. MORIN.

On 2022-02-14 17:24 +0100, Luca Ceresoli spake thusly:
> /usr/bin/bash does not exist on Ubuntu 2018.04. Use the more portable
> alternative /bin/bash.
> 
> Note that currently "/usr/bin/bash" does not appear anywhere in the
> Buildroot source code, while "/bin/bash" is used by many scripts.
> 
> Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
> Fixes: 242e9d72e7d2 ("utils/docker-run: new script")
> ---
>  utils/docker-run | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/docker-run b/utils/docker-run
> index 0614f1325d78..979aec69b946 100755
> --- a/utils/docker-run
> +++ b/utils/docker-run
> @@ -1,4 +1,4 @@
> -#!/usr/bin/bash
> +#!/bin/bash
>  set -o errexit -o pipefail
>  DIR=$(dirname "${0}")
>  MAIN_DIR=$(readlink -f "${DIR}/..")
> -- 
> 2.35.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] 5+ messages in thread

end of thread, other threads:[~2022-02-14 17:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-14 16:24 [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang Luca Ceresoli
2022-02-14 16:24 ` [Buildroot] [PATCH 2/2] utils/docker-run: allow interactive use Luca Ceresoli
2022-02-14 16:28   ` Giulio Benetti
2022-02-14 16:36 ` [Buildroot] [PATCH 1/2] utils/docker-run: use portable bash shebang Yann E. MORIN
2022-02-14 17:04 ` Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.