[yum-commits] 4 commits - plugins/keys repoquery.py yumdb.py

James Antill james at osuosl.org
Tue Oct 18 19:57:33 UTC 2011


 plugins/keys/keys.py |   11 ++++++++++-
 repoquery.py         |    9 +++++++++
 yumdb.py             |   25 +++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 1 deletion(-)

New commits:
commit d5198bf04d6167ab7d027b46b3f6755a1d4f2d63
Author: James Antill <james at and.org>
Date:   Tue Oct 18 15:57:25 2011 -0400

    Output the fingerprint in the same way we do for acceptance (group 4 chars).

diff --git a/plugins/keys/keys.py b/plugins/keys/keys.py
index 3342576..4d2ca96 100644
--- a/plugins/keys/keys.py
+++ b/plugins/keys/keys.py
@@ -31,6 +31,15 @@ except:
 requires_api_version = '2.1'
 plugin_type = (TYPE_INTERACTIVE,)
 
+def gpgkey_fingerprint_ascii(gpg_cert, chop=4):
+    ''' Given a key_info data from getgpgkeyinfo(), return an ascii
+    fingerprint. Chop every 4 ascii values, as that is what GPG does. '''
+    fp = yum.pgpmsg.str_to_hex(gpg_cert.public_key.fingerprint())
+    if chop:
+        fp = [fp[i:i+chop] for i in range(0, len(fp), chop)]
+        fp = " ".join(fp)
+    return fp
+
 def match_keys(patterns, key, globs=True):
     for pat in patterns:
         if pat == key.keyid:
@@ -250,7 +259,7 @@ Key ID     : %s
        time.ctime(key.createts),
        gpg_cert.version, gpg_cert.user_id,
        yum.pgpmsg.algo_pk_to_str[gpg_cert.public_key.pk_algo],
-       yum.pgpmsg.str_to_hex(gpg_cert.public_key.fingerprint()),
+       gpgkey_fingerprint_ascii(gpg_cert),
        yum.pgpmsg.str_to_hex(gpg_cert.public_key.key_id()))
 
 
commit 3d0e6c572b880b26edb82e30bca6c92348a1879c
Author: James Antill <james at and.org>
Date:   Thu Sep 22 16:11:03 2011 -0400

    Add "undeleted" param. to yumdb, should always be empty.

diff --git a/yumdb.py b/yumdb.py
index 8a4888e..4e549cd 100755
--- a/yumdb.py
+++ b/yumdb.py
@@ -7,8 +7,24 @@ import fnmatch
 import yum
 import shlex
 
+import os
+import glob
+
 parser = None
 
+# FIXME: Internal knowledge
+def _load_all_package_paths(db_path):
+    # glob the path and get a dict of pkgs to their subdir
+    glb = '%s/*/*/' % db_path
+    pkgdirs = glob.glob(glb)
+    _packages = {}
+    for d in pkgdirs:
+        if d[-1] == '/':
+            d = d[:-1]
+        pkgid = os.path.basename(d).split('-')[0]
+        _packages[pkgid] = d
+    return _packages
+
 def setup_opts():
     version = "0.0.1"
     vers_txt = "Manage yum groups metadata version %s" % version
@@ -25,6 +41,7 @@ def setup_opts():
       unset?        <key> [pkg-wildcard]...
       info          [pkg-wildcard]...
       sync          [pkg-wildcard]...
+      undeleted
       shell         [filename]...
 """
     parser =  optparse.OptionParser(usage = usage_txt, version = vers_txt)
@@ -183,6 +200,14 @@ def run_cmd(yb, args, inshell=False):
                 if ykey not in ndata:
                     continue
                 print " " * 4, ykey, '=', getattr(pkg.yumdb_info, ykey)
+    elif args[0] == 'undeleted':
+        yumdb_packages = _load_all_package_paths(yb.rpmdb.yumdb.conf.db_path)
+        for pkg in sorted(yb.rpmdb.returnPackages()):
+            if pkg.pkgid in yumdb_packages:
+                del yumdb_packages[pkg.pkgid]
+        for pkgid in yumdb_packages:
+            print "%s: %s" % (pkgid, yumdb_packages[pkgid])
+
     elif args[0] == 'shell' and not inshell:
         args.pop(0)
         if args:
commit 22ec89d173f8e5dec0d862a9485cf3c5a0cec415
Author: James Antill <james at and.org>
Date:   Thu Sep 22 15:49:59 2011 -0400

    Add latest nevra shortcuts to querytags.

diff --git a/repoquery.py b/repoquery.py
index b8ddaf7..61d396e 100755
--- a/repoquery.py
+++ b/repoquery.py
@@ -77,6 +77,9 @@ querytags = [ 'name', 'version', 'release', 'epoch', 'arch', 'summary',
               'checksum', 'pkgid', 'committer', 'committime',
               'ui_evr', 'evr', 'ui_nevra', 'ui_envra',
               'ui_from_repo', 'base_package_name', 'size', 'xattr_origin_url',
+              'ui_evra', 'ui_nevr', 'na', 'vr', 'vra', 'evr', 'evra',
+              'nvr', 'nvra', 'nevr', 'nevra', 'envr', 'envra',
+
               'repo.<attr of the repo object>',
               'yumdb.<attr of the yumdb object>',
               '<attr of the yum object>'
commit 0dc268cacd2e359143e483550cf9f96c39e52a1a
Author: James Antill <james at and.org>
Date:   Thu Sep 22 15:24:32 2011 -0400

    Add some more stuff to querytags.

diff --git a/repoquery.py b/repoquery.py
index f8fdd14..b8ddaf7 100755
--- a/repoquery.py
+++ b/repoquery.py
@@ -74,6 +74,12 @@ querytags = [ 'name', 'version', 'release', 'epoch', 'arch', 'summary',
               'installedsize', 'archivesize', 'packagesize', 'repoid', 
               'requires', 'provides', 'conflicts', 'obsoletes',
               'relativepath', 'hdrstart', 'hdrend', 'id',
+              'checksum', 'pkgid', 'committer', 'committime',
+              'ui_evr', 'evr', 'ui_nevra', 'ui_envra',
+              'ui_from_repo', 'base_package_name', 'size', 'xattr_origin_url',
+              'repo.<attr of the repo object>',
+              'yumdb.<attr of the yumdb object>',
+              '<attr of the yum object>'
             ]
 
 def sec2isodate(timestr):


More information about the Yum-commits mailing list