Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] utils/brmake: add option to run in docker
@ 2024-10-23 12:22 Arnout Vandecappelle via buildroot
  2024-10-23 20:10 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Arnout Vandecappelle via buildroot @ 2024-10-23 12:22 UTC (permalink / raw)
  To: buildroot

At the moment, it is difficult to combine brmake with docker-run.
`docker-run brmake ...` doesn't work because our docker image doesn't
have unbuffer. In addition, inside the container the timezone is UTC,
but you probably want the timestamps added by brmake to be in local
time. Therefore, it's better to have the call to docker-run nested
inside brmake.

Currently, brmake doesn't have any way to pass parameters, all of "$@"
is passed unchanged to the `make` invocation. Thus, there is no
established way to pass in the option whether or not to use docker. We
choose to use an environment variable to pass in the option. The
convention is that such a buildroot-specific environment variable should
start with BR2_, so we choose BR2_DOCKER.

Run make inside docker-run if the BR2_DOCKER environment variable is
set. Update utils/readme.txt (the only existing documentation of brmake)
with this information.

Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
---
 utils/brmake     | 8 +++++++-
 utils/readme.txt | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/utils/brmake b/utils/brmake
index 70dfb6cdc8..4756016a0c 100755
--- a/utils/brmake
+++ b/utils/brmake
@@ -12,7 +12,13 @@ main() {
 
     start=${SECONDS}
 
-    ( exec 2>&1; unbuffer make "${@}"; ) \
+    if [ -n "$BR2_DOCKER" ]; then
+        docker=("${0%/*}/docker-run")
+    else
+        docker=()
+    fi
+
+    ( exec 2>&1; unbuffer "${docker[@]}" make "${@}"; ) \
     > >( while read -r line; do
              printf "%(%Y-%m-%dT%H:%M:%S)T %s\n" -1 "${line}"
          done \
diff --git a/utils/readme.txt b/utils/readme.txt
index b5862f1fb9..abff659d4f 100644
--- a/utils/readme.txt
+++ b/utils/readme.txt
@@ -7,6 +7,9 @@ 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.
-- 
2.47.0

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

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

end of thread, other threads:[~2024-10-23 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 12:22 [Buildroot] [PATCH] utils/brmake: add option to run in docker Arnout Vandecappelle via buildroot
2024-10-23 20:10 ` Thomas Petazzoni via buildroot

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