commit:     b812317ac54e6f1707333ba138c339bedf0166b4
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  5 04:33:16 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 04:35:20 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=b812317a

gpkg: don't show gpg output twice

Don't decode + split the gpg outout twice if signing failed.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/gpkg.py | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/portage/gpkg.py b/lib/portage/gpkg.py
index a81bc21c0a..67a4d39ff3 100644
--- a/lib/portage/gpkg.py
+++ b/lib/portage/gpkg.py
@@ -608,27 +608,20 @@ class checksum_helper:
                 if self.gpg_operation == checksum_helper.VERIFY:
                     self._check_gpg_status(self.gpg_result)
             else:
-                msg = ["Binary package is not usable:"]
-                msg.extend(
-                    "\t" + line
-                    for line in self.gpg_result.decode(
-                        "UTF-8", errors="replace"
-                    ).splitlines()
-                )
+                gpg_error_lines = self.gpg_result.decode(
+                    "UTF-8", errors="replace"
+                ).splitlines()
                 out = portage.output.EOutput()
-                [out.eerror(line) for line in msg]
 
                 if self.gpg_operation == checksum_helper.SIGNING:
                     msg = ["Binary package is not usable (signing failed):"]
-                    msg.extend(
-                        "\t" + line
-                        for line in self.gpg_output.decode(
-                            "UTF-8", errors="replace"
-                        ).splitlines()
-                    )
+                    msg.extend("\t" + line for line in gpg_error_lines)
                     [out.eerror(line) for line in msg]
                     raise GPGException("GnuPG signing failed")
                 elif self.gpg_operation == checksum_helper.VERIFY:
+                    msg = ["Binary package is not usable (verification 
failed):"]
+                    msg.extend("\t" + line for line in gpg_error_lines)
+                    [out.eerror(line) for line in msg]
                     raise InvalidSignature("GnuPG verification failed")
 
 

Reply via email to