Skip to content

Commit

Permalink
Fix behavior of localinstall 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 `localinstall` form, since it would no
longer detect that command to restrict search of packages.

Before this commit, this command would (incorrectly) succeed:
  $ dnf localinstall joe

After this commit:
  $ dnf localinstall joe
  Not a valid rpm file path: joe
  Error: Nothing to do.

Closes: #1611
Approved by: m-blaha
  • Loading branch information
filbranden authored and rh-atomic-bot committed Apr 1, 2020
1 parent 14dd35f commit 582b52b
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 @@ -74,12 +74,12 @@ def run(self):
nevra_forms = self._get_nevra_forms_from_command()

self.cli._populate_update_security_filter(self.opts, self.base.sack.query())
if self.opts.command == ['localinstall'] and (self.opts.grp_specs or self.opts.pkg_specs):
if self.opts.command == 'localinstall' and (self.opts.grp_specs or self.opts.pkg_specs):
self._log_not_valid_rpm_file_paths(self.opts.grp_specs)
if self.base.conf.strict:
raise dnf.exceptions.Error(_('Nothing to do.'))
skipped_grp_specs = []
if self.opts.grp_specs and self.opts.command != ['localinstall']:
if self.opts.grp_specs and self.opts.command != 'localinstall':
if dnf.base.WITH_MODULES:
try:
module_base = dnf.module.module_base.ModuleBase(self.base)
Expand Down Expand Up @@ -108,10 +108,10 @@ def run(self):
self._inform_not_a_valid_combination(skipped_grp_specs)
if self.base.conf.strict:
raise dnf.exceptions.Error(_('Nothing to do.'))
elif skipped_grp_specs and self.opts.command != ['localinstall']:
elif skipped_grp_specs and self.opts.command != 'localinstall':
self._install_groups(skipped_grp_specs)

if self.opts.command != ['localinstall']:
if self.opts.command != 'localinstall':
errs = self._install_packages(nevra_forms)

if (len(errs) != 0 or len(err_pkgs) != 0 or error_module_specs) and self.base.conf.strict:
Expand Down

0 comments on commit 582b52b

Please sign in to comment.