From fe7437e1872475aae4fbfe4f84ddcaec5d0dcc92 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Tue, 21 Aug 2012 23:31:01 +0800 Subject: [PATCH] auto selecting backend with 'pkgmgr=auto' Signed-off-by: Gui Chen --- mic/conf.py | 4 ++-- mic/rt_util.py | 8 +++----- plugins/imager/fs_plugin.py | 5 ++++- plugins/imager/livecd_plugin.py | 5 ++++- plugins/imager/liveusb_plugin.py | 5 ++++- plugins/imager/loop_plugin.py | 5 ++++- plugins/imager/raw_plugin.py | 5 ++++- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/mic/conf.py b/mic/conf.py index c7d3317..5177480 100644 --- a/mic/conf.py +++ b/mic/conf.py @@ -44,7 +44,7 @@ class ConfigMgr(object): "outdir": './mic-output', "arch": None, # None means auto-detect - "pkgmgr": "yum", + "pkgmgr": "auto", "name": "output", "ksfile": None, "ks": None, @@ -227,7 +227,7 @@ class ConfigMgr(object): self.bootstrap['enable'] = parser.getboolean('main', 'enable') except: self.bootstrap['enable'] = False - if self.bootstrap['distro_name']: + if not self.bootstrap['distro_name']: self.bootstrap['distro_name'] = self.common['distro_name'] configmgr = ConfigMgr() diff --git a/mic/rt_util.py b/mic/rt_util.py index f538271..16834f5 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -149,10 +149,8 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', raise errors.BootstrapError(err) # clean stuff: - # yum backend, not available in bootstrap; # bootstrap.conf, disable bootstrap mode inside bootstrap - clrpaths = [os.path.join(libpth, 'plugins/backend/yumpkgmgr.py'), - os.path.join(libpth, 'plugins/backend/yumpkgmgr.pyc'), + clrpaths = [ '/etc/mic/bootstrap.conf', ] @@ -162,9 +160,9 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', except: pass - # use default zypp backend + # auto select backend conf_str = file(_path(conf)).read() - conf_str = re.sub("pkgmgr\s*=\s*yum", "pkgmgr=zypp", conf_str) + conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str) with open(_path(conf), 'w') as wf: wf.write(conf_str) diff --git a/plugins/imager/fs_plugin.py b/plugins/imager/fs_plugin.py index 03b3b1b..d972fe5 100644 --- a/plugins/imager/fs_plugin.py +++ b/plugins/imager/fs_plugin.py @@ -67,7 +67,10 @@ class FsPlugin(ImagerPlugin): # try to find the pkgmgr pkgmgr = None for (key, pcls) in pluginmgr.get_plugins('backend').iteritems(): - if key == creatoropts['pkgmgr']: + if 'auto' == creatoropts['pkgmgr']: + pkgmgr = pcls + break + elif key == creatoropts['pkgmgr']: pkgmgr = pcls break diff --git a/plugins/imager/livecd_plugin.py b/plugins/imager/livecd_plugin.py index 680217e..424404f 100644 --- a/plugins/imager/livecd_plugin.py +++ b/plugins/imager/livecd_plugin.py @@ -67,7 +67,10 @@ class LiveCDPlugin(ImagerPlugin): # try to find the pkgmgr pkgmgr = None for (key, pcls) in pluginmgr.get_plugins('backend').iteritems(): - if key == creatoropts['pkgmgr']: + if 'auto' == creatoropts['pkgmgr']: + pkgmgr = pcls + break + elif key == creatoropts['pkgmgr']: pkgmgr = pcls break diff --git a/plugins/imager/liveusb_plugin.py b/plugins/imager/liveusb_plugin.py index 4b357e4..01afcbb 100644 --- a/plugins/imager/liveusb_plugin.py +++ b/plugins/imager/liveusb_plugin.py @@ -69,7 +69,10 @@ class LiveUSBPlugin(ImagerPlugin): # try to find the pkgmgr pkgmgr = None for (key, pcls) in pluginmgr.get_plugins('backend').iteritems(): - if key == creatoropts['pkgmgr']: + if 'auto' == creatoropts['pkgmgr']: + pkgmgr = pcls + break + elif key == creatoropts['pkgmgr']: pkgmgr = pcls break diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py index 28171b7..6c22b82 100644 --- a/plugins/imager/loop_plugin.py +++ b/plugins/imager/loop_plugin.py @@ -74,7 +74,10 @@ class LoopPlugin(ImagerPlugin): # try to find the pkgmgr pkgmgr = None for (key, pcls) in pluginmgr.get_plugins('backend').iteritems(): - if key == creatoropts['pkgmgr']: + if 'auto' == creatoropts['pkgmgr']: + pkgmgr = pcls + break + elif key == creatoropts['pkgmgr']: pkgmgr = pcls break diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py index e536443..8f31c03 100644 --- a/plugins/imager/raw_plugin.py +++ b/plugins/imager/raw_plugin.py @@ -72,7 +72,10 @@ class RawPlugin(ImagerPlugin): # try to find the pkgmgr pkgmgr = None for (key, pcls) in pluginmgr.get_plugins('backend').iteritems(): - if key == creatoropts['pkgmgr']: + if 'auto' == creatoropts['pkgmgr']: + pkgmgr = pcls + break + elif key == creatoropts['pkgmgr']: pkgmgr = pcls break -- 2.7.4