[Buildroot] [PATCH 2/2] utils/docker-run: propagate user's proxy settings

yann.morin at orange.com yann.morin at orange.com
Tue Oct 31 10:22:17 UTC 2023


From: "Yann E. MORIN" <yann.morin at orange.com>

When dealing in enterprise-grade networks, it is more often than not the
case that the wider internet is unreachable but through proxies.

There is a usual set of variables that users can set in the environment
to point various tools (curl, git...) to use those proxies.

Propagate those variables inside the container.

Note that there are a few tools (e.g. cvs, svn) that may not recognise
those variables; instead, they require custom setup that is too complex
to handle, so is left as an exercise to interested parties.

Similarly, there exists another type of proxy, socks4 or socks5, that
also requires custom setup that is not trivial to replicate in a
container, so is also left out as an exrcise for interested parties.

In the large majority of cases, those few variables are enough to Make
Things Work™.

Signed-off-by: Yann E. MORIN <yann.morin at orange.com>
Cc: Ricardo Martincoski <ricardo.martincoski at datacom.com.br>
---
 utils/docker-run | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/utils/docker-run b/utils/docker-run
index 464cbf691f..79694474c1 100755
--- a/utils/docker-run
+++ b/utils/docker-run
@@ -29,6 +29,26 @@ declare -a mountpoints=(
     "$(pwd)"
 )
 
+# curl lists (and recognises and uses) other types of *_proxy variables,
+# but only those make sense for Buildroot:
+for env in all_proxy http_proxy https_proxy ftp_proxy no_proxy; do
+    if [ "${!env}" ]; then
+        docker_opts+=( --env "${env}" )
+        # The lower-case variant takes precedence on the upper-case one
+        # (dixit curl)
+        continue
+    fi
+    # http_proxy is only lower-case (dixit curl)
+    if [ "${env}" = http_proxy ]; then
+        continue
+    fi
+    # All the others also exist in the upper-case variant
+    env="${env^^}"
+    if [ "${!env}" ]; then
+        docker_opts+=( --env "${env}" )
+    fi
+done
+
 # Empty GIT_DIR means that we are not in a workdir, *and* git is too old
 # to know about worktrees, so we're not in a worktree either. So it means
 # we're in the main git working copy, and thus we don't need to mount the
-- 
2.34.1

____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.


More information about the buildroot mailing list