[yum-cvs] package-cleanup.py

Tim Lauridsen timlau at linux.duke.edu
Fri Sep 28 12:45:22 UTC 2007


 package-cleanup.py |   11 +++++++++++
 1 file changed, 11 insertions(+)

New commits:
commit 94fa23caec9f4e6a86941dd90ded392f568423e1
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Fri Sep 28 14:44:55 2007 +0200

    Make package-cleanup --orphans work as no root (rhbz #253352)

diff --git a/package-cleanup.py b/package-cleanup.py
index 80405a6..607ffee 100755
--- a/package-cleanup.py
+++ b/package-cleanup.py
@@ -34,11 +34,22 @@ from rpmUtils import miscutils, transaction
 from optparse import OptionParser
 from yum.packages import YumInstalledPackage
 from yum import Errors
+from yum.misc import getCacheDir
+
 
 def initYum(opts):
     my = yum.YumBase()
     my.doConfigSetup(opts.conffile,init_plugins=False)
     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
         my.doRepoSetup()
     else:
         # Disable all enabled repositories



More information about the Yum-cvs-commits mailing list