aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-19 17:57:10 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-02-20 16:45:06 +0000
commitc73bb6023c73f003a160bb02aa4da1b580b86c23 (patch)
treea8d422c30b3dc1df5170bfe428bffee80ea5f09e
parent52630eefb5174e4ca357ac57085093a7f5767bd8 (diff)
downloadbitbake-c73bb6023c73f003a160bb02aa4da1b580b86c23.tar.gz
fetch2: Abstract fetcher environment to a function
The changing of the environment inside the wget fetcher can race if threading is used, such as with sstate in OE-Core. Abstract the function so the environment can be correct before the function is called, removing the race since the enviroment is then no longer changed. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/fetch2/__init__.py11
-rw-r--r--lib/bb/fetch2/wget.py9
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index a7e84e0dc..35fae6623 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -851,6 +851,17 @@ FETCH_EXPORT_VARS = ['HOME', 'PATH',
'AWS_SECRET_ACCESS_KEY',
'AWS_DEFAULT_REGION']
+def get_fetcher_environment(d):
+ newenv = {}
+ origenv = d.getVar("BB_ORIGENV")
+ for name in bb.fetch2.FETCH_EXPORT_VARS:
+ value = d.getVar(name)
+ if not value and origenv:
+ value = origenv.getVar(name)
+ if value:
+ newenv[name] = value
+ return newenv
+
def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None, workdir=None):
"""
Run cmd returning the command output
diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 92cc10785..b3a3de571 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -315,14 +315,7 @@ class Wget(FetchMethod):
# Avoid tramping the environment too much by using bb.utils.environment
# to scope the changes to the build_opener request, which is when the
# environment lookups happen.
- newenv = {}
- origenv = d.getVar("BB_ORIGENV")
- for name in bb.fetch2.FETCH_EXPORT_VARS:
- value = d.getVar(name)
- if not value and origenv:
- value = origenv.getVar(name)
- if value:
- newenv[name] = value
+ newenv = bb.fetch2.get_fetcher_environment(d)
with bb.utils.environment(**newenv):
import ssl