All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mingrui Ren" <jiladahe1997@gmail.com>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Cc: richard.purdie <richard.purdie@linuxfoundation.org>
Subject: [PATCH] Add a new variable:'FETCH_ENV_WHITELIST'
Date: Fri, 9 Jul 2021 09:44:17 +0800	[thread overview]
Message-ID: <202107090944160361815@gmail.com> (raw)

From d228100b7551b2327d66072b03f2a809744e8f52 Mon Sep 17 00:00:00 2001
From: Mingrui Ren <jiladahe1997@gmail.com>
Date: Thu, 8 Jul 2021 23:44:53 +0800
Subject: [PATCH] Add a new variable:'FETCH_ENV_WHITELIST'

The enviroment variables used by Fetcher are hard-coded, and are obtained
from HOST env instead of bitbake datastore.
This patch adds a new variable 'FETCH_ENV_WHITELIST' similar to 
'BB_ENV_EXTRAWHITE', trying to fix the problems above.

Signed-off-by: Mingrui Ren <jiladahe1997@gmail.com>
---
The situation I encountered was that I tried to use a custom git-proxy by
setting GIT_PROXY_COMMAND and SOCK_PROXY enviroment variables. However, 
I found that even if I set BB_ENV_EXTRAWHITE, the SOCK_PROXY variable does
not work.

 bitbake/lib/bb/fetch2/__init__.py | 16 +---------------
 bitbake/lib/bb/utils.py           |  5 +++++
 scripts/oe-buildenv-internal      |  7 +++++++
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index c8e91262a9..7cdc6c5ee8 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -820,21 +820,7 @@ def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None, workdir=None):
     # rather than host provided
     # Also include some other variables.
     # FIXME: Should really include all export varaiables?
-    exportvars = ['HOME', 'PATH',
-                  'HTTP_PROXY', 'http_proxy',
-                  'HTTPS_PROXY', 'https_proxy',
-                  'FTP_PROXY', 'ftp_proxy',
-                  'FTPS_PROXY', 'ftps_proxy',
-                  'NO_PROXY', 'no_proxy',
-                  'ALL_PROXY', 'all_proxy',
-                  'GIT_PROXY_COMMAND',
-                  'GIT_SSH',
-                  'GIT_SSL_CAINFO',
-                  'GIT_SMART_HTTP',
-                  'SSH_AUTH_SOCK', 'SSH_AGENT_PID',
-                  'SOCKS5_USER', 'SOCKS5_PASSWD',
-                  'DBUS_SESSION_BUS_ADDRESS',
-                  'P4CONFIG']
+    exportvars = (d.getVar("FETCH_ENV_WHITELIST") or "").split()

     if not cleanup:
         cleanup = []
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 6ba1d2a376..6676584845 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -585,6 +585,7 @@ def preserved_envvars():
         'BB_PRESERVE_ENV',
         'BB_ENV_WHITELIST',
         'BB_ENV_EXTRAWHITE',
+        'FETCH_ENV_WHITELIST',
     ]
     return v + preserved_envvars_exported()

@@ -630,6 +631,10 @@ def approved_variables():
         approved.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
         if 'BB_ENV_EXTRAWHITE' not in approved:
             approved.extend(['BB_ENV_EXTRAWHITE'])
+    if 'FETCH_ENV_WHITELIST' in os.environ:
+        approved.extend(os.environ['FETCH_ENV_WHITELIST'].split())
+        if 'FETCH_ENV_WHITELIST' not in approved:
+            approved.extend(['FETCH_ENV_WHITELIST'])
     return approved

 def clean_environment():
diff --git a/scripts/oe-buildenv-internal b/scripts/oe-buildenv-internal
index e0d920f2fc..39aa2f2444 100755
--- a/scripts/oe-buildenv-internal
+++ b/scripts/oe-buildenv-internal
@@ -106,6 +106,13 @@ unset BITBAKEDIR newpath
 export BUILDDIR
 export PATH

+FETCH_ENV_WHITELIST="HOME PATH HTTP_PROXY http_proxy HTTPS_PROXY https_proxy \
+FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy NO_PROXY no_proxy ALL_PROXY all_proxy \
+GIT_PROXY_COMMAND GIT_SSH GIT_SSL_CAINFO GIT_SMART_HTTP SSH_AUTH_SOCK SSH_AGENT_PID \
+SOCKS5_USER SOCKS5_PASSWD DBUS_SESSION_BUS_ADDRESS P4CONFIG"
+
+export FETCH_ENV_WHITELIST
+
 BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
--
2.20.1

             reply	other threads:[~2021-07-09  1:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09  1:44 Mingrui Ren [this message]
2021-07-09  8:50 ` [PATCH] Add a new variable:'FETCH_ENV_WHITELIST' Richard Purdie
2021-07-10  2:48   ` Mingrui Ren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202107090944160361815@gmail.com \
    --to=jiladahe1997@gmail.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.