utils.py: Add clean_environment() function and call where appropriate (from Poky)
authorRichard Purdie <rpurdie@linux.intel.com>
Sat, 6 Dec 2008 12:27:37 +0000 (12:27 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Sat, 6 Dec 2008 12:27:37 +0000 (12:27 +0000)
bin/bitbake
lib/bb/fetch/wget.py
lib/bb/utils.py

index 0087be3..6a69e34 100755 (executable)
@@ -116,15 +116,9 @@ Default BBFILES are the .bb files in the current directory.""" )
 
     cooker = bb.cooker.BBCooker(configuration)
 
-    # Optionally clean up the environment
-    if 'BB_PRESERVE_ENV' not in os.environ:
-        if 'BB_ENV_WHITELIST' in os.environ:
-            good_vars = os.environ['BB_ENV_WHITELIST'].split()
-        else:
-            good_vars = bb.utils.preserved_envvars_list()
-        if 'BB_ENV_EXTRAWHITE' in os.environ:
-            good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
-        bb.utils.filter_environment(good_vars)
+    # Clear away any spurious environment variables. But don't wipe the
+    # environment totally.
+    bb.utils.clean_environment()
 
     cooker.parseConfiguration()
 
index 739d5a1..0008a28 100644 (file)
@@ -60,9 +60,34 @@ class Wget(Fetch):
             else:
                 fetchcmd = data.getVar("FETCHCOMMAND", d, 1)
 
+            uri = uri.split(";")[0]
+            uri_decoded = list(bb.decodeurl(uri))
+            uri_type = uri_decoded[0]
+            uri_host = uri_decoded[1]
+
             bb.msg.note(1, bb.msg.domain.Fetcher, "fetch " + uri)
             fetchcmd = fetchcmd.replace("${URI}", uri)
             fetchcmd = fetchcmd.replace("${FILE}", ud.basename)
+            httpproxy = None
+            ftpproxy = None
+            if uri_type == 'http':
+                httpproxy = data.getVar("HTTP_PROXY", d, True)
+                httpproxy_ignore = (data.getVar("HTTP_PROXY_IGNORE", d, True) or "").split()
+                for p in httpproxy_ignore:
+                    if uri_host.endswith(p):
+                        httpproxy = None
+                        break
+            if uri_type == 'ftp':
+                ftpproxy = data.getVar("FTP_PROXY", d, True)
+                ftpproxy_ignore = (data.getVar("HTTP_PROXY_IGNORE", d, True) or "").split()
+                for p in ftpproxy_ignore:
+                    if uri_host.endswith(p):
+                        ftpproxy = None
+                        break
+            if httpproxy:
+                fetchcmd = "http_proxy=" + httpproxy + " " + fetchcmd
+            if ftpproxy:
+                fetchcmd = "ftp_proxy=" + ftpproxy + " " + fetchcmd
             bb.msg.debug(2, bb.msg.domain.Fetcher, "executing " + fetchcmd)
             ret = os.system(fetchcmd)
             if ret != 0:
index ba3089d..aebeb33 100644 (file)
@@ -359,6 +359,21 @@ def filter_environment(good_vars):
 
     return removed_vars
 
+def clean_environment():
+    """
+    Clean up any spurious environment variables. This will remove any
+    variables the user hasn't chose to preserve.
+    """
+    if 'BB_PRESERVE_ENV' not in os.environ:
+        if 'BB_ENV_WHITELIST' in os.environ:
+            good_vars = os.environ['BB_ENV_WHITELIST'].split()
+        else:
+            good_vars = preserved_envvars_list()
+        if 'BB_ENV_EXTRAWHITE' in os.environ:
+            good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
+        filter_environment(good_vars)
+
+
 def prunedir(topdir):
     # Delete everything reachable from the directory named in 'topdir'.
     # CAUTION:  This is dangerous!