add shell option for convertor to enable modification before conerting
authorGui Chen <gui.chen@intel.com>
Mon, 16 Jan 2012 03:14:35 +0000 (11:14 +0800)
committerJF Ding <jian-feng.ding@intel.com>
Mon, 16 Jan 2012 05:40:19 +0000 (13:40 +0800)
recreate image modified by internal shell

Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/conf.py
plugins/imager/livecd_plugin.py
plugins/imager/liveusb_plugin.py
tools/mic

index 54d8ab4..05832f6 100644 (file)
@@ -53,7 +53,9 @@ class ConfigMgr(object):
                     "runtime": None,
                 },
                 'chroot': {},
-                'convert': {},
+                'convert': {
+                    "shell": False,
+                },
                 'bootstraps': {},
                }
 
index 4c1ac71..6572eef 100644 (file)
@@ -177,8 +177,8 @@ class LiveCDPlugin(ImagerPlugin):
                raise errors.CreatorError("Failed to run post cleanups: %s" % msg)
 
         convertoropts = configmgr.convert
+        convertoropts['name'] = os.path.splitext(os.path.basename(base_on))[0]
         convertor = livecd.LiveCDImageCreator(convertoropts)
-        convertor.name = os.path.splitext(os.path.basename(base_on))[0]
         imgtype = misc.get_image_type(base_on)
         if imgtype == "btrfsimg":
             fstype = "btrfs"
@@ -192,6 +192,7 @@ class LiveCDPlugin(ImagerPlugin):
             __mkinitrd(convertor)
             convertor._create_bootconfig()
             __run_post_cleanups(convertor)
+            convertor.launch_shell(convertoropts['shell'])
             convertor.unmount()
             convertor.package()
             convertor.print_outimage_info()
index e638b10..cbcf81e 100644 (file)
@@ -180,8 +180,8 @@ class LiveUSBPlugin(ImagerPlugin):
                raise errors.CreatorError("Failed to run post cleanups: %s" % msg)
 
         convertoropts = configmgr.convert
+        convertoropts['name'] = os.path.splitext(os.path.basename(base_on))[0]
         convertor = liveusb.LiveUSBImageCreator(convertoropts)
-        convertor.name = os.path.splitext(os.path.basename(base_on))[0]
         imgtype = misc.get_image_type(base_on)
         if imgtype == "btrfsimg":
             fstype = "btrfs"
@@ -195,6 +195,7 @@ class LiveUSBPlugin(ImagerPlugin):
             __mkinitrd(convertor)
             convertor._create_bootconfig()
             __run_post_cleanups(convertor)
+            convertor.launch_shell(convertoropts['shell'])
             convertor.unmount()
             convertor.package()
             convertor.print_outimage_info()
index 1a08e85..c55c5f1 100755 (executable)
--- a/tools/mic
+++ b/tools/mic
@@ -18,6 +18,7 @@
 import os, sys, errno
 from mic import msger, creator
 from mic.utils import cmdln, misc, errors
+from mic.conf import configmgr
 from mic.plugin import pluginmgr
 from mic.__version__ import VERSION
 
@@ -82,6 +83,9 @@ class MicCmd(cmdln.Cmdln):
             msger.error('Root permission is required to continue, abort')
 
     @cmdln.alias("cv")
+    @cmdln.option("-S", "--shell",
+                  action="store_true", dest="shell", default=False,
+                  help="Launch shell before packaging the converted image")
     def do_convert(self, subcmd, opts, *args):
         """${cmd_name}: convert image format
 
@@ -110,6 +114,8 @@ class MicCmd(cmdln.Cmdln):
 
         self._root_confirm()
 
+        configmgr.convert['shell'] = opts.shell
+
         srcformat = misc.get_image_type(srcimg)
         if srcformat == "ext3fsimg":
             srcformat = "loop"