Skip to content

Commit

Permalink
Fix behavior of install-n command
Browse files Browse the repository at this point in the history
Commit de9643a (first shipped in dnf 4.2.8) changed opts.command
from a list to a simple string, but code in InstallCommand still handled
it as if it was a list.

This broke silently because Python will iterate over a string character
by character, so it never produced a syntax error or an exception that
would be noticed.

But it broke behavior of the `install-n` form, since it would no longer
detect that command to restrict search of packages.

Before this commit, this command would (incorrectly) succeed:
  $ dnf install-n joe-4.6

After this commit:
  $ dnf install-n joe-4.6
  No match for argument: joe-4.6
    * Maybe you meant: joe
  Error: Unable to find a match: joe-4.6

Closes: #1611
Approved by: m-blaha
  • Loading branch information
filbranden authored and rh-atomic-bot committed Apr 1, 2020
1 parent 864c381 commit 14dd35f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dnf/cli/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def run(self):
packages=err_pkgs)

def _get_nevra_forms_from_command(self):
return [self.nevra_forms[command]
for command in self.opts.command
if command in list(self.nevra_forms.keys())
]
if self.opts.command in self.nevra_forms:
return [self.nevra_forms[self.opts.command]]
else:
return []

def _log_not_valid_rpm_file_paths(self, grp_specs):
group_names = map(lambda g: '@' + g, grp_specs)
Expand Down

0 comments on commit 14dd35f

Please sign in to comment.