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):
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)
# 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()
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)
"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)
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()
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)
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)
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()
self._root_confirm()
imagetype = misc.get_image_type(targetimage)
- if imagetype == "ext3fsimg":
+ if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg"):
imagetype = "loop"
chrootclass = None