The value of fstype is not cpio, an image is generated by cpio.
authorxiaojuan.mao <xiaojuan.mao@samsung.com>
Fri, 13 Oct 2017 04:07:08 +0000 (12:07 +0800)
committeryuhuan.yang <yuhuan.yang@samsung.com>
Fri, 26 Jan 2018 08:35:20 +0000 (16:35 +0800)
Change-Id: Ia9ae3d445c708b444da0dee1e5060725db9b9403

mic/imager/baseimager.py

index cca4e50..f39d236 100755 (executable)
@@ -33,7 +33,7 @@ import rpm
 import time
 from mic import kickstart
 from mic import msger, __version__ as VERSION
-from mic.utils.errors import CreatorError, Abort
+from mic.utils.errors import CreatorError, KsError, Abort
 from mic.utils import misc, grabber, runner, fs_related as fs
 from mic.chroot import kill_proc_inchroot
 from mic.archive import get_archive_suffixes
@@ -154,8 +154,11 @@ class BaseImageCreator(object):
                 if part.fstype and part.fstype == "btrfs":
                     self._dep_checks.append("mkfs.btrfs")
                     break
-                if part.fstype == "cpio":
-                    part.fstype = "ext4"
+                if part.cpioopts:
+                    if part.fstype == "cpio": 
+                        part.fstype = "ext4"
+                    else:
+                        raise KsError("The '--fstype' in ks file need to set 'cpio' when you want to generate image by cpio.")
             if len(self.ks.handler.partition.partitions) > 1:
                 self.multiple_partitions = True
 
@@ -1377,7 +1380,7 @@ class BaseImageCreator(object):
                         runner.show('find . | cpio --create %s | gzip > %s' % (item['cpioopts'], tmp_cpio_imgfile))
                         os.chdir(oldoutdir)
                 except OSError, (errno, msg):
-                    raise errors.CreatorError("Create image by cpio error: %s" % msg)
+                    raise CreatorError("Create image by cpio error: %s" % msg)
 
     def copy_cpio_image(self):
         for item in self._instloops:
@@ -1387,7 +1390,7 @@ class BaseImageCreator(object):
                 try:
                     shutil.copyfile(os.path.join(tmp_cpio, item['name']),os.path.join(self._imgdir, item['name']))
                 except IOError:
-                    raise errors.CreatorError("Copy cpio image error")
+                    raise CreatorError("Copy cpio image error")
                 os.remove(os.path.join(tmp_cpio, item['name']))
                 if not os.listdir(tmp_cpio):
                     shutil.rmtree(tmp_cpio, ignore_errors=True)