Skip to contentSkip to conversation

bb/utils: include SSL certificate paths in export_proxies

PATCH Superseded Ross Burton 2 participants 3 messages Jan 26, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bb/utils: include SSL certificate paths in export_proxies

bb.utils.export_proxies() is a poor-man's alternative for the environment setup code in bb/fetch2, but it's used in several places where recipes want to download manually (such as cve-update-db-native).

Notably, export_proxies() doesn't pass on the SSL certificate paths from the original environment, so if SSL_CERT_FILE needs to be set (for example, in a buildtools environment) then proxies work but SSL doesn't.

In an ideal world export_proxies and the same logic in fetch2 would merge, but until then we can add the SSL_CERT_ variables and duplicate the basic logic: check the datastore first and then the original environment for variables.

Also remove the return value as nothing ever checked it.

[ YOCTO #15000 ]

---
 bitbake/lib/bb/utils.py | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
bitbake/lib/bb/utils.py +9 -12
index 8c791595730..bfbc48b6cd9 100644
@@ -1699,23 +1699,20 @@ def disable_network(uid=None, gid=None):
 
 def export_proxies(d):
     """ export common proxies variables from datastore to environment """
-    import os
 
     variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY',
                     'ftp_proxy', 'FTP_PROXY', 'no_proxy', 'NO_PROXY',
-                    'GIT_PROXY_COMMAND']
-    exported = False
+                    'GIT_PROXY_COMMAND', 'SSL_CERT_FILE', 'SSL_CERT_DIR']
 
-    for v in variables:
-        if v in os.environ.keys():
-            exported = True
-        else:
-            v_proxy = d.getVar(v)
-            if v_proxy is not None:
-                os.environ[v] = v_proxy
-                exported = True
+    origenv = d.getVar("BB_ORIGENV")
 
-    return exported
+    for name in variables:
+        value = d.getVar(name)
+        if not value and origenv:
+            value = origenv.getVar(name)
+        if value:
+            os.environ[name] = value
+    return os
 
 
 def load_plugins(logger, plugins, pluginpath):
Signature · 1 line
2.34.1
#1 lore raw
Quoted 47 lines · Ross Burton

bb.utils.export_proxies() is a poor-man's alternative for the environment setup code in bb/fetch2, but it's used in several places where recipes want to download manually (such as cve-update-db-native).

Notably, export_proxies() doesn't pass on the SSL certificate paths from the original environment, so if SSL_CERT_FILE needs to be set (for example, in a buildtools environment) then proxies work but SSL doesn't.

In an ideal world export_proxies and the same logic in fetch2 would merge, but until then we can add the SSL_CERT_ variables and duplicate the basic logic: check the datastore first and then the original environment for variables.

Also remove the return value as nothing ever checked it.

[ YOCTO #15000 ]

---
 bitbake/lib/bb/utils.py | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
bitbake/lib/bb/utils.py +2 -11
index 8c791595730..bfbc48b6cd9 100644
@@ -1699,23 +1699,20 @@ def disable_network(uid=None, gid=None):
 
 def export_proxies(d):
     """ export common proxies variables from datastore to environment """
-    import os
 
     variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY',
                     'ftp_proxy', 'FTP_PROXY', 'no_proxy', 'NO_PROXY',
-                    'GIT_PROXY_COMMAND']
-    exported = False
+                    'GIT_PROXY_COMMAND', 'SSL_CERT_FILE', 'SSL_CERT_DIR']
 
-    for v in variables:
-        if v in os.environ.keys():
-            exported = True
-        else:
-            v_proxy = d.getVar(v)
-            if v_proxy is not None:
-                os.environ[v] = v_proxy
-                exported = True
+    origenv = d.getVar("BB_ORIGENV")

bitbake/lib/bb/utils.py def disable_network(uid=None, gid=None): · line 1716

Quoted 10 lines
bitbake/lib/bb/utils.py +7 -1
 
-    return exported
+    for name in variables:
+        value = d.getVar(name)
+        if not value and origenv:
+            value = origenv.getVar(name)
+        if value:
+            os.environ[name] = value
+    return os
 

"return os"?

Cheers,

Richard

#2 lore raw
Quoted 4 lines
Quoted 2 lines

+ return os

"return os”?

Where the hell did that come from?!

v2 incoming...