Fix for dnf groupinstall

Previous fix to group install introduced a different bug trying to
strip() group names at the wrong level.  This patch fixes that.

Fixes #3358
pull/18777/head
Toshio Kuratomi 8 years ago committed by Matt Clay
parent 3ec6722a21
commit 138f2cd847

@ -304,14 +304,14 @@ def ensure(module, base, state, names):
filenames = [f.strip() for f in filenames] filenames = [f.strip() for f in filenames]
groups = [] groups = []
environments = [] environments = []
for group_spec in group_specs: for group_spec in (g.strip() for g in group_specs):
group = base.comps.group_by_pattern(group_spec) group = base.comps.group_by_pattern(group_spec)
if group: if group:
groups.append(group.strip()) groups.append(group)
else: else:
environment = base.comps.environments_by_pattern(group_spec) environment = base.comps.environment_by_pattern(group_spec)
if environment: if environment:
environments.extend((e.id.strip() for e in environment)) environments.append(environment.id)
else: else:
module.fail_json( module.fail_json(
msg="No group {} available.".format(group_spec)) msg="No group {} available.".format(group_spec))
@ -376,11 +376,21 @@ def ensure(module, base, state, names):
module.fail_json( module.fail_json(
msg="Cannot remove paths -- please specify package name.") msg="Cannot remove paths -- please specify package name.")
installed = base.sack.query().installed()
for group in groups: for group in groups:
if installed.filter(name=group.name): try:
base.group_remove(group) base.group_remove(group)
except dnf.exceptions.CompsError:
# Group is already uninstalled.
pass
for envioronment in environments:
try:
base.environment_remove(environment)
except dnf.exceptions.CompsError:
# Environment is already uninstalled.
pass
installed = base.sack.query().installed()
for pkg_spec in pkg_specs: for pkg_spec in pkg_specs:
if installed.filter(name=pkg_spec): if installed.filter(name=pkg_spec):
base.remove(pkg_spec) base.remove(pkg_spec)

Loading…
Cancel
Save