From 533df42e6f1fd3ffaf3d8d6bb344f83c25a7ab2c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 20:48:32 +0100 Subject: [PATCH] [PR #7971/dd25ddfb backport][stable-7] Pkgin fixes (#8015) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pkgin fixes (#7971) * Solve exception and spurious "changed" in pkgin * Create changelog * PEP 8 * Update changelogs/fragments/pkgin.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit dd25ddfbe83362d42c12c321b0c554ac4548c4a3) Co-authored-by: Jesús Cea --- changelogs/fragments/pkgin.yml | 2 ++ plugins/modules/pkgin.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/pkgin.yml diff --git a/changelogs/fragments/pkgin.yml b/changelogs/fragments/pkgin.yml new file mode 100644 index 0000000000..60eff0bfe5 --- /dev/null +++ b/changelogs/fragments/pkgin.yml @@ -0,0 +1,2 @@ +bugfixes: + - pkgin - pkgin (pkgsrc package manager used by SmartOS) raises erratic exceptions and spurious ``changed=true`` (https://github.com/ansible-collections/community.general/pull/7971). diff --git a/plugins/modules/pkgin.py b/plugins/modules/pkgin.py index c08b252187..ab052e3dba 100644 --- a/plugins/modules/pkgin.py +++ b/plugins/modules/pkgin.py @@ -174,6 +174,13 @@ def query_package(module, name): # '<' - installed but out of date # '=' - installed and up to date # '>' - installed but newer than the repository version + + if (package in ('reading local summary...', + 'processing local summary...', + 'downloading pkg_summary.xz done.')) or \ + (package.startswith('processing remote summary (')): + continue + pkgname_with_version, raw_state = package.split(splitchar)[0:2] # Search for package, stripping version @@ -317,7 +324,7 @@ def do_upgrade_packages(module, full=False): format_pkgin_command(module, cmd)) if rc == 0: - if re.search('^nothing to do.\n$', out): + if re.search('^(.*\n|)nothing to do.\n$', out): module.exit_json(changed=False, msg="nothing left to upgrade") else: module.fail_json(msg="could not %s packages" % cmd, stdout=out, stderr=err)