add --repourl for BOSS to replace baseurl in zypp repo file
authorGui Chen <gui.chen@intel.com>
Tue, 18 Sep 2012 13:24:38 +0000 (21:24 +0800)
committerGui Chen <gui.chen@intel.com>
Thu, 20 Sep 2012 03:07:13 +0000 (11:07 +0800)
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 <gui.chen@intel.com>
Change-Id: I9e7d395de15fed6b8f89899ff0721d3eb515ff45

mic/conf.py
mic/creator.py
mic/imager/baseimager.py
mic/kickstart/__init__.py

index 74dbc0f..d0d96ce 100644 (file)
@@ -60,6 +60,7 @@ class ConfigMgr(object):
                     "proxy": None,
                     "no_proxy": None,
                     "copy_kernel": False,
+                    "repourl": {},
                 },
                 'chroot': {
                     "saveto": None,
index 428e2b7..d6a1768 100644 (file)
@@ -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
index 6d4256d..92bdc86 100644 (file)
@@ -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
index 27437b7..7386ff6 100644 (file)
@@ -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")