diff --git a/recipes/msys2/all/conanfile.py b/recipes/msys2/all/conanfile.py index cfd25b19656d2..7e964badd302a 100644 --- a/recipes/msys2/all/conanfile.py +++ b/recipes/msys2/all/conanfile.py @@ -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): @@ -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) @@ -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):