"""
rootfs = oe_builddir
du_cmd = "du -Lbms %s" % rootfs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
self.size = rootfs_size
rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label ,self.fstype)
du_cmd = "du -ks %s" % image_rootfs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
actual_rootfs_size = int(out.split()[0])
extra_blocks = self.get_extra_block_count(actual_rootfs_size)
dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
(rootfs, rootfs_size)
- rc, out = exec_cmd(dd_cmd)
+ exec_cmd(dd_cmd)
extra_imagecmd = "-i 8192"
mkfs_cmd = "mkfs.%s -F %s %s -d %s" % \
(self.fstype, extra_imagecmd, rootfs, image_rootfs)
- rc, out = exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
+ exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
# get the rootfs size in the right units for kickstart (Mb)
du_cmd = "du -Lbms %s" % rootfs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
self.size = rootfs_size
rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
du_cmd = "du -ks %s" % image_rootfs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
actual_rootfs_size = int(out.split()[0])
extra_blocks = self.get_extra_block_count(actual_rootfs_size)
dd_cmd = "dd if=/dev/zero of=%s bs=1024 seek=%d count=0 bs=1k" % \
(rootfs, rootfs_size)
- rc, out = exec_cmd(dd_cmd)
+ exec_cmd(dd_cmd)
mkfs_cmd = "mkfs.%s -b %d -r %s %s" % \
(self.fstype, rootfs_size * 1024, image_rootfs, rootfs)
- rc, out = exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
+ exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
# get the rootfs size in the right units for kickstart (Mb)
du_cmd = "du -Lbms %s" % rootfs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
self.size = rootfs_size
rootfs = "%s/rootfs_%s.%s" % (cr_workdir, self.label, self.fstype)
du_cmd = "du -bks %s" % image_rootfs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
blocks = int(out.split()[0])
extra_blocks = self.get_extra_block_count(blocks)
# get the rootfs size in the right units for kickstart (Mb)
du_cmd = "du -Lbms %s" % rootfs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
self.set_size(rootfs_size)
squashfs_cmd = "mksquashfs %s %s -noappend" % \
(image_rootfs, rootfs)
- rc, out = exec_native_cmd(pseudo + squashfs_cmd, native_sysroot)
+ 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
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
rootfs_size = out.split()[0]
self.size = rootfs_size
dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
(fs, self.size)
- rc, out = exec_cmd(dd_cmd)
+ exec_cmd(dd_cmd)
extra_imagecmd = "-i 8192"
mkfs_cmd = "mkfs.%s -F %s %s" % (self.fstype, extra_imagecmd, fs)
- rc, out = exec_native_cmd(mkfs_cmd, native_sysroot)
+ exec_native_cmd(mkfs_cmd, native_sysroot)
self.source_file = fs
dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
(fs, self.size)
- rc, out = exec_cmd(dd_cmd)
+ exec_cmd(dd_cmd)
mkfs_cmd = "mkfs.%s -b %d %s" % (self.fstype, self.size * 1024, rootfs)
- rc, out = exec_native_cmd(mkfs_cmd, native_sysroot)
+ exec_native_cmd(mkfs_cmd, native_sysroot)
mkfs_cmd = "mkfs.%s -F %s %s" % (self.fstype, extra_imagecmd, fs)
- rc, out = exec_native_cmd(mkfs_cmd, native_sysroot)
+ exec_native_cmd(mkfs_cmd, native_sysroot)
self.source_file = fs
squashfs_cmd = "mksquashfs %s %s -noappend" % \
(tmpdir, fs)
- rc, out = exec_native_cmd(squashfs_cmd, native_sysroot)
+ exec_native_cmd(squashfs_cmd, native_sysroot)
os.rmdir(tmpdir)
# get the rootfs size in the right units for kickstart (Mb)
du_cmd = "du -Lbms %s" % fs
- rc, out = exec_cmd(du_cmd)
+ out = exec_cmd(du_cmd)
fs_size = out.split()[0]
self.size = fs_size
dd_cmd = "dd if=/dev/zero of=%s bs=1M seek=%d count=0" % \
(fs, self.size)
- rc, out = exec_cmd(dd_cmd)
+ exec_cmd(dd_cmd)
import uuid
label_str = ""
if self.label:
label_str = "-L %s" % self.label
mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), fs)
- rc, out = exec_native_cmd(mkswap_cmd, native_sysroot)
+ exec_native_cmd(mkswap_cmd, native_sysroot)
self.source_file = fs
from mic import msger
from mic.utils import runner
-def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
+def __exec_cmd(cmd_and_args, as_shell = False, catch = 3):
"""
Execute command, catching stderr, stdout
Need to execute as_shell if the command uses wildcards
"""
- msger.debug("exec_cmd: %s" % cmd_and_args)
+ msger.debug("__exec_cmd: %s" % cmd_and_args)
args = cmd_and_args.split()
msger.debug(args)
else:
rc, out = runner.runtool(args, catch)
out = out.strip()
- msger.debug("exec_cmd: output for %s (rc = %d): %s" % \
- (cmd_and_args, rc, out))
+ msger.debug("__exec_cmd: output for %s (rc = %d): %s" % \
+ (cmd_and_args, rc, out))
+
+ return (rc, out)
+
+
+def exec_cmd(cmd_and_args, as_shell = False, catch = 3):
+ """
+ Execute command, catching stderr, stdout
+
+ Exits if rc non-zero
+ """
+ rc, out = __exec_cmd(cmd_and_args, as_shell, catch)
if rc != 0:
- # We don't throw exception when return code is not 0, because
- # parted always fails to reload part table with loop devices. This
- # prevents us from distinguishing real errors based on return
- # code.
- msger.warning("WARNING: %s returned '%s' instead of 0" % (cmd_and_args, rc))
+ msger.error("exec_cmd: %s returned '%s' instead of 0" % (cmd_and_args, rc))
- return (rc, out)
+ return out
def exec_cmd_quiet(cmd_and_args, as_shell = False):
"""
Execute command, catching nothing in the output
- Need to execute as_shell if the command uses wildcards
+ Exits if rc non-zero
"""
return exec_cmd(cmd_and_args, as_shell, 0)
args = cmd_and_args.split()
msger.debug(args)
- rc, out = exec_cmd(native_cmd_and_args, True, catch)
+ rc, out = __exec_cmd(native_cmd_and_args, True, catch)
if rc == 127: # shell command-not-found
msger.error("A native (host) program required to build the image "
bitbake_env_cmd = "bitbake -e %s" % image_name
else:
bitbake_env_cmd = "bitbake -e"
- rc, bitbake_env_lines = exec_cmd(bitbake_env_cmd)
+ rc, bitbake_env_lines = __exec_cmd(bitbake_env_cmd)
if rc != 0:
print "Couldn't get '%s' output." % bitbake_env_cmd
return None