[yum-commits] Branch 'yum-3_2_X' - yum/__init__.py
James Antill
james at osuosl.org
Fri May 22 22:00:30 UTC 2009
yum/__init__.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
New commits:
commit 22ca5115d59d795bac23eb608700f36be96bc99b
Author: James Antill <james at and.org>
Date: Fri May 22 18:00:16 2009 -0400
Add setCacheDir(), to make setting user cache dirs. easier
diff --git a/yum/__init__.py b/yum/__init__.py
index 942244e..06f8787 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -3842,3 +3842,20 @@ class YumBase(depsolve.Depsolve):
self.repos.enableRepo(newrepo.id)
return newrepo
+ def setCacheDir(self, force=False, tmpdir='/var/tmp', reuse=True,
+ suffix='/$basearch/$releasever'):
+ ''' Set a new cache dir, using misc.getCacheDir() and var. replace
+ on suffix. '''
+
+ if not force and os.geteuid() == 0:
+ return True # We are root, not forced, so happy with the global dir.
+
+ cachedir = misc.getCacheDir(tmpdir, reuse)
+ if cachedir is None:
+ return False # Tried, but failed, to get a "user" cachedir
+
+ self.repos.setCacheDir(cachedir + varReplace(suffix, self.yumvar))
+ self.conf.cache = 0 # yum set cache=1, if uid != 0
+
+ return True # We got a new cache dir
+
More information about the Yum-commits
mailing list