[Yum-devel] [PATCH 2/2] Make the "installing gpg key" messages nicer, showing the owning package.

James Antill james at and.org
Tue Jun 22 20:07:29 UTC 2010


---
 yum/__init__.py |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 3ad8a84..73ec7c3 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -4210,6 +4210,28 @@ class YumBase(depsolve.Depsolve):
         
         return keys
 
+    def _getKeyImportMessage(self, info, keyurl):
+        msg = None
+        if keyurl.startswith("file:"):
+            fname = keyurl[len("file:"):]
+            pkgs = self.rpmdb.searchFiles(fname)
+            if pkgs:
+                pkgs = sorted(pkgs)[-1]
+                msg = (_('Importing GPG key 0x%s:\n'
+                         ' Userid : %s\n'
+                         ' Package: %s (%s)\n'
+                         ' From   : %s') %
+                       (info['hexkeyid'], to_unicode(info['userid']),
+                        pkgs, pkgs.ui_from_repo,
+                        keyurl.replace("file://","")))
+        if msg is None:
+            msg = (_('Importing GPG key 0x%s:\n'
+                     ' Userid: "%s"\n'
+                     ' From  : %s') %
+                   (info['hexkeyid'], to_unicode(info['userid']),
+                    keyurl.replace("file://","")))
+        self.logger.critical("%s", msg)
+
     def getKeyForPackage(self, po, askcb = None, fullaskcb = None):
         """
         Retrieve a key for a package. If needed, prompt for if the key should
@@ -4240,10 +4262,7 @@ class YumBase(depsolve.Depsolve):
                     continue
 
                 # Try installing/updating GPG key
-                self.logger.critical(_('Importing GPG key 0x%s "%s" from %s') %
-                                     (info['hexkeyid'], 
-                                      to_unicode(info['userid']),
-                                      keyurl.replace("file://","")))
+                self._getKeyImportMessage(info, keyurl)
                 rc = False
                 if self.conf.assumeyes:
                     rc = True
@@ -4302,10 +4321,7 @@ class YumBase(depsolve.Depsolve):
                     continue
 
                 # Try installing/updating GPG key
-                self.logger.critical(_('Importing GPG key 0x%s "%s" from %s') %
-                                     (info['hexkeyid'], 
-                                     to_unicode(info['userid']),
-                                     keyurl.replace("file://","")))
+                self._getKeyImportMessage(info, keyurl)
                 rc = False
                 if self.conf.assumeyes:
                     rc = True
-- 
1.7.0.1



More information about the Yum-devel mailing list