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

Update system package manager db right before install, instead before check #11716

Merged
merged 3 commits into from Jul 28, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions conan/tools/system/package_manager.py
Expand Up @@ -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)

Expand All @@ -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,
Expand All @@ -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)
Expand Down
Expand Up @@ -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", [
Expand Down