Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing pacman used for msys2 win_bash #17103

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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