diff --git a/conan/tools/system/package_manager.py b/conan/tools/system/package_manager.py index 8b88c808677..435350a4b8b 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,9 @@ 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 +133,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) 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", [