Skip to content

Commit

Permalink
fixing pacman used for msys2 win_bash (#17103)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Oct 3, 2024
1 parent f31647f commit ee9cf01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conan/tools/system/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_default_tool(self):
if os_name in ["Linux", "FreeBSD"]:
import distro
os_name = distro.id() or os_name
elif os_name == "Windows" and self._conanfile.conf.get("tools.microsoft.bash:subsystem") == "msys2":
elif os_name == "Windows" and self._conanfile.settings.get_safe("os.subsystem") == "msys2":
os_name = "msys2"
manager_mapping = {"apt-get": ["Linux", "ubuntu", "debian", "raspbian", "linuxmint", 'astra', 'elbrus', 'altlinux', 'pop'],
"apk": ["alpine"],
Expand Down
9 changes: 8 additions & 1 deletion test/integration/tools/system/package_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ def test_msys2():
with mock.patch('conan.ConanFile.context', new_callable=PropertyMock) as context_mock:
context_mock.return_value = "host"
conanfile = ConanFileMock()
conanfile.settings = Settings()
conanfile.settings = Settings({"os": {"Windows": {"subsystem": ["msys2"]}}})
conanfile.conf.define("tools.microsoft.bash:subsystem", "msys2")
manager = _SystemPackageManagerTool(conanfile)
assert manager.get_default_tool() == "choco"

conanfile.settings.os = "Windows"
conanfile.settings.os.subsystem = "msys2"
manager = _SystemPackageManagerTool(conanfile)
assert manager.get_default_tool() == "pacman"


Expand Down Expand Up @@ -240,6 +245,7 @@ def fake_check(*args, **kwargs):

assert tool._conanfile.command == result


@pytest.mark.parametrize("tool_class, arch_host, result", [
# Install build machine package and not cross-compile -> do not add host architecture
(Apk, 'x86_64', 'apk add --no-cache package1 package2'),
Expand Down Expand Up @@ -281,6 +287,7 @@ def fake_check(*args, **kwargs):

assert tool._conanfile.command == result


@pytest.mark.parametrize("tool_class, result", [
# cross-compile but arch_names=None -> do not add host architecture
# https://github.com/conan-io/conan/issues/12320 because the package is archless
Expand Down

0 comments on commit ee9cf01

Please sign in to comment.