summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGui Chen <gui.chen@intel.com>2013-01-15 16:29:44 +0800
committerGui Chen <gui.chen@intel.com>2013-01-20 09:53:28 +0800
commit8697543cb765b21366e8313642d811d0d5159402 (patch)
tree546e8dbcb33e1ba328c0a9e730cd901b42451cac /plugins
parentbe2d409b9dc2f8d7a29eeeefbb0e06b8224d1d2c (diff)
downloadmic-8697543cb765b21366e8313642d811d0d5159402.tar.gz
mic-8697543cb765b21366e8313642d811d0d5159402.tar.bz2
mic-8697543cb765b21366e8313642d811d0d5159402.zip
add a new opiton --nocache for repo command
this option '--nocache' in repo command is used to disable using cached rpm in this repo Signed-off-by: Gui Chen <gui.chen@intel.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/backend/yumpkgmgr.py8
-rwxr-xr-xplugins/backend/zypppkgmgr.py12
2 files changed, 17 insertions, 3 deletions
diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py
index 910f1cf..6a94631 100644
--- a/plugins/backend/yumpkgmgr.py
+++ b/plugins/backend/yumpkgmgr.py
@@ -257,8 +257,8 @@ class Yum(BackendPlugin, yum.YumBase):
def addRepository(self, name, url = None, mirrorlist = None, proxy = None,
proxy_username = None, proxy_password = None,
- inc = None, exc = None, ssl_verify=True, cost = None,
- priority=None):
+ inc = None, exc = None, ssl_verify=True, nocache=False,
+ cost = None, priority=None):
# TODO: Handle priority attribute for repos
def _varSubstitute(option):
# takes a variable and substitutes like yum configs do
@@ -290,6 +290,7 @@ 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
@@ -371,6 +372,9 @@ class Yum(BackendPlugin, yum.YumBase):
msger.info("\nChecking packages cache and packages integrity ...")
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):
+ os.unlink(local)
if not os.path.exists(local):
continue
if not self.verifyPkg(local, po, False):
diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py
index 468a8b7..48894b2 100755
--- a/plugins/backend/zypppkgmgr.py
+++ b/plugins/backend/zypppkgmgr.py
@@ -43,6 +43,7 @@ class RepositoryStub:
self.proxy = None
self.proxy_username = None
self.proxy_password = None
+ self.nocache = False
self.enabled = True
self.autorefresh = True
@@ -303,6 +304,7 @@ class Zypp(BackendPlugin):
inc = None,
exc = None,
ssl_verify = True,
+ nocache = False,
cost=None,
priority=None):
# TODO: Handle cost attribute for repos
@@ -320,6 +322,7 @@ class Zypp(BackendPlugin):
repo.proxy_username = proxy_username
repo.proxy_password = proxy_password
repo.ssl_verify = ssl_verify
+ repo.nocache = nocache
repo.baseurl.append(url)
if inc:
for pkg in inc:
@@ -448,8 +451,15 @@ class Zypp(BackendPlugin):
cached_count += 1
else:
local = self.getLocalPkgPath(po)
+ name = str(po.repoInfo().name())
+ try:
+ repo = filter(lambda r: r.name == name, self.repos)[0]
+ except IndexError:
+ repo = None
+ nocache = repo.nocache if repo else False
+
if os.path.exists(local):
- if self.checkPkg(local) != 0:
+ if nocache or self.checkPkg(local) !=0:
os.unlink(local)
else:
download_total_size -= int(po.downloadSize())