On Fri, 23 Sep 2016 03:22:25 +0100
Kerin Millar <k...@plushkava.net> wrote:

> Hi,
> The attached patch renders portage functional under WSL, as tested
> with the "current branch" of Windows 10. Further details can be found
> in the commit message.

commit fc706e5b21829cdeab2c40749639c4fceccd225a
Author: Kerin Millar <k...@plushkava.net>
Date:   Fri Sep 23 01:55:10 2016 +0000

    AbstractEbuildProcess: disable ipc_daemon under Windows Subsystem for Linux
    As of Windows 10 build 14393, WSL is unable to support EbuildIpcDaemon
    correctly. The presence of /dev/lxss - as a character device - indicates 
that we
    are running under WSL, in which case the use of the daemon should be 
    Note that stat calls directed at /dev/lxss are currently doomed to fail with
    EPERM. Thus, this specific error is also used as a means to detect WSL. 
    Microsoft render this device node accessible in future builds, WSL will 
    be detected correctly.

diff --git a/pym/_emerge/AbstractEbuildProcess.py 
index 8bd30a6..7c8fc18 100644
--- a/pym/_emerge/AbstractEbuildProcess.py
+++ b/pym/_emerge/AbstractEbuildProcess.py
@@ -128,7 +128,17 @@ class AbstractEbuildProcess(SpawnProcess):
                        # since we're not displaying to a terminal anyway.
                        self.settings['NOCOLOR'] = 'true'
-               if self._enable_ipc_daemon:
+               # Determine whether we are running under WSL (Windows Subsystem 
for Linux).
+               # Trying to stat /dev/lxss under WSL will always fail with 
EPERM (for now).
+               running_wsl = False
+               try:
+                       if platform.system() == 'Linux' and 

Using "in" comparisons is faster than doing == comparisons, even for a list or 
tuple of one length.  
It also allows easier expansion of the qualifiers.

                        if platform.system() in ['Linux'] and ...

+                               running_wsl = True
+               except OSError as e:
+                       if (e.errno == errno.EPERM):

Same for this one                   ^^

+                               running_wsl = True
+               if self._enable_ipc_daemon and not running_wsl:
                        self.settings.pop('PORTAGE_EBUILD_EXIT_FILE', None)
                        if self.phase not in self._phases_without_builddir:
                                if 'PORTAGE_BUILDDIR_LOCKED' not in 

Brian Dolbec <dolsen>

Reply via email to