diff options
author | Gui Chen <gui.chen@intel.com> | 2011-11-17 17:13:04 +0800 |
---|---|---|
committer | Gui Chen <gui.chen@intel.com> | 2011-11-17 17:14:36 +0800 |
commit | a4b43fc9ed5df9d6b34dd4d8d2b286c7e8c3f8fd (patch) | |
tree | 7e606bfd2fd1d67bffb51e8eaae4fb46a6520eb4 | |
parent | bf26cfdf12463d81bd7c7a111849a41f60af4e59 (diff) | |
download | mic-a4b43fc9ed5df9d6b34dd4d8d2b286c7e8c3f8fd.tar.gz mic-a4b43fc9ed5df9d6b34dd4d8d2b286c7e8c3f8fd.tar.bz2 mic-a4b43fc9ed5df9d6b34dd4d8d2b286c7e8c3f8fd.zip |
support btrfs and ext4 for creator, chroot, convert
it's not backported from mic2
Signed-off-by: Gui Chen <gui.chen@intel.com>
-rw-r--r-- | mic/utils/misc.py | 6 | ||||
-rw-r--r-- | plugins/imager/livecd_plugin.py | 30 | ||||
-rw-r--r-- | plugins/imager/liveusb_plugin.py | 31 | ||||
-rw-r--r-- | plugins/imager/loop_plugin.py | 16 | ||||
-rwxr-xr-x | tools/mic | 2 |
5 files changed, 65 insertions, 20 deletions
diff --git a/mic/utils/misc.py b/mic/utils/misc.py index e6cd294..3188b3c 100644 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -111,6 +111,8 @@ def get_image_type(path): rawptn = re.compile(r".*x86 boot sector.*") vmdkptn = re.compile(r".*VMware. disk image.*") ext3fsimgptn = re.compile(r".*Linux.*ext3 filesystem data.*") + ext4fsimgptn = re.compile(r".*Linux.*ext4 filesystem data.*") + btrfsimgptn = re.compile(r".*BTRFS.*") if isoptn.match(output): return maptab["iso"] elif usbimgptn.match(output): @@ -121,6 +123,10 @@ def get_image_type(path): return maptab["vmdk"] elif ext3fsimgptn.match(output): return "ext3fsimg" + elif ext4fsimgptn.match(output): + return "ext4fsimg" + elif btrfsimgptn.match(output): + return "btrfsimg" else: raise CreatorError("Cannot detect the type of image: %s" % path) diff --git a/plugins/imager/livecd_plugin.py b/plugins/imager/livecd_plugin.py index fa1d058..ef5590f 100644 --- a/plugins/imager/livecd_plugin.py +++ b/plugins/imager/livecd_plugin.py @@ -113,16 +113,22 @@ class LiveCDPlugin(ImagerPlugin): # unpack image to target dir imgsize = misc.get_file_size(os_image) * 1024L * 1024L - extmnt = misc.mkdtemp() - tfstype = "ext3" - tlabel = "ext3 label" + imgtype = misc.get_image_type(os_image) + if imgtype == "btrfsimg": + fstype = "btrfs" + myDiskMount = fs_related.BtrfsDiskMount + elif imgtype in ("ext3fsimg", "ext4fsimg"): + fstype = imgtype[:4] + myDiskMount = fs_related.ExtDiskMount + else: + raise errors.CreatorError("Unsupported filesystem type: %s" % fstype) - MyDiskMount = fs_related.ExtDiskMount - extloop = MyDiskMount(fs_related.SparseLoopbackDisk(os_image, imgsize), + extmnt = misc.mkdtemp() + extloop = myDiskMount(fs_related.SparseLoopbackDisk(os_image, imgsize), extmnt, - tfstype, + fstype, 4096, - tlabel) + "%s label" % fstype) try: extloop.mount() @@ -162,7 +168,14 @@ class LiveCDPlugin(ImagerPlugin): convertor = livecd.LiveCDImageCreator() convertor.name = os.path.splitext(os.path.basename(base_on))[0] - convertor._set_fstype("ext3") + imgtype = misc.get_image_type(base_on) + if imgtype == "btrfsimg": + fstype = "btrfs" + elif imgtype in ("ext3fsimg", "ext4fsimg"): + fstype = imgtype[:4] + else: + raise errors.CreatorError("Unsupported filesystem type: %s" % fstype) + convertor._set_fstype(fstype) try: convertor.mount(base_on) __mkinitrd(convertor) @@ -208,6 +221,7 @@ class LiveCDPlugin(ImagerPlugin): "LiveOS/ext3fs.img nor os.img exist" %img) imgname = os.path.basename(srcimg) + imgname = os.path.splitext(imgname)[0] + ".img" rtimage = os.path.join(tempfile.mkdtemp(dir = "/var/tmp", prefix = "tmp"), imgname) shutil.copyfile(os_image, rtimage) diff --git a/plugins/imager/liveusb_plugin.py b/plugins/imager/liveusb_plugin.py index 67d204b..7af6feb 100644 --- a/plugins/imager/liveusb_plugin.py +++ b/plugins/imager/liveusb_plugin.py @@ -113,18 +113,25 @@ class LiveUSBPlugin(ImagerPlugin): os_image = cls.do_unpack(target) os_image_dir = os.path.dirname(os_image) - #unpack image to target dir + # unpack image to target dir imgsize = misc.get_file_size(os_image) * 1024L * 1024L - extmnt = misc.mkdtemp() - tfstype = "ext3" - tlabel = "ext3 label" + imgtype = misc.get_image_type(os_image) + if imgtype == "btrfsimg": + fstype = "btrfs" + myDiskMount = fs_related.BtrfsDiskMount + elif imgtype in ("ext3fsimg", "ext4fsimg"): + fstype = imgtype[:4] + myDiskMount = fs_related.ExtDiskMount + else: + raise errors.CreatorError("Unsupported filesystem type: %s" % fstype) - MyDiskMount = fs_related.ExtDiskMount + extmnt = misc.mkdtemp() extloop = MyDiskMount(fs_related.SparseLoopbackDisk(os_image, imgsize), extmnt, - tfstype, + fstype, 4096, - tlabel) + "%s label" % fstype) + try: extloop.mount() @@ -164,7 +171,14 @@ class LiveUSBPlugin(ImagerPlugin): convertor = liveusb.LiveUSBImageCreator() convertor.name = os.path.splitext(os.path.basename(base_on))[0] - convertor._set_fstype("ext3") + imgtype = misc.get_image_type(base_on) + if imgtype == "btrfsimg": + fstype = "btrfs" + elif imgtype in ("ext3fsimg", "ext4fsimg"): + fstype = imgtype[:4] + else: + raise errors.CreatorError("Unsupported filesystem type: %s" % fstyp) + convertor._set_fstype(fstype) try: convertor.mount(base_on) __mkinitrd(convertor) @@ -212,6 +226,7 @@ class LiveUSBPlugin(ImagerPlugin): raise errors.CreatorError("'%s' is not a valid live CD ISO : neither " "LiveOS/ext3fs.img nor os.img exist" %img) imgname = os.path.basename(srcimg) + imgname = os.path.splitext(imgname)[0] + ".img" rtimage = os.path.join(tempfile.mkdtemp(dir = "/var/tmp", prefix = "tmp"), imgname) shutil.copyfile(os_image, rtimage) diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py index f2ca0ee..4dc2236 100644 --- a/plugins/imager/loop_plugin.py +++ b/plugins/imager/loop_plugin.py @@ -111,12 +111,22 @@ class LoopPlugin(ImagerPlugin): def do_chroot(cls, target):#chroot.py parse opts&args img = target imgsize = misc.get_file_size(img) * 1024L * 1024L + imgtype = misc.get_image_type(img) + if imgtype == "btrfsimg": + fstype = "btrfs" + myDiskMount = fs_related.BtrfsDiskMount + elif imgtype in ("ext3fsimg", "ext4fsimg"): + fstype = imgtype[:4] + myDiskMount = fs_related.ExtDiskMount + else: + raise errors.CreatorError("Unsupported filesystem type: %s" % imgtype) + extmnt = misc.mkdtemp() - extloop = fs_related.ExtDiskMount(fs_related.SparseLoopbackDisk(img, imgsize), + extloop = myDiskMount(fs_related.SparseLoopbackDisk(img, imgsize), extmnt, - "ext3", + fstype, 4096, - "ext3 label") + "%s label" % fstype) try: extloop.mount() @@ -145,7 +145,7 @@ class Mic(cmdln.Cmdln): self._root_confirm() imagetype = misc.get_image_type(targetimage) - if imagetype == "ext3fsimg": + if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg"): imagetype = "loop" chrootclass = None |