Skip to content

Commit

Permalink
dnf5: utilize automatic gpg check via transaction.run() (ansible#81144)
Browse files Browse the repository at this point in the history
rpm-software-management/dnf5#607
(cherry picked from commit c3af71a)
  • Loading branch information
mkrizek committed Jul 10, 2023
1 parent 94a6f6e commit 369c66c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/dnf5-gpg-check-builtin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Utilize gpg check provided internally by the ``transaction.run`` method as oppose to calling it manually.
9 changes: 4 additions & 5 deletions lib/ansible/modules/dnf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,16 +670,15 @@ def run(self):
else:
transaction.download()
if not self.download_only:
if not self.disable_gpg_check and not transaction.check_gpg_signatures():
transaction.set_description("ansible dnf5 module")
result = transaction.run()
if result == libdnf5.base.Transaction.TransactionRunResult_ERROR_GPG_CHECK:
self.module.fail_json(
msg="Failed to validate GPG signatures: {}".format(",".join(transaction.get_gpg_signature_problems())),
failures=[],
rc=1,
)

transaction.set_description("ansible dnf5 module")
result = transaction.run()
if result != libdnf5.base.Transaction.TransactionRunResult_SUCCESS:
elif result != libdnf5.base.Transaction.TransactionRunResult_SUCCESS:
self.module.fail_json(
msg="Failed to install some of the specified packages",
failures=["{}: {}".format(transaction.transaction_result_to_string(result), log) for log in transaction.get_transaction_problems()],
Expand Down

0 comments on commit 369c66c

Please sign in to comment.