diff mbox series

[next,v4,1/1] utils/docker-run: mount and pass BR2_EXTERNAL dirs

Message ID 20240831191919.370005-1-fiona.klute@gmx.de
State New
Headers show
Series [next,v4,1/1] utils/docker-run: mount and pass BR2_EXTERNAL dirs | expand

Commit Message

Fiona Klute Aug. 31, 2024, 7:19 p.m. UTC
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>

The BR2_EXTERNAL environment variable is passed into the container,
and each path listed in it mounted. This allows using external trees
when running a build using utils/docker-run. Testing the existence of
the variable instead of a non-empty value allows passing an empty
BR2_EXTERNAL variable to disable currently set external trees.

Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
Brandon, I've dropped your reviewed-by because the changes from v3 are
significant and counter to what you suggested in previous
reviews. Feel free to re-add it (or not).

Changes v3 -> v4:
* Split BR2_EXTERNAL on spaces OR colons
* Revert changes to mountpoints processing loop

Changes v2 -> v3:
* Use read to make the loop that creates mount options more robust,
  removing pre-exisiting shellcheck override. Suggested by Brandon
  Maier.

Changes v1 -> v2:
* Correctly handle spaces in external tree paths

 utils/docker-run | 7 +++++++
 1 file changed, 7 insertions(+)

--
2.45.2
diff mbox series

Patch

diff --git a/utils/docker-run b/utils/docker-run
index 1adb02d74e..9579f83ce2 100755
--- a/utils/docker-run
+++ b/utils/docker-run
@@ -90,6 +90,13 @@  if [ "${BR2_DL_DIR}" ]; then
     docker_opts+=( --env BR2_DL_DIR )
 fi

+if [ -v BR2_EXTERNAL ]; then
+    docker_opts+=( --env BR2_EXTERNAL )
+    for br2_ext in ${BR2_EXTERNAL//:/ }; do
+        mountpoints+=( "${br2_ext}" )
+    done
+fi
+
 # shellcheck disable=SC2013 # can't use while-read because of the assignment
 for dir in $(printf '%s\n' "${mountpoints[@]}" |LC_ALL=C sort -u); do
     docker_opts+=( --mount "type=bind,src=${dir},dst=${dir}" )