Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 1/2] utils/docker-run: mount and pass BR2_EXTERNAL dirs
@ 2024-07-13 19:22 Fiona Klute via buildroot
  2024-07-13 19:22 ` [Buildroot] [PATCH v3 2/2] support/scripts/br2-external: allow spaces in dirname Fiona Klute via buildroot
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Fiona Klute via buildroot @ 2024-07-13 19:22 UTC (permalink / raw)
  To: buildroot
  Cc: Thomas Petazzoni, Brandon Maier, Fiona Klute (WIWA),
	Ricardo Martincoski

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>
---
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 | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/utils/docker-run b/utils/docker-run
index 1adb02d74e..dbb9c45fdd 100755
--- a/utils/docker-run
+++ b/utils/docker-run
@@ -90,10 +90,17 @@ if [ "${BR2_DL_DIR}" ]; then
     docker_opts+=( --env BR2_DL_DIR )
 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
+if [ -v BR2_EXTERNAL ]; then
+    IFS=":" read -r -a br2_ext_arr <<< "${BR2_EXTERNAL}"
+    for br2_ext in "${br2_ext_arr[@]}"; do
+        mountpoints+=( "${br2_ext}" )
+    done
+    docker_opts+=( --env BR2_EXTERNAL )
+fi
+
+while IFS=$'\n' read -r dir; do
     docker_opts+=( --mount "type=bind,src=${dir},dst=${dir}" )
-done
+done < <(printf '%s\n' "${mountpoints[@]}" | LC_ALL=C sort -u)

 if tty -s; then
     docker_opts+=( -t )
--
2.45.2

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

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

end of thread, other threads:[~2024-08-31 19:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-13 19:22 [Buildroot] [PATCH v3 1/2] utils/docker-run: mount and pass BR2_EXTERNAL dirs Fiona Klute via buildroot
2024-07-13 19:22 ` [Buildroot] [PATCH v3 2/2] support/scripts/br2-external: allow spaces in dirname Fiona Klute via buildroot
2024-07-13 19:38   ` Brandon Maier via buildroot
2024-08-30 21:38   ` Yann E. MORIN
2024-08-31 17:07     ` Fiona Klute via buildroot
2024-07-13 19:38 ` [Buildroot] [PATCH v3 1/2] utils/docker-run: mount and pass BR2_EXTERNAL dirs Brandon Maier via buildroot
2024-08-30 21:35 ` Yann E. MORIN
2024-08-31 16:57   ` Fiona Klute via buildroot
2024-08-31 18:14     ` Yann E. MORIN
2024-08-31 19:22       ` Fiona Klute via buildroot

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