Skip to content

Commit

Permalink
PR 4286: try to kill pacman first
Browse files Browse the repository at this point in the history
  • Loading branch information
dmn-star committed Jan 25, 2021
1 parent d771a11 commit 0048efa
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions recipes/msys2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
from conans.errors import ConanInvalidConfiguration, ConanException
import os
import shutil
import subprocess


class MSYS2Conan(ConanFile):
Expand Down Expand Up @@ -33,8 +34,6 @@ def validate(self):
if tools.Version(self.version) <= "20161025":
raise ConanInvalidConfiguration("msys2 v.20161025 is no longer supported")



def _download(self, url, sha256):
from six.moves.urllib.parse import urlparse
filename = os.path.basename(urlparse(url[0]).path)
Expand Down Expand Up @@ -78,6 +77,27 @@ def _update_pacman(self):
self.run('bash -l -c "pacman -Rc dash --noconfirm"')
self.run('bash -l -c "pacman -Syu --noconfirm"')

def _kill_pacman(self):
taskkill_exe = os.path.join(os.environ['WINDIR'], 'system32', 'taskkill.exe')

log_out = True
if log_out:
out = subprocess.PIPE
err = subprocess.STDOUT
else:
out = file(os.devnull, 'w')
err = subprocess.PIPE

if os.path.exists(taskkill_exe):
taskkill_cmd = taskkill_exe + ' /f /fi "MODULES eq msys-2.0.dll"'
try:
proc = subprocess.Popen(taskkill_cmd, stdout=out, stderr=err, bufsize=1)
except OSError as e:
if e.errno == errno.ENOENT:
raise ConanException("Cannot kill pacman")

def configure(self):
self._kill_pacman()

@property
def _msys_dir(self):
Expand Down

0 comments on commit 0048efa

Please sign in to comment.