[yum-commits] 6 commits - docs/yumdb.8 plugins/priorities repodiff.py yumdb.py

James Antill james at osuosl.org
Tue Oct 26 15:15:25 UTC 2010


 docs/yumdb.8                     |   22 +++++++++++-
 plugins/priorities/priorities.py |    7 ++--
 repodiff.py                      |    1 
 yumdb.py                         |   67 +++++++++++++++++++++++++++++----------
 4 files changed, 77 insertions(+), 20 deletions(-)

New commits:
commit 1b5ed25a6a318b4c1f09aeef763d1e2e28529ef2
Author: James Antill <james at and.org>
Date:   Tue Oct 26 11:13:10 2010 -0400

    Add yumdb copy-force, for symmetry with rename-force.

diff --git a/docs/yumdb.8 b/docs/yumdb.8
index 66acd74..63a3c6b 100644
--- a/docs/yumdb.8
+++ b/docs/yumdb.8
@@ -42,6 +42,11 @@ any specified packages. If the old-key does not exist, new-key is deleted.
 This command will copy the given old-key, to the given new-key, limiting to
 any specified packages. If the old-key does not exist, nothing happens.
 .br 
+.IP "\fByumdb copy-force <old-key> <new-key> [pkg-wildcard]...
+.PP
+This command will copy the given old-key, to the given new-key, limiting to
+any specified packages. If the old-key does not exist, new-key is deleted.
+.br 
 .IP "\fByumdb search <key> <wildcard>...
 .PP
 This command will search all packages for the given key, against any of the
diff --git a/yumdb.py b/yumdb.py
index 53cc075..8a4888e 100755
--- a/yumdb.py
+++ b/yumdb.py
@@ -56,7 +56,8 @@ def run_cmd(yb, args, inshell=False):
             setattr(pkg.yumdb_info, ykey, yval)
             print pkg
             print " " * 4, ykey, '=', getattr(pkg.yumdb_info, ykey)
-    elif args[0] == 'copy' and len(args) > 2:
+    elif args[0] in ('copy', 'copy-f', 'copy-force') and len(args) > 2:
+        force = args[0] in ['copy-f', 'copy-force']
         args.pop(0)
         yokey = args.pop(0)
         ynkey = args.pop(0)
@@ -65,6 +66,9 @@ def run_cmd(yb, args, inshell=False):
             if yokey in pkg.yumdb_info:
                 setattr(pkg.yumdb_info, ynkey, getattr(pkg.yumdb_info, yokey))
                 print " " * 4, ynkey, '=', getattr(pkg.yumdb_info, ynkey)
+            elif force and ynkey in pkg.yumdb_info:
+                delattr(pkg.yumdb_info, ynkey)
+                print " " * 4, ynkey, '<unset>'
             elif ynkey in pkg.yumdb_info:
                 print " " * 4, ynkey, '=', getattr(pkg.yumdb_info, ynkey)
             else:
commit 5f694d62df14f94963a167dd25061c4e7ca8f086
Author: James Antill <james at and.org>
Date:   Tue Oct 26 11:07:19 2010 -0400

    Cleanup yumdb rename/rename-force, and make the difference more obvious.

diff --git a/yumdb.py b/yumdb.py
index 2bc17ad..53cc075 100755
--- a/yumdb.py
+++ b/yumdb.py
@@ -56,20 +56,6 @@ def run_cmd(yb, args, inshell=False):
             setattr(pkg.yumdb_info, ykey, yval)
             print pkg
             print " " * 4, ykey, '=', getattr(pkg.yumdb_info, ykey)
-    elif args[0] == 'rename' and len(args) > 2:
-        args.pop(0)
-        yokey = args.pop(0)
-        ynkey = args.pop(0)
-        for pkg in sorted(yb.rpmdb.returnPackages(patterns=args)):
-            print pkg
-            if yokey in pkg.yumdb_info:
-                setattr(pkg.yumdb_info, ynkey, getattr(pkg.yumdb_info, yokey))
-                delattr(pkg.yumdb_info, yokey)
-                print " " * 4, ynkey, '=', getattr(pkg.yumdb_info, ynkey)
-            elif ynkey in pkg.yumdb_info:
-                print " " * 4, ynkey, '=', getattr(pkg.yumdb_info, ynkey)
-            else:
-                print " " * 4, ynkey, '<unset>'
     elif args[0] == 'copy' and len(args) > 2:
         args.pop(0)
         yokey = args.pop(0)
@@ -83,7 +69,8 @@ def run_cmd(yb, args, inshell=False):
                 print " " * 4, ynkey, '=', getattr(pkg.yumdb_info, ynkey)
             else:
                 print " " * 4, ynkey, '<unset>'
-    elif args[0] in ['rename-f', 'rename-force'] and len(args) > 2:
+    elif args[0] in ['rename', 'rename-f', 'rename-force'] and len(args) > 2:
+        force = args[0] in ['rename-f', 'rename-force']
         args.pop(0)
         yokey = args.pop(0)
         ynkey = args.pop(0)
@@ -93,9 +80,11 @@ def run_cmd(yb, args, inshell=False):
                 setattr(pkg.yumdb_info, ynkey, getattr(pkg.yumdb_info, yokey))
                 delattr(pkg.yumdb_info, yokey)
                 print " " * 4, ynkey, '=', getattr(pkg.yumdb_info, ynkey)
-            elif ynkey in pkg.yumdb_info:
+            elif force and ynkey in pkg.yumdb_info:
                 delattr(pkg.yumdb_info, ynkey)
                 print " " * 4, ynkey, '<unset>'
+            elif ynkey in pkg.yumdb_info:
+                print " " * 4, ynkey, '=', getattr(pkg.yumdb_info, ynkey)
             else:
                 print " " * 4, ynkey, '<unset>'
     elif args[0] in ['del', 'delete', 'rm', 'remove'] and len(args) > 1:
commit 9382ceee464a7e0e389f85f5c8c517d106909b24
Author: James Antill <james at and.org>
Date:   Tue Oct 26 10:44:34 2010 -0400

    Add a yumdb sync command, for failed transactions.

diff --git a/docs/yumdb.8 b/docs/yumdb.8
index 7c39459..66acd74 100644
--- a/docs/yumdb.8
+++ b/docs/yumdb.8
@@ -59,8 +59,21 @@ to any specified packages.
 .br 
 .IP "\fByumdb info [pkg-wildcard]...
 .PP
-This command will all the data stored in the yumdb, limiting to any specified
-packages.
+This command will display all the data stored in the yumdb, limiting to any
+specified packages.
+.br 
+.IP "\fByumdb sync [pkg-wildcard]...
+.PP
+This command will add any missing data to the yumdb from the repositories,
+limiting to any specified packages. This is useful to run if you have had any
+aborted transactions (and thus. missing yumdb data).
+Note that "yumdb sync" cannot know all the information that would have been put
+into the yumdb at the time.
+.br 
+.IP "\fByumdb sync-force [pkg-wildcard]...
+.PP
+This command will replace any data in the yumdb from the repositories,
+limiting to any specified packages.
 
 .SH "EXAMPLES"
 .PP
diff --git a/yumdb.py b/yumdb.py
index 38ba561..2bc17ad 100755
--- a/yumdb.py
+++ b/yumdb.py
@@ -24,6 +24,7 @@ def setup_opts():
       exist?        <key> [pkg-wildcard]...
       unset?        <key> [pkg-wildcard]...
       info          [pkg-wildcard]...
+      sync          [pkg-wildcard]...
       shell         [filename]...
 """
     parser =  optparse.OptionParser(usage = usage_txt, version = vers_txt)
@@ -148,6 +149,47 @@ def run_cmd(yb, args, inshell=False):
             print pkg
             for ykey in sorted(pkg.yumdb_info):
                 print " " * 4, ykey, '=', getattr(pkg.yumdb_info, ykey)
+    elif args[0] in ('sync', 'synchronize', 'sync-f', 'synchronize-f',
+                     'sync-force', 'synchronize-force'):
+        force = args[0] in ('sync-f', 'synchronize-f',
+                            'sync-force', 'synchronize-force')
+        args.pop(0)
+        done = False
+        for pkg in sorted(yb.rpmdb.returnPackages(patterns=args)):
+            apkg = yb.pkgSack.searchPkgTuple(pkg.pkgtup)
+            if not apkg:
+                continue
+            apkg = sorted(apkg)[0]
+
+            if done: print ''
+            done = True
+            print pkg
+            ndata = {}
+            ndata['releasever'] = yb.conf.yumvar['releasever']
+            ndata['from_repo']  = apkg.repoid
+            csum = apkg.returnIdSum()
+            if csum is not None:
+                ndata['checksum_type'] = str(csum[0])
+                ndata['checksum_data'] = str(csum[1])
+            if hasattr(apkg.repo, 'repoXML'):
+                md = apkg.repo.repoXML
+                if md and md.revision is not None:
+                    ndata['from_repo_revision']  = str(md.revision)
+                if md:
+                    ndata['from_repo_timestamp'] = str(md.timestamp)
+
+            loginuid = yum.misc.getloginuid()
+            if loginuid is not None:
+                ndata['changed_by'] = str(loginuid)
+
+            for ykey in ndata:
+                if not force and hasattr(pkg.yumdb_info, ykey):
+                    continue
+                setattr(pkg.yumdb_info, ykey, ndata[ykey])
+            for ykey in sorted(pkg.yumdb_info):
+                if ykey not in ndata:
+                    continue
+                print " " * 4, ykey, '=', getattr(pkg.yumdb_info, ykey)
     elif args[0] == 'shell' and not inshell:
         args.pop(0)
         if args:
commit fa6cff6e5cd13e9346b4478a68b9f5ed71ec67e4
Author: James Antill <james at and.org>
Date:   Tue Oct 26 10:42:38 2010 -0400

    Disable any excludes in repodiff.

diff --git a/repodiff.py b/repodiff.py
index 0ac00e3..ef21c2d 100755
--- a/repodiff.py
+++ b/repodiff.py
@@ -176,6 +176,7 @@ def main(args):
         my.conf.debuglevel=0
         my.doLoggingSetup(my.conf.debuglevel, my.conf.errorlevel)
     
+    my.conf.disable_excludes = ['all']
     my.dy_shutdown_all_other_repos()
     my.dy_archlist = opts.archlist
     if not opts.quiet: print 'setting up repos'
commit 6821f6882cc0c74addff60440748bd6adbfaa413
Author: James Antill <james at and.org>
Date:   Wed Oct 13 14:18:01 2010 -0400

    Only display priorities message, if we did something.

diff --git a/plugins/priorities/priorities.py b/plugins/priorities/priorities.py
index 5ce1c92..ff1a4ed 100644
--- a/plugins/priorities/priorities.py
+++ b/plugins/priorities/priorities.py
@@ -161,7 +161,8 @@ def exclude_hook(conduit):
                                 cnt += 1
                                 conduit.info(3," --> %s from %s excluded (priority)" % (po,po.repoid))
                                 break
-    conduit.info(2, '%d packages excluded due to repository priority protections' % cnt)
+    if cnt:
+        conduit.info(2, '%d packages excluded due to repository priority protections' % cnt)
 
 def _pkglist_to_dict(pl, priority, addArch = False):
     out = dict()
commit 42a15a5d0cdf6b743c09509086dfb483b6a39196
Author: James Antill <james at and.org>
Date:   Wed Oct 13 14:10:57 2010 -0400

    Speedup priorities: Reuse rawobsoletes.

diff --git a/plugins/priorities/priorities.py b/plugins/priorities/priorities.py
index ddee1cb..5ce1c92 100644
--- a/plugins/priorities/priorities.py
+++ b/plugins/priorities/priorities.py
@@ -107,8 +107,10 @@ def exclude_hook(conduit):
         only_samearch = True
 
     cnt = 0
+    if check_obsoletes and not conduit._base.conf.obsoletes:
+        check_obsoletes = False
     if check_obsoletes:
-        obsoletes = conduit._base.pkgSack.returnObsoletes() 
+        obsoletes = conduit._base.up.rawobsoletes
 
     # Build a dictionary with package priorities. Either with arch or
     # archless, based on the user's settings.


More information about the Yum-commits mailing list