# The maximum string length supported for LoopImageCreator.fslabel
FSLABEL_MAXLEN = 32
-
+# Support for Read-only file system list
+AFTER_MNT_FS = {"squashfs":".sqsh", "vdfs":".vdfs"}
def save_mountpoints(fpath, loops, arch = None):
"""Save mount points mapping to file
"ext3")
self.__fsopts = kickstart.get_image_fsopts(self.ks,
"defaults,noatime")
+ if self.__fstype in AFTER_MNT_FS.keys():
+ self.__fstype = "ext4"
allloops = []
for part in sorted(kickstart.get_partitions(self.ks),
key=lambda p: p.mountpoint):
+ aft_fstype = None
if part.fstype == "swap":
continue
+ elif part.fstype in AFTER_MNT_FS.keys():
+ aft_fstype = part.fstype
+ part.fstype = "ext4"
label = part.label
mp = part.mountpoint
'name': imgname,
'size': part.size or 4096L * 1024 * 1024,
'fstype': part.fstype or 'ext3',
+ 'aft_fstype': aft_fstype or None,
'extopts': part.extopts or None,
+ 'vdfsopts': part.vdfsopts or None,
+ 'squashfsopts': part.squashfsopts or None,
'loop': None, # to be created in _mount_instroot
'uuid': part.uuid or None,
'kspart' : part,
if not self._instloops:
return None
- return [lo['name'] for lo in self._instloops]
+ names = []
+ for lo in self._instloops :
+ names.append(lo['name'])
+ for ro in AFTER_MNT_FS.values():
+ names.append(lo['name'].replace('.img',ro))
+ return list(set(names))
def _set_fstype(self, fstype):
self.__fstype = fstype
for item in self._instloops:
imgfile = os.path.join(self._imgdir, item['name'])
+
+ if item['aft_fstype'] in AFTER_MNT_FS.keys():
+ mountpoint = misc.mkdtemp()
+ ext4img = os.path.join(self._imgdir, item['name'])
+ runner.show('mount -t ext4 %s %s' % (ext4img, mountpoint))
+ runner.show('ls -al %s' % (mountpoint))
+# item['loop'].mount(None, 'not_create')
+# point_mnt = os.path.join(self._instroot, item['mountpoint'].lstrip('/'))
+
+ fs_suffix = AFTER_MNT_FS[item['aft_fstype']]
+ if item['aft_fstype'] == "squashfs":
+# fs.mksquashfs(mountpoint, self._outdir+"/"+item['label']+fs_suffix)
+ args = "mksquashfs " + mountpoint + " " + self._imgdir+"/"+item['label']+fs_suffix
+ if item['squashfsopts']:
+ squashfsopts=item['squashfsopts'].replace(',', ' ')
+ runner.show("mksquashfs --help")
+ runner.show("%s %s" % (args, squashfsopts))
+ else:
+ runner.show("%s " % args)
+
+ if item['aft_fstype'] == "vdfs":
+ ##FIXME temporary code - replace this with fs.mkvdfs()
+ if item['vdfsopts']:
+ vdfsopts=item['vdfsopts'].replace(',', ' ')
+ else:
+ vdfsopts="-i -z 1024M"
+
+ fullpathmkvdfs = "mkfs.vdfs" #find_binary_path("mkfs.vdfs")
+ runner.show("%s --help" % fullpathmkvdfs)
+# fs.mkvdfs(mountpoint, self._outdir+"/"+item['label']+fs_suffix, vdfsopts)
+ runner.show('%s %s -r %s %s' % (fullpathmkvdfs, vdfsopts, mountpoint, self._imgdir+"/"+item['label']+fs_suffix))
+
+ runner.show('umount %s' % mountpoint)
+# os.unlink(mountpoint)
+ runner.show('mv %s %s' % (self._imgdir+"/"+item['label']+fs_suffix, self._imgdir+"/"+item['label']+".img") )
+ runner.show('ls -al %s' % self._imgdir)
+
if item['fstype'] == "ext4":
runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s '
% imgfile)
self.part_type = kwargs.get("part_type", None)
self.uuid = kwargs.get("uuid", None)
self.exclude_image = kwargs.get("exclude_from_image", False)
+ self.vdfsopts = kwargs.get("vdfsopts", None)
+ self.squashfsopts = kwargs.get("squashfsopts", None)
def _getArgsAsStr(self):
retval = FC4_PartData._getArgsAsStr(self)
retval += " --uuid=%s" % self.uuid
if self.exclude_image:
retval += " --exclude-from-image"
+ if self.vdfsopts:
+ retval += " --vdfsoptions=%s" % self.vdfsopts
+ if self.squashfsopts:
+ retval += " --squashfsoptions=%s" % self.squashfsopts
return retval
op.add_option("--uuid", dest="uuid", action="store", type="string")
op.add_option("--exclude-from-image", action="store_true", dest="exclude_image",
default=False)
+ op.add_option("--vdfsoptions", type="string", action="store", dest="vdfsopts",
+ default=None)
+ op.add_option("--squashfsoptions", type="string", action="store", dest="squashfsopts",
+ default=None)
return op
if err.errno != errno.EEXIST:
raise
+def mkvdfs(in_img, out_img, fsoptions):
+ """ This function is incomplete. """
+ fullpathmkvdfs = find_binary_path("mkfs.vdfs")
+# args = fullpathmkvdfs + " -i -r "+ in_img + " -z 1024M -s " + out_img
+ args = fullpathmkvdfs + " " + fsoptions + " -r " + in_img + " " + out_img
+ msger.verbose("vdfs args: %s" % args)
+ runner.show("%s --help" % fullpathmkvdfs)
+# if not sys.stdout.isatty():
+# args.append("-no-progress")
+# runner.show("%s --help" % fullpathmkvdfs)
+ ret = runner.show(args)
+ if ret != 0:
+ runner.show ("vdfs error")
+ raise VdfsError("' %s' exited with error (%d)" % (args, ret))
+
def mksquashfs(in_img, out_img):
fullpathmksquashfs = find_binary_path("mksquashfs")
args = [fullpathmksquashfs, in_img, out_img]