def do_unpack(cls, srcimg): img = srcimg imgsize = misc.get_file_size(img) * 1024L * 1024L imgmnt = misc.mkdtemp() disk = fs_related.SparseLoopbackDisk(img, imgsize) imgloop = PartitionedMount(imgmnt, skipformat=True) imgloop.add_disk('/dev/sdb', disk) imgloop.add_partition(imgsize / 1024 / 1024, "/dev/sdb", "/", "vfat", boot=False) try: imgloop.mount() except errors.MountError: imgloop.cleanup() raise # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(imgmnt + "/squashfs.img"): squashimg = imgmnt + "/squashfs.img" else: squashimg = imgmnt + "/LiveOS/squashfs.img" tmpoutdir = misc.mkdtemp() # unsquashfs requires outdir mustn't exist shutil.rmtree(tmpoutdir, ignore_errors=True) misc.uncompress_squashfs(squashimg, tmpoutdir) try: # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(tmpoutdir + "/os.img"): os_image = tmpoutdir + "/os.img" else: os_image = tmpoutdir + "/LiveOS/ext3fs.img" if not os.path.exists(os_image): 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) finally: imgloop.cleanup() shutil.rmtree(tmpoutdir, ignore_errors=True) shutil.rmtree(imgmnt, ignore_errors=True) return rtimage
def do_unpack(cls, srcimg): img = srcimg imgsize = misc.get_file_size(img) * 1024L * 1024L imgmnt = misc.mkdtemp() disk = fs_related.SparseLoopbackDisk(img, imgsize) imgloop = PartitionedMount(imgmnt, skipformat = True) imgloop.add_disk('/dev/sdb', disk) imgloop.add_partition(imgsize/1024/1024, "/dev/sdb", "/", "vfat", boot=False) try: imgloop.mount() except errors.MountError: imgloop.cleanup() raise # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(imgmnt + "/squashfs.img"): squashimg = imgmnt + "/squashfs.img" else: squashimg = imgmnt + "/LiveOS/squashfs.img" tmpoutdir = misc.mkdtemp() # unsquashfs requires outdir mustn't exist shutil.rmtree(tmpoutdir, ignore_errors = True) misc.uncompress_squashfs(squashimg, tmpoutdir) try: # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(tmpoutdir + "/os.img"): os_image = tmpoutdir + "/os.img" else: os_image = tmpoutdir + "/LiveOS/ext3fs.img" if not os.path.exists(os_image): 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) finally: imgloop.cleanup() shutil.rmtree(tmpoutdir, ignore_errors = True) shutil.rmtree(imgmnt, ignore_errors = True) return rtimage
def do_unpack(cls, srcimg): img = srcimg imgmnt = misc.mkdtemp() imgloop = fs_related.DiskMount(fs_related.LoopbackDisk(img, 0), imgmnt) try: imgloop.mount() except errors.MountError: imgloop.cleanup() raise # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(imgmnt + "/squashfs.img"): squashimg = imgmnt + "/squashfs.img" else: squashimg = imgmnt + "/LiveOS/squashfs.img" tmpoutdir = misc.mkdtemp() # unsquashfs requires outdir mustn't exist shutil.rmtree(tmpoutdir, ignore_errors=True) misc.uncompress_squashfs(squashimg, tmpoutdir) try: # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(tmpoutdir + "/os.img"): os_image = tmpoutdir + "/os.img" else: os_image = tmpoutdir + "/LiveOS/ext3fs.img" if not os.path.exists(os_image): 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) finally: imgloop.cleanup() shutil.rmtree(tmpoutdir, ignore_errors=True) shutil.rmtree(imgmnt, ignore_errors=True) return rtimage
def do_unpack(cls, srcimg): img = srcimg imgmnt = misc.mkdtemp() imgloop = fs_related.DiskMount(fs_related.LoopbackDisk(img, 0), imgmnt) try: imgloop.mount() except errors.MountError: imgloop.cleanup() raise # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(imgmnt + "/squashfs.img"): squashimg = imgmnt + "/squashfs.img" else: squashimg = imgmnt + "/LiveOS/squashfs.img" tmpoutdir = misc.mkdtemp() # unsquashfs requires outdir mustn't exist shutil.rmtree(tmpoutdir, ignore_errors=True) misc.uncompress_squashfs(squashimg, tmpoutdir) try: # legacy LiveOS filesystem layout support, remove for F9 or F10 if os.path.exists(tmpoutdir + "/os.img"): os_image = tmpoutdir + "/os.img" else: os_image = tmpoutdir + "/LiveOS/ext3fs.img" if not os.path.exists(os_image): 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) finally: imgloop.cleanup() shutil.rmtree(tmpoutdir, ignore_errors=True) shutil.rmtree(imgmnt, ignore_errors=True) return rtimage