From 59bb1c43a4c6d3a628edb4a2ebf4672549af9b78 Mon Sep 17 00:00:00 2001 From: Fiona Klute Date: Sun, 5 Apr 2026 20:56:08 +0200 Subject: [PATCH] utils/docker-run: mount and pass BR2_EXTERNAL dirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. The --mount option needs an absolute path for the destination. Make the paths absolute the same way br2-external itself does it. Do not use realpath since that resolves symlinks and would make it different from what is in the BR2_EXTERNAL variable. Signed-off-by: Fiona Klute Signed-off-by: Arnout Vandecappelle (cherry picked from commit ddd4788c1f1f047398aa028954381372b5ce47be) Signed-off-by: Raphaël Mélotte --- utils/docker-run | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils/docker-run b/utils/docker-run index 8cb15c9c48..675e945193 100755 --- a/utils/docker-run +++ b/utils/docker-run @@ -97,6 +97,17 @@ if [ "${BR2_DL_DIR}" ]; then docker_opts+=( --env BR2_DL_DIR ) fi +# 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. +if [ "${BR2_EXTERNAL+set}" ]; then + docker_opts+=( --env BR2_EXTERNAL ) + for br2_ext in ${BR2_EXTERNAL//:/ }; do + # bind volume source paths must be absolute + mountpoints+=( "$(cd "${br2_ext}" && pwd)" ) + 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}" )