Fix --pkgmgr=yum does not use cached download packages
authorHuanhuan Li <huanhuanx.li@intel.com>
Tue, 20 Aug 2013 23:49:12 +0000 (07:49 +0800)
committerHuanhuan Li <huanhuanx.li@intel.com>
Wed, 21 Aug 2013 05:30:59 +0000 (13:30 +0800)
Change-Id: I81fba9c393a7fd13b0ce22c5c9e8027fa14bf315
Fixes: #1547

plugins/backend/yumpkgmgr.py

index d4bf31f..93c54cb 100644 (file)
@@ -45,6 +45,10 @@ sslverify=1
 """
 
 class MyYumRepository(yum.yumRepo.YumRepository):
+    def __init__(self, repoid, nocache):
+        super(MyYumRepository, self).__init__(repoid)
+        self.nocache = nocache
+
     def __del__(self):
         pass
 
@@ -264,8 +268,7 @@ class Yum(BackendPlugin, yum.YumBase):
             option = option.replace("$basearch", rpmUtils.arch.getBaseArch())
             option = option.replace("$arch", rpmUtils.arch.getCanonArch())
             return option
-
-        repo = MyYumRepository(name)
+        repo = MyYumRepository(name, nocache)
 
         # Set proxy
         repo.proxy = proxy
@@ -284,7 +287,6 @@ class Yum(BackendPlugin, yum.YumBase):
                 repo.setAttribute(k, v)
 
         repo.sslverify = ssl_verify
-        repo.cache = not nocache
 
         repo.basecachedir = self.cachedir
         repo.base_persistdir = self.conf.persistdir
@@ -374,7 +376,7 @@ class Yum(BackendPlugin, yum.YumBase):
         for po in dlpkgs:
             local = po.localPkg()
             repo = filter(lambda r: r.id == po.repoid, self.repos.listEnabled())[0]
-            if not repo.cache and os.path.exists(local):
+            if repo.nocache and os.path.exists(local):
                 os.unlink(local)
             if not os.path.exists(local):
                 continue