From e78ed6c2afd062fe93218fccbd485bae6e8ed547 Mon Sep 17 00:00:00 2001 From: czoido Date: Wed, 27 Jul 2022 15:09:38 +0200 Subject: [PATCH 1/3] move update --- conan/tools/system/package_manager.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/conan/tools/system/package_manager.py b/conan/tools/system/package_manager.py index 8b88c808677..fd44f539590 100644 --- a/conan/tools/system/package_manager.py +++ b/conan/tools/system/package_manager.py @@ -103,9 +103,6 @@ def _install_substitutes(self, *packages_substitutes, update=False, check=True, raise ConanException("None of the installs for the package substitutes succeeded.") def _install(self, packages, update=False, check=True, **kwargs): - if update: - self.update() - if check: packages = self.check(packages) @@ -120,6 +117,10 @@ def _install(self, packages, update=False, check=True, **kwargs): self.mode_check, self.mode_install)) elif packages: + + if update: + self.update() + packages_arch = [self.get_package_name(package) for package in packages] if packages_arch: command = self.install_command.format(sudo=self.sudo_str, @@ -133,7 +134,7 @@ def _install(self, packages, update=False, check=True, **kwargs): def _update(self): # we just update the package manager database in case we are in 'install mode' - # in case we are in check mode warn about that but don't fail + # in case we are in check mode just ignore if self._mode == self.mode_install: command = self.update_command.format(sudo=self.sudo_str, tool=self.tool_name) return self._conanfile_run(command, self.accepted_update_codes) From 2cb7927c4dd38fe2bec46d3d7ab796c322bf2ba0 Mon Sep 17 00:00:00 2001 From: czoido Date: Wed, 27 Jul 2022 15:12:25 +0200 Subject: [PATCH 2/3] minor changes --- conan/tools/system/package_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/conan/tools/system/package_manager.py b/conan/tools/system/package_manager.py index fd44f539590..435350a4b8b 100644 --- a/conan/tools/system/package_manager.py +++ b/conan/tools/system/package_manager.py @@ -117,7 +117,6 @@ def _install(self, packages, update=False, check=True, **kwargs): self.mode_check, self.mode_install)) elif packages: - if update: self.update() From 4135b8e7add83e8883039a0b2a6dc2d0dbd11310 Mon Sep 17 00:00:00 2001 From: czoido Date: Wed, 27 Jul 2022 15:13:26 +0200 Subject: [PATCH 3/3] minor changes --- conans/test/integration/tools/system/package_manager_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/test/integration/tools/system/package_manager_test.py b/conans/test/integration/tools/system/package_manager_test.py index abdff245be8..f63da31ec8f 100644 --- a/conans/test/integration/tools/system/package_manager_test.py +++ b/conans/test/integration/tools/system/package_manager_test.py @@ -157,7 +157,7 @@ def test_tools_update_mode_install(tool_class, result): assert tool._conanfile.command == result else: # does not run the update when mode check - assert tool._conanfile.command == None + assert tool._conanfile.command is None @pytest.mark.parametrize("tool_class, result", [