Skip to contentSkip to conversation

utils/brmake: add option to run in docker

PATCH Applied Arnout Vandecappelle via buildroot 1 participant 2 messages Oct 23, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils/brmake: add option to run in docker

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.

---
 utils/brmake     | 8 +++++++-
 utils/readme.txt | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)
utils/brmake +7 -1
index 70dfb6cdc8..4756016a0c 100755
@@ -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 \
utils/readme.txt +3 -0
index b5862f1fb9..abff659d4f 100644
@@ -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.
Signature · 6 lines
2.47.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 18 lines · On Wed, 23 Oct 2024 14:22:34 +0200 Arnout Vandecappelle via 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.

Quoted 5 lines
---
 utils/brmake     | 8 +++++++-
 utils/readme.txt | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot