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

Fix behavior of install-n command #1611

Closed
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions dnf/cli/commands/autoremove.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def configure(self):

def run(self):
if any([self.opts.grp_specs, self.opts.pkg_specs, self.opts.filenames]):
forms = [self.nevra_forms[command] for command in self.opts.command
if command in list(self.nevra_forms.keys())]
forms = []
if self.opts.command in self.nevra_forms:
forms = [self.nevra_forms[self.opts.command]]

self.base.autoremove(forms,
self.opts.pkg_specs,
Expand Down
16 changes: 8 additions & 8 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 All @@ -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
5 changes: 3 additions & 2 deletions dnf/cli/commands/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def configure(self):

def run(self):

forms = [self.nevra_forms[command] for command in self.opts.command
if command in list(self.nevra_forms.keys())]
forms = []
if self.opts.command in self.nevra_forms:
forms = [self.nevra_forms[self.opts.command]]

# local pkgs not supported in erase command
self.opts.pkg_specs += self.opts.filenames
Expand Down
10 changes: 5 additions & 5 deletions dnf/cli/commands/repolist.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def configure(self):
if not self.opts.quiet:
self.cli.redirect_repo_progress()
demands = self.cli.demands
if any((self.base.conf.verbose, ('repoinfo' in self.opts.command))):
if self.base.conf.verbose or self.opts.command == 'repoinfo':
demands.available_repos = True
demands.sack_activation = True

Expand Down Expand Up @@ -139,10 +139,10 @@ def run(self):
enabled = True
if arg == 'disabled':
continue
if any((include_status, verbose, 'repoinfo' in self.opts.command)):
if include_status or verbose or self.opts.command == 'repoinfo':
ui_enabled = ehibeg + _('enabled') + hiend
ui_endis_wid = exact_width(_('enabled'))
if verbose or ('repoinfo' in self.opts.command):
if verbose or self.opts.command == 'repoinfo':
ui_size = _repo_size(self.base.sack, repo)
else:
enabled = False
Expand All @@ -151,7 +151,7 @@ def run(self):
ui_enabled = dhibeg + _('disabled') + hiend
ui_endis_wid = exact_width(_('disabled'))

if not any((verbose, ('repoinfo' in self.opts.command))):
if not (verbose or self.opts.command == 'repoinfo'):
rid = ucd(repo.id)
cols.append((rid, repo.name, (ui_enabled, ui_endis_wid)))
else:
Expand Down Expand Up @@ -287,6 +287,6 @@ def run(self):
print("%s %s %s" % (fill_exact_width(rid, id_len),
fill_exact_width(rname, nm_len, nm_len),
ui_enabled))
if any((verbose, ('repoinfo' in self.opts.command))):
if verbose or self.opts.command == 'repoinfo':
msg = _('Total packages: {}')
print(msg.format(_num2ui_num(tot_num)))
6 changes: 2 additions & 4 deletions dnf/cli/commands/repoquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,8 @@ def run(self):
remote_packages = self._add_add_remote_packages()

kwark = {}
forms = [self.nevra_forms[command] for command in self.opts.command
if command in list(self.nevra_forms.keys())]
if forms:
kwark["forms"] = forms
if self.opts.command in self.nevra_forms:
kwark["forms"] = [self.nevra_forms[self.opts.command]]
pkgs = []
query_results = q.filter(empty=True)

Expand Down
4 changes: 2 additions & 2 deletions dnf/cli/commands/updateinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def configure(self):
self.cli.demands.available_repos = True
self.cli.demands.sack_activation = True

if self.opts.command[0] in self.direct_commands:
if self.opts.command in self.direct_commands:
# we were called with direct command
self.opts.spec_action = self.direct_commands[self.opts.command[0]]
self.opts.spec_action = self.direct_commands[self.opts.command]
else:
if self.opts._spec_action:
self.opts.spec_action = self.opts._spec_action
Expand Down