Skip to content

Commit

Permalink
Update system package manager db right before install, instead before…
Browse files Browse the repository at this point in the history
… check (#11716)

* move update

* minor changes

* minor changes
  • Loading branch information
czoido committed Jul 28, 2022
1 parent b2ddd7a commit 5acc52d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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

0 comments on commit 5acc52d

Please sign in to comment.