[Yum] keepcache=1 on individual repos

Zdenek Pavlas zpavlas at redhat.com
Mon Aug 26 08:58:16 UTC 2013


> > No, it's a global option.  However, it seems quite easy
> > to implement as a per-repo option.  Will think about it..
> 
> That would be a useful option.  We use local repos that we don't need to
> cache and remote repos that we definitely want to cache.  I've been
> using a global keepcache=1 setting with a wrapper script to clean out
> only the local repos but a per-repo option would be simpler.
 
I've made a patch.. Could you fill a Bugzilla RFE against FC19?

commit ecd0b5a219f97ea63ff7722102e7b67f01628774
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date:   Mon Aug 26 10:55:50 2013 +0200

    per-repository "keepcache" option.

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 8a7de80..fcacbae 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -914,6 +914,10 @@ value of mirrorlist is copied to metalink (if metalink is not set).
 Either `1' or `0'. This tells yum whether or not use this repository.
 
 .IP
+\fBkeepcache\fR
+Overrides the \fBkeepcache\fR option from the [main] section for this repository.
+
+.IP
 \fBgpgcheck\fR
 Either `1' or `0'. This tells yum whether or not it should perform a GPG
 signature check on the packages gotten from this repository.
diff --git a/yum/__init__.py b/yum/__init__.py
index 7a5332b..cf9cd39 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1830,8 +1830,7 @@ much more problems).
                                           errors=errors)
 
                           
-        if (not self.conf.keepcache and
-            not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST)):
+        if not self.ts.isTsFlagSet(rpm.RPMTRANS_FLAG_TEST):
             self.cleanUsedHeadersPackages()
         
         for i in ('ts_all_fn', 'ts_done_fn'):
@@ -2671,6 +2670,8 @@ much more problems).
                 continue
             if txmbr.po.repoid not in self.repos.repos:
                 continue
+            if txmbr.po.repo.keepcache:
+                continue
             
             # make sure it's not a local file
             repo = self.repos.repos[txmbr.po.repoid]
diff --git a/yum/config.py b/yum/config.py
index 1d446c0..3bc5bd1 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -942,6 +942,7 @@ class RepoConf(BaseConfig):
 
     name = Option()
     enabled = Inherit(YumConf.enabled)
+    keepcache = Inherit(YumConf.keepcache)
     baseurl = UrlListOption()
     mirrorlist = UrlOption()
     metalink   = UrlOption()



More information about the Yum mailing list