From 8aad67f1575f1d8a9c90ccd70302e9a6823cf794 Mon Sep 17 00:00:00 2001 From: Arnout Vandecappelle Date: Wed, 23 Oct 2024 14:22:34 +0200 Subject: [PATCH] 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. Signed-off-by: Arnout Vandecappelle Signed-off-by: Thomas Petazzoni --- 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.