Skip to contentSkip to conversation

utils/brmake: simplifications and cleanups (branch yem/brmake-docker)

PATCH In review Yann E. MORIN 2 participants 6 messages Feb 18, 2025

lore
Share & tools
lore
#0 lore raw

cover utils/brmake: simplifications and cleanups (branch yem/brmake-docker)

Hello All!

This small series cleanups and simplifies brmake to make it usable with docker-run like other commands: ./utils/docker-run ./utils/brmake

This is a follow-up to a discussion with Arnout when reviewing an unrelated change ([0] and replies).

[0] https://lore.kernel.org/buildroot/[email protected]/T/#m5ad1cfae86426b29ff6f15fa0c643be5a0c70de6

Regards,
Yann E. MORIN.

----------------------------------------------------------------
Yann E. MORIN (3):
utils/brnmake: drop use of unbuffer Revert "utils/brmake: add option to run in docker" utils/brmake: simplify redirection

 utils/brmake     | 15 ++-------------
 utils/readme.txt |  3 ---
 2 files changed, 2 insertions(+), 16 deletions(-)

--
.-----------------.--------------------.------------------.--------------------.

|  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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#1 lore raw

PATCH 1/3 utils/brnmake: drop use of unbuffer

When it was introduced in afdb545b2847 (tools: new tool to filter the output of make), brmake made use of unbuffer, so as to try and ensure that no output would get lost between make printing it, and the logger loop time-stamping it and storing it in the logfile, in case the user would interrup the build (SIGINT, ^C)

However, unbuffer is missing in our reference build image (we could have added it, but we missed the occasion to do so every time we updated the reference build image.

Furthermore, the rationale for using unbuffer, although reasonable, is not so practical: indeed, when the user hits Crtl-C, this is inherently asynchronous, and they can't expect everything to be entirely cleanly terminated, especially buffering. Using unbuffer is thus slightly superfluous.

Drop use of unbuffer.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>
---
 utils/brmake | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
utils/brmake +1 -6
index 4756016a0c..e5437d8f2c 100755
@@ -5,11 +5,6 @@
 main() {
     local ret start d h m mf
 
-    if ! which unbuffer >/dev/null 2>&1; then
-        printf "you need to install 'unbuffer' (from package expect or expect-dev)\n" >&2
-        exit 1
-    fi
-
     start=${SECONDS}
 
     if [ -n "$BR2_DOCKER" ]; then
@@ -18,7 +13,7 @@ main() {
         docker=()
     fi
 
-    ( exec 2>&1; unbuffer "${docker[@]}" make "${@}"; ) \
+    ( exec 2>&1; "${docker[@]}" make "${@}"; ) \
     > >( while read -r line; do
              printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
          done \
Signature · 6 lines
2.47.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH 2/3 Revert "utils/brmake: add option to run in docker"

In reply to Yann E. MORIN

All our documented uses of utils/docker-run, besides running it standalone to get an interactive shell, is to use it as a prefix to the otherwise standard command to run, e.g.:
- ./utils/docker-run make foo_defconfig
- ./utils/docker-run make menuconfig
- ./utils/docker-run make
- ./utils/docker-run make check-package

Commit 8aad67f1575f (utils/brmake: add option to run in docker) departed from that usual convention, by hiding the call to docker-run inside brmake, conditioned by an environment variable. The only reason is that brmake internally used ubuffer. This is no longer the case, so we can now use brmake together with docker-run in the usual manner.

This basically reverts commit 8aad67f1575f1d8a9c90ccd70302e9a6823cf794, after resolving the conflict due to the removal of unbuffer in te previous commit.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>
---
 utils/brmake     | 8 +-------
 utils/readme.txt | 3 ---
 2 files changed, 1 insertion(+), 10 deletions(-)
utils/brmake +1 -7
index e5437d8f2c..4b9179e415 100755
@@ -7,13 +7,7 @@ main() {
 
     start=${SECONDS}
 
-    if [ -n "$BR2_DOCKER" ]; then
-        docker=("${0%/*}/docker-run")
-    else
-        docker=()
-    fi
-
-    ( exec 2>&1; "${docker[@]}" make "${@}"; ) \
+    ( exec 2>&1; make "${@}" ) \
     > >( while read -r line; do
              printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
          done \
utils/readme.txt +0 -3
index abff659d4f..b5862f1fb9 100644
@@ -7,9 +7,6 @@ brmake
     front of each line, redirects all of the build output to a file
     ("'br.log' in the current directory), and just outputs the Buildroot
     messages (those lines starting with >>>) on stdout.
-    To run this within a container using docker-run (see below), set
-    BR2_DOCKER=y in the environment, i.e. call it as
-    `BR2_DOCKER=y utils/brmake`.
     Do not run this script for interactive configuration (e.g. menuconfig)
     or on an unconfigured directory. The output is redirected so you will see
     nothing.
Signature · 6 lines
2.47.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH 2/3] Revert "utils/brmake: add option to run in docker"

Quoted 8 lines · Yann E. MORIN

All our documented uses of utils/docker-run, besides running it standalone to get an interactive shell, is to use it as a prefix to the otherwise standard command to run, e.g.:
- ./utils/docker-run make foo_defconfig
- ./utils/docker-run make menuconfig
- ./utils/docker-run make
- ./utils/docker-run make check-package

Quoted 4 lines

Commit 8aad67f1575f (utils/brmake: add option to run in docker) departed from that usual convention, by hiding the call to docker-run inside brmake, conditioned by an environment variable. The only reason is that brmake internally used ubuffer.

The other reason is that the TZ setting is not propagated into the container
so the timestamps are in UTC. But anyway, none of the local settings (e.g. locale :-) ) are propagated, so it's not so important.

Regards,
Arnout

Quoted 38 lines

This is no longer the case, so we can
now use brmake together with docker-run in the usual manner.

This basically reverts commit 8aad67f1575f1d8a9c90ccd70302e9a6823cf794, after resolving the conflict due to the removal of unbuffer in te previous commit.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>
---
  utils/brmake     | 8 +-------
  utils/readme.txt | 3 ---
  2 files changed, 1 insertion(+), 10 deletions(-)
utils/brmake +1 -7
index e5437d8f2c..4b9179e415 100755
@@ -7,13 +7,7 @@ main() {
 
      start=${SECONDS}
 
-    if [ -n "$BR2_DOCKER" ]; then
-        docker=("${0%/*}/docker-run")
-    else
-        docker=()
-    fi
-
-    ( exec 2>&1; "${docker[@]}" make "${@}"; ) \
+    ( exec 2>&1; make "${@}" ) \
      > >( while read -r line; do
               printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
           done \
utils/readme.txt +0 -0
index abff659d4f..b5862f1fb9 100644

utils/readme.txt brmake · line 12

Quoted 9 lines
utils/readme.txt +0 -3
@@ -7,9 +7,6 @@ brmake
      front of each line, redirects all of the build output to a file
      ("'br.log' in the current directory), and just outputs the Buildroot
      messages (those lines starting with >>>) on stdout.
-    To run this within a container using docker-run (see below), set
-    BR2_DOCKER=y in the environment, i.e. call it as
-    `BR2_DOCKER=y utils/brmake`.
      Do not run this script for interactive configuration (e.g. menuconfig)
      or on an unconfigured directory. The output is redirected so you will see
      nothing.

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

PATCH 3/3 utils/brmake: simplify redirection

In reply to Yann E. MORIN

We want to redirect both stout and stderr to the log, so just do both redirections at once. This simplifies the call to make, which was inherited from afdb545b2847 (tools: new tool to filter the output of make) when brmake was using unbuffer (and even then it was not entirely waranted to do the redirection that way).

---
 utils/brmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utils/brmake +2 -2
index 4b9179e415..a4b9e7fa71 100755
@@ -7,8 +7,8 @@ main() {
 
     start=${SECONDS}
 
-    ( exec 2>&1; make "${@}" ) \
-    > >( while read -r line; do
+    make "${@}" \
+    &> >( while read -r line; do
              printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
          done \
          |tee -a br.log \
Signature · 6 lines
2.47.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw
In reply to Yann E. MORIN
Quoted 9 lines · Yann E. MORIN

Hello All!

This small series cleanups and simplifies brmake to make it usable with docker-run like other commands: ./utils/docker-run ./utils/brmake

This is a follow-up to a discussion with Arnout when reviewing an unrelated change ([0] and replies).

[0] https://lore.kernel.org/buildroot/[email protected]/T/#m5ad1cfae86426b29ff6f15fa0c643be5a0c70de6

Series applied to master, thanks.

Regards,
Arnout

Quoted 15 lines

Regards,
Yann E. MORIN.

----------------------------------------------------------------
Yann E. MORIN (3):
utils/brnmake: drop use of unbuffer Revert "utils/brmake: add option to run in docker" utils/brmake: simplify redirection

  utils/brmake     | 15 ++-------------
  utils/readme.txt |  3 ---
  2 files changed, 2 insertions(+), 16 deletions(-)
Quoted 7 lines

--
.-----------------.--------------------.------------------.--------------------.

|  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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot