From 874d7f7050266919b4b44706b6698fb478a26175 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 4 May 2023 08:14:29 +0200 Subject: [PATCH] [PR #6456/fab717bb backport][stable-6] modules/portage: fix usage with withbdeps: false (#6480) modules/portage: fix usage with withbdeps: false (#6456) Using ``withbdeps: false`` was causing the underlying emerge command to fail due to not passing an argument to the ``--with-bdeps`` flag. Fix by updating the logic for generating the emerge command arguments to ensure that ``withbdeps: false`` results in a passing an ``n`` argument with the ``--with-bdeps`` emerge flag. (cherry picked from commit fab717bb2d392df7aef77a74232aa92e4e63e127) Co-authored-by: Daniel Harding --- .../fragments/6456-fix-portage-withbdeps-false.yml | 2 ++ plugins/modules/portage.py | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/6456-fix-portage-withbdeps-false.yml diff --git a/changelogs/fragments/6456-fix-portage-withbdeps-false.yml b/changelogs/fragments/6456-fix-portage-withbdeps-false.yml new file mode 100644 index 0000000000..5227d3ff19 --- /dev/null +++ b/changelogs/fragments/6456-fix-portage-withbdeps-false.yml @@ -0,0 +1,2 @@ +bugfixes: + - "portage - update the logic for generating the emerge command arguments to ensure that ``withbdeps: false`` results in a passing an ``n`` argument with the ``--with-bdeps`` emerge flag (https://github.com/ansible-collections/community.general/issues/6451, https://github.com/ansible-collections/community.general/pull/6456)." diff --git a/plugins/modules/portage.py b/plugins/modules/portage.py index d33f44d578..c732e7f56f 100644 --- a/plugins/modules/portage.py +++ b/plugins/modules/portage.py @@ -383,14 +383,12 @@ def emerge_packages(module, packages): """Fallback to default: don't use this argument at all.""" continue - if not flag_val: + """Add the --flag=value pair.""" + if isinstance(flag_val, bool): + args.extend((arg, to_native('y' if flag_val else 'n'))) + elif not flag_val: """If the value is 0 or 0.0: add the flag, but not the value.""" args.append(arg) - continue - - """Add the --flag=value pair.""" - if isinstance(p[flag], bool): - args.extend((arg, to_native('y' if flag_val else 'n'))) else: args.extend((arg, to_native(flag_val)))