public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: disable ipc_daemon under Windows Subsystem for Linux
@ 2016-09-23  2:22 Kerin Millar
  2016-09-23  2:50 ` Brian Dolbec
  0 siblings, 1 reply; 2+ messages in thread
From: Kerin Millar @ 2016-09-23  2:22 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 203 bytes --]

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.

-- 
Kerin Millar <kfm@plushkava.net>

[-- Attachment #2: portage-wsl-support.patch --]
[-- Type: application/octet-stream, Size: 1722 bytes --]

commit fc706e5b21829cdeab2c40749639c4fceccd225a
Author: Kerin Millar <kfm@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 disabled.
    
    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. Should
    Microsoft render this device node accessible in future builds, WSL will still
    be detected correctly.

diff --git a/pym/_emerge/AbstractEbuildProcess.py b/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 stat.S_ISCHR(os.stat('/dev/lxss')):
+				running_wsl = True
+		except OSError as e:
+			if (e.errno == errno.EPERM):
+				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 self.settings:

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: disable ipc_daemon under Windows Subsystem for Linux
  2016-09-23  2:22 [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: disable ipc_daemon under Windows Subsystem for Linux Kerin Millar
@ 2016-09-23  2:50 ` Brian Dolbec
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2016-09-23  2:50 UTC (permalink / raw
  To: gentoo-portage-dev

On Fri, 23 Sep 2016 03:22:25 +0100
Kerin Millar <kfm@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 <kfm@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 disabled.
    
    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. Should
    Microsoft render this device node accessible in future builds, WSL will still
    be detected correctly.

diff --git a/pym/_emerge/AbstractEbuildProcess.py b/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 stat.S_ISCHR(os.stat('/dev/lxss')):


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 self.settings:

-- 
Brian Dolbec <dolsen>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-23  2:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-23  2:22 [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: disable ipc_daemon under Windows Subsystem for Linux Kerin Millar
2016-09-23  2:50 ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox