fetch: pass full env to fetcher (for proxy vars)
authorZac Medico <zmedico@gentoo.org>
Thu, 25 Nov 2010 08:23:15 +0000 (00:23 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 25 Nov 2010 08:23:15 +0000 (00:23 -0800)
This should fix bug #315421.

pym/portage/package/ebuild/config.py
pym/portage/package/ebuild/fetch.py

index 9d53888cea43fb2cee8c9da5b6faac260f4e2544..043a310b835aeb35b706d40e64eff052318974c0 100644 (file)
@@ -2008,7 +2008,7 @@ class config(object):
                eapi = self.get('EAPI')
                phase = self.get('EBUILD_PHASE')
                filter_calling_env = False
-               if phase not in ('clean', 'cleanrm', 'depend'):
+               if phase not in ('clean', 'cleanrm', 'depend', 'fetch'):
                        temp_dir = self.get('T')
                        if temp_dir is not None and \
                                os.path.exists(os.path.join(temp_dir, 'environment')):
index 2c7f00703949a88b3597ae0401794b0de085503a..f97707fd6c00afe5c61310c67bcce1a4a6602dbd 100644 (file)
@@ -81,7 +81,18 @@ def _spawn_fetch(settings, args, **kwargs):
                if args[0] != BASH_BINARY:
                        args = [BASH_BINARY, "-c", "exec \"$@\"", args[0]] + args
 
-       rval = spawn_func(args, env=settings.environ(), **kwargs)
+       # Ensure that EBUILD_PHASE is set to fetch, so that config.environ()
+       # does not filter the calling environment (which may contain needed
+       # proxy variables, as in bug #315421).
+       phase_backup = settings.get('EBUILD_PHASE')
+       settings['EBUILD_PHASE'] = 'fetch'
+       try:
+               rval = spawn_func(args, env=settings.environ(), **kwargs)
+       finally:
+               if phase_backup is None:
+                       settings.pop('EBUILD_PHASE', None)
+               else:
+                       settings['EBUILD_PHASE'] = phase_backup
 
        return rval