[yum-commits] 3 commits - package-cleanup.py plugins/changelog

James Antill james at osuosl.org
Mon Jun 22 06:45:45 UTC 2009


 package-cleanup.py             |   25 +++++++++++++------------
 plugins/changelog/changelog.py |    8 +++++---
 2 files changed, 18 insertions(+), 15 deletions(-)

New commits:
commit 71308f5d13b697a78d81935a086071367a2b0920
Author: James Antill <james at and.org>
Date:   Mon Jun 22 02:45:33 2009 -0400

    Use base.setCacheDir() in package-cleanup

diff --git a/package-cleanup.py b/package-cleanup.py
index 13a09de..d486847 100755
--- a/package-cleanup.py
+++ b/package-cleanup.py
@@ -29,7 +29,6 @@ import re
 
 from rpmUtils import miscutils, transaction
 from optparse import OptionParser
-from yum.misc import getCacheDir
 
 
 def initYum(opts):
@@ -45,15 +44,9 @@ def initYum(opts):
                      debuglevel=debuglevel,errorlevel=errorlevel)
 
     if opts.orphans:
-        # make it work as non root user.
-        if my.conf.uid != 0:
-            cachedir = getCacheDir()
-            if cachedir is None:
-                my.logger.error("Error: Could not make cachedir, exiting")
-                sys.exit(50)
-            my.repos.setCacheDir(cachedir)
-            # Turn of cache
-            my.conf.cache = 0
+        if not my.setCacheDir():
+            my.logger.error("Error: Could not make cachedir, exiting")
+            sys.exit(50)
         my.doRepoSetup()
     elif opts.dupes or opts.cleandupes:
         need_repos = False
commit 10d12a2d4e73fd77832dacfad7aab35835e317c9
Author: James Antill <james at and.org>
Date:   Mon Jun 22 02:37:44 2009 -0400

    Don't setup repos. when doing dupes processing

diff --git a/package-cleanup.py b/package-cleanup.py
index f73061f..13a09de 100755
--- a/package-cleanup.py
+++ b/package-cleanup.py
@@ -38,9 +38,12 @@ def initYum(opts):
     if opts.quiet:
         debuglevel=0
         errorlevel=0
+    need_repos = True
     my = yum.YumBase()
+    # This should be preconf
     my.doConfigSetup(opts.conffile,init_plugins=not opts.noplugins,
                      debuglevel=debuglevel,errorlevel=errorlevel)
+
     if opts.orphans:
         # make it work as non root user.
         if my.conf.uid != 0:
@@ -52,13 +55,17 @@ def initYum(opts):
             # Turn of cache
             my.conf.cache = 0
         my.doRepoSetup()
+    elif opts.dupes or opts.cleandupes:
+        need_repos = False
     else:
         # Disable all enabled repositories
         for repo in my.repos.listEnabled():
             my.repos.disableRepo(repo.id)
 
-    my.doTsSetup()
-    my.doSackSetup()
+    # FIXME: Is any of this needed anymore?
+    if need_repos:
+        my.doTsSetup()
+        my.doSackSetup()
     my.doRpmDBSetup()
     my.localPackages = []
     return my
@@ -195,6 +202,7 @@ def printDupes(my, qf):
 def cleanOldDupes(my, confirmed, qf):
     """remove all the older duplicates"""
     dupedict = findDupes(my)
+    my._getTs(True) # Remove only transaction, no repos/pkgSacks.
     removedupes = []
     for (n) in dupedict.keys():
         if n.startswith('kernel'):
commit 5c8f82ea4f294002014f459e944387055e1a8b8c
Author: James Antill <james at and.org>
Date:   Mon Jun 22 02:31:32 2009 -0400

    Don't assume pkgs have sourcerpm, in changelog plugin

diff --git a/plugins/changelog/changelog.py b/plugins/changelog/changelog.py
index 1e58b8c..6c4d29d 100644
--- a/plugins/changelog/changelog.py
+++ b/plugins/changelog/changelog.py
@@ -279,9 +279,11 @@ def postresolve_hook(conduit):
         mdi = UpdateMetadata(repos=list(repos))
     for tsmem in ts.getMembers():
         for po in rpmdb.searchNevra(name=tsmem.po.name, arch=tsmem.po.arch):
-            hdr = po.hdr
-            times = hdr['changelogtime']
-            n,v,r,e,a = splitFilename(hdr['sourcerpm'])
+            times = po.hdr['changelogtime']
+            try:
+                n,v,r,e,a = splitFilename(po.sourcerpm)
+            except TypeError:
+                n = po.name
             if len(times) == 0:
                 # deal with packages without changelog
                 origpkgs[n] = 0 


More information about the Yum-commits mailing list