From bd2acce1eac38938d26edead07cb507715b15619 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Tue, 18 Sep 2012 21:24:38 +0800 Subject: [PATCH] add --repourl for BOSS to replace baseurl in zypp repo file for BOSS, the baseurl in zypp repo file should be corrected. to enable it, append the option like below: --repourl="Tizen-main=http://download.example.com/x/y/z/" --repourl="Tizen-base=http://download.example.com/z/y/x/" Signed-off-by: Gui Chen Change-Id: I9e7d395de15fed6b8f89899ff0721d3eb515ff45 --- mic/conf.py | 1 + mic/creator.py | 11 +++++++++++ mic/imager/baseimager.py | 3 ++- mic/kickstart/__init__.py | 4 +++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mic/conf.py b/mic/conf.py index 74dbc0f..d0d96ce 100644 --- a/mic/conf.py +++ b/mic/conf.py @@ -60,6 +60,7 @@ class ConfigMgr(object): "proxy": None, "no_proxy": None, "copy_kernel": False, + "repourl": {}, }, 'chroot': { "saveto": None, diff --git a/mic/creator.py b/mic/creator.py index 428e2b7..d6a1768 100644 --- a/mic/creator.py +++ b/mic/creator.py @@ -108,6 +108,9 @@ class Creator(cmdln.Cmdln): dest='copy_kernel', help='Copy kernel files from image /boot directory' ' to the image output directory.') + optparser.add_option('', '--repourl', action='append', + dest='repourl', default=[], + help=SUPPRESS_HELP) return optparser def preoptparse(self, argv): @@ -212,6 +215,14 @@ class Creator(cmdln.Cmdln): if self.options.copy_kernel: configmgr.create['copy_kernel'] = self.options.copy_kernel + if self.options.repourl: + for item in self.options.repourl: + try: + key, val = item.split('=') + except: + continue + configmgr.create['repourl'][key] = val + def main(self, argv=None): if argv is None: argv = sys.argv diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 6d4256d..92bdc86 100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -75,6 +75,7 @@ class BaseImageCreator(object): self.target_arch = "noarch" self._local_pkgs_path = None self.pack_to = None + self.repourl = {} # If the kernel is save to the destdir when copy_kernel cmd is called. self._need_copy_kernel = False @@ -1035,7 +1036,7 @@ class BaseImageCreator(object): kickstart.RPMMacroConfig(self._instroot).apply(self.ks) kickstart.DesktopConfig(self._instroot).apply(ksh.desktop) self.__save_repo_keys(repodata) - kickstart.MoblinRepoConfig(self._instroot).apply(ksh.repo, repodata) + kickstart.MoblinRepoConfig(self._instroot).apply(ksh.repo, repodata, self.repourl) except: msger.warning("Failed to apply configuration to image") raise diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index 27437b7..7386ff6 100644 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -496,8 +496,10 @@ class MoblinRepoConfig(KickstartConfig): f.close() @apply_wrapper - def apply(self, ksrepo, repodata): + def apply(self, ksrepo, repodata, repourl): for repo in ksrepo.repoList: + if repo.name in repourl: + repo.baseurl = repourl[repo.name] if repo.save: #self.__create_repo_file(repo, "/etc/yum.repos.d") self.__create_repo_file(repo, "/etc/zypp/repos.d") -- 2.7.4