if self.recommended:
retval += " --recommended"
if self.size and self.size != 0:
- retval += " --size=%s" % self.size
+ retval += " --size=%sk" % self.size
if hasattr(self, "start") and self.start != 0:
retval += " --start=%s" % self.start
callback=part_cb, nargs=1, type="string")
op.add_option("--recommended", dest="recommended", action="store_true",
default=False)
- op.add_option("--size", dest="size", action="store", type="int",
+ op.add_option("--size", dest="size", action="store", type="size",
nargs=1)
op.add_option("--start", dest="start", action="store", type="int",
nargs=1)
else:
return value
+def _check_size(option, opt, value):
+ # Former default was MB
+ if (value.isdigit()):
+ return int(value) * 1024L
+
+ mapping = {"opt": opt, "value": value}
+ if (not value[:-1].isdigit()):
+ raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping)
+
+ size = int(value[:-1])
+ if (value.endswith("k") or value.endswith("K")):
+ return size
+ if (value.endswith("M")):
+ return size * 1024L
+ if (value.endswith("G")):
+ return size * 1024L * 1024L
+ raise OptionValueError(_("Option %(opt)s: invalid size value: %(value)r") % mapping)
+
# Creates a new Option class that supports several new attributes:
# - required: any option with this attribute must be supplied or an exception
# is thrown
ACTIONS = Option.ACTIONS + ("map", "map_extend",)
STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",)
- TYPES = Option.TYPES + ("ksboolean", "string")
+ TYPES = Option.TYPES + ("ksboolean", "string", "size")
TYPE_CHECKER = copy(Option.TYPE_CHECKER)
TYPE_CHECKER["ksboolean"] = _check_ksboolean
TYPE_CHECKER["string"] = _check_string
+ TYPE_CHECKER["size"] = _check_size
def _check_required(self):
if self.required and not self.takes_value():
def get_extra_block_count(self, current_blocks):
"""
- The --size param is reflected in self.size (in MB), and we already
+ The --size param is reflected in self.size (in kB), and we already
have current_blocks (1k) blocks, calculate and return the
number of (1k) blocks we need to add to get to --size, 0 if
we're already there or beyond.
if not self.size:
return 0
- requested_blocks = self.size * 1024
+ requested_blocks = self.size
msger.debug("Requested blocks %d, current_blocks %d" % \
(requested_blocks, current_blocks))
Handle an already-created partition e.g. xxx.ext3
"""
rootfs = oe_builddir
- du_cmd = "du -Lbms %s" % rootfs
+ du_cmd = "du -Lbks %s" % rootfs
out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
print "rootfs_dir: %s" % rootfs_dir
msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir))
- # get the rootfs size in the right units for kickstart (Mb)
- du_cmd = "du -Lbms %s" % rootfs
+ # get the rootfs size in the right units for kickstart (kB)
+ du_cmd = "du -Lbks %s" % rootfs
out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
if rc:
msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir))
- # get the rootfs size in the right units for kickstart (Mb)
- du_cmd = "du -Lbms %s" % rootfs
+ # get the rootfs size in the right units for kickstart (kB)
+ du_cmd = "du -Lbks %s" % rootfs
out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
chmod_cmd = "chmod 644 %s" % rootfs
exec_cmd(chmod_cmd)
- # get the rootfs size in the right units for kickstart (Mb)
- du_cmd = "du -Lbms %s" % rootfs
+ # get the rootfs size in the right units for kickstart (kB)
+ du_cmd = "du -Lbks %s" % rootfs
out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
(image_rootfs, rootfs)
exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
- # get the rootfs size in the right units for kickstart (Mb)
- du_cmd = "du -Lbms %s" % rootfs
+ # get the rootfs size in the right units for kickstart (kB)
+ du_cmd = "du -Lbks %s" % rootfs
out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
"""
fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
- dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
+ dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \
(fs, self.size)
exec_cmd(dd_cmd)
"""
fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
- dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
+ dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \
(fs, self.size)
exec_cmd(dd_cmd)
- mkfs_cmd = "mkfs.%s -b %d %s" % (self.fstype, self.size * 1024, rootfs)
+ mkfs_cmd = "mkfs.%s -b %d %s" % (self.fstype, self.size, rootfs)
(rc, out) = exec_native_cmd(mkfs_cmd, native_sysroot)
if rc:
msger.error("ERROR: mkfs.%s returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % (self.fstype, rc))
"""
fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype)
- blocks = self.size * 1024
+ blocks = self.size
dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (fs, blocks)
exec_native_cmd(dosfs_cmd, native_sysroot)
os.rmdir(tmpdir)
- # get the rootfs size in the right units for kickstart (Mb)
- du_cmd = "du -Lbms %s" % fs
+ # get the rootfs size in the right units for kickstart (kB)
+ du_cmd = "du -Lbks %s" % fs
out = exec_cmd(du_cmd)
fs_size = out.split()[0]
"""
fs = "%s/fs.%s" % (cr_workdir, self.fstype)
- dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
+ dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \
(fs, self.size)
exec_cmd(dd_cmd)