From 99c4bda93815856c1c2c1c356b8099965374c31b Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Tue, 5 Jun 2012 15:56:30 +0800 Subject: [PATCH] resolve right url for attachment package Signed-off-by: Gui Chen --- mic/imager/baseimager.py | 5 ++++- plugins/backend/zypppkgmgr.py | 27 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index ce8160f..daa39d0 100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -858,7 +858,10 @@ class BaseImageCreator(object): if not url: msger.warning("Can't get url from repo for %s" % item) continue - proxies = proxy.get_proxy_for(url) + proxies = None + aproxy = proxy.get_proxy_for(url) + if aproxy: + proxies = {url.split(':')[0]: aproxy} fpath = os.path.join(self.cachedir, os.path.basename(url)) if not os.path.exists(fpath): # download pkgs diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index 15e1850..a7e3c12 100755 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -825,6 +825,29 @@ class Zypp(BackendPlugin): repourl = str(repoinfo.baseUrls()[0]) return get_proxy_for(repourl) + def _get_url(self, pobj): + if not pobj: + return None + + name = str(pobj.repoInfo().name()) + try: + repo = filter(lambda r: r.name == name, self.repos)[0] + except IndexError: + return None + + baseurl = repo.baseurl[0] + + index = baseurl.find("?") + if index > -1: + baseurl = baseurl[:index] + + location = zypp.asKindPackage(pobj).location() + location = str(location.filename()) + if location.startswith("./"): + location = location[2:] + + return os.path.join(baseurl, location) + def package_url(self, pkg): def cmpEVR(ed1, ed2): @@ -844,8 +867,6 @@ class Zypp(BackendPlugin): reverse=True) if items: - baseurl = items[0].repoInfo().baseUrls()[0] - location = zypp.asKindPackage(items[0]).location() - return os.path.join(str(baseurl), str(location.filename())) + return self._get_url(items[0]) return None -- 2.7.4