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

[develop] Fix: Prevent full system upgrade in pkg.installed for Arch Linux #66255

Closed
wants to merge 1 commit into from
Closed
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 salt/modules/pacmanpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def install(name=None,
cmd.append('-S')
if refresh is True:
cmd.append('-y')
if sysupgrade is True or (sysupgrade is None and refresh is True):
if sysupgrade is True:
cmd.append('-u')
cmd.extend(['--noprogressbar', '--noconfirm', '--needed'])
wildcards = []
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/modules/test_pacmanpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,16 @@ def test_group_diff(self):
}):
results = pacman.group_diff('testgroup')
self.assertEqual(results['default'], {'installed': ['A'], 'not installed': ['C']})

def test_pkg_installed_sysupgrade_flag(self):
'''
Test if the pkg.installed state appends the '-u' flag only when sysupgrade is True
'''
with patch.dict(pacman.__salt__, {'cmd.run': MagicMock()}):
pacman.pkg_installed(name='somepkg', sysupgrade=True)
args, kwargs = pacman.__salt__['cmd.run'].call_args
self.assertIn('-u', args[0])

pacman.pkg_installed(name='somepkg', sysupgrade=None, refresh=True)
args, kwargs = pacman.__salt__['cmd.run'].call_args
self.assertNotIn('-u', args[0])