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
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
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:
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)