From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 10DEF138330 for ; Fri, 23 Sep 2016 02:50:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A4330E0881; Fri, 23 Sep 2016 02:50:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F3ACBE080D for ; Fri, 23 Sep 2016 02:50:08 +0000 (UTC) Received: from professor-x (d108-172-194-175.bchsia.telus.net [108.172.194.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id 8818733BDC3 for ; Fri, 23 Sep 2016 02:50:07 +0000 (UTC) Date: Thu, 22 Sep 2016 19:50:04 -0700 From: Brian Dolbec To: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: disable ipc_daemon under Windows Subsystem for Linux Message-ID: <20160922195004.37f418e4.dolsen@gentoo.org> In-Reply-To: <20160923032225.74dc9398a248c4f150393cf9@plushkava.net> References: <20160923032225.74dc9398a248c4f150393cf9@plushkava.net> Organization: Gentoo Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archives-Salt: 760fc160-62d2-4163-8d5b-12ce0a961e61 X-Archives-Hash: aa2b3c1bd4865f9e1709ce2eddb9b0df On Fri, 23 Sep 2016 03:22:25 +0100 Kerin Millar 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 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