]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: move checks to exec_native_cmd
authorEd Bartosh <ed.bartosh@linux.intel.com>
Fri, 5 Jun 2015 06:13:07 +0000 (09:13 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 11 Jun 2015 22:55:38 +0000 (23:55 +0100)
Checked for return code and output of native commands
inside exec_native_cmd.

Removed similar code from a lot of places where
exec_native_cmd is called.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/lib/wic/kickstart/custom_commands/partition.py
scripts/lib/wic/utils/oe/misc.py
scripts/lib/wic/utils/partitionedfs.py

index d9f77d9a28f59c3a5a071ff1f0366c16d5b7902c..5d033bb562553988ea6b5f33a40a0e792c5d1f68 100644 (file)
@@ -257,10 +257,7 @@ class Wic_PartData(Mic_PartData):
 
         mkfs_cmd = "mkfs.%s -F %s %s %s -d %s" % \
             (self.fstype, extra_imagecmd, rootfs, label_str, image_rootfs)
-        (rc, out) = exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
-        if rc:
-            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))
+        exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
 
         # get the rootfs size in the right units for kickstart (kB)
         du_cmd = "du -Lbks %s" % rootfs
@@ -307,9 +304,7 @@ class Wic_PartData(Mic_PartData):
 
         mkfs_cmd = "mkfs.%s -b %d -r %s %s %s" % \
             (self.fstype, rootfs_size * 1024, image_rootfs, label_str, rootfs)
-        (rc, out) = exec_native_cmd(pseudo + 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) when creating filesystem from rootfs directory: %s" % (self.fstype, rc, rootfs_dir))
+        exec_native_cmd(pseudo + mkfs_cmd, native_sysroot)
 
         # get the rootfs size in the right units for kickstart (kB)
         du_cmd = "du -Lbks %s" % rootfs
@@ -357,9 +352,7 @@ class Wic_PartData(Mic_PartData):
         exec_native_cmd(dosfs_cmd, native_sysroot)
 
         mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, image_rootfs)
-        rc, out = exec_native_cmd(mcopy_cmd, native_sysroot)
-        if rc:
-            msger.error("ERROR: mcopy returned '%s' instead of 0 (which you probably don't want to ignore, use --debug for details)" % rc)
+        exec_native_cmd(mcopy_cmd, native_sysroot)
 
         chmod_cmd = "chmod 644 %s" % rootfs
         exec_cmd(chmod_cmd)
@@ -432,9 +425,7 @@ class Wic_PartData(Mic_PartData):
 
         mkfs_cmd = "mkfs.%s -F %s %s %s" % \
             (self.fstype, extra_imagecmd, label_str, fs)
-        (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))
+        exec_native_cmd(mkfs_cmd, native_sysroot)
 
         self.source_file = fs
 
@@ -458,9 +449,7 @@ class Wic_PartData(Mic_PartData):
 
         mkfs_cmd = "mkfs.%s -b %d %s %s" % \
             (self.fstype, self.size * 1024, label_str, fs)
-        (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))
+        exec_native_cmd(mkfs_cmd, native_sysroot)
 
         self.source_file = fs
 
index 9eaf039f95e83143486f84035419f75a542d5f91..f08ff15a3461e3b2acc96dfe761c6557e3e4569e 100644 (file)
@@ -86,6 +86,12 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
         msger.error("A native program %s required to build the image "
                     "was not found (see details above). Please make sure "
                     "it's installed and try again." % args[0])
+    if out:
+        msger.debug('"%s" output: %s' % (args[0], out))
+
+    if rc != 0:
+        msger.error("exec_cmd: '%s' returned '%s' instead of 0" % \
+                    (cmd_and_args, rc))
 
     return (rc, out)
 
index eacf2679d2b23baa3949cbd09a3fbad4917e9e0e..8fd44a6a962dbbb1d648d9af9b3cd9e0d91c228b 100644 (file)
@@ -227,17 +227,7 @@ class Image:
         args = ' '.join(args)
         msger.debug(args)
 
-        rc, out = exec_native_cmd(args, self.native_sysroot)
-
-        if out:
-            msger.debug('"parted" output: %s' % out)
-
-        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.error("WARNING: parted returned '%s' instead of 0 (use --debug for details)" % rc)
+        exec_native_cmd(args, self.native_sysroot)
 
     def __create_partition(self, device, parttype, fstype, start, size):
         """ Create a partition on an image described by the 'device' object. """