Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [wic][PATCH 3/4] wic: replaced __run_parted with exec_native_cmd
Date: Fri,  5 Jun 2015 09:13:08 +0300	[thread overview]
Message-ID: <1433484789-304-4-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1433484789-304-1-git-send-email-ed.bartosh@linux.intel.com>

There is no need for yet another wrapper around exec_native_cmd.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>

diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 8fd44a6..dcb63e5 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -220,15 +220,6 @@ class Image:
 
             d['min_size'] *= self.sector_size
 
-    def __run_parted(self, args):
-        """ Run parted with arguments specified in the 'args' list. """
-
-        args.insert(0, "parted")
-        args = ' '.join(args)
-        msger.debug(args)
-
-        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. """
 
@@ -237,12 +228,12 @@ class Image:
         msger.debug("Added '%s' partition, sectors %d-%d, size %d sectors" %
                     (parttype, start, end, size))
 
-        args = ["-s", device, "unit", "s", "mkpart", parttype]
+        cmd = "parted -s %s unit s mkpart %s" % (device, parttype)
         if fstype:
-            args.extend([fstype])
-        args.extend(["%d" % start, "%d" % end])
+            cmd += " %s" % fstype
+        cmd += " %d %d" % (start, end)
 
-        return self.__run_parted(args)
+        return exec_native_cmd(cmd, self.native_sysroot)
 
     def __format_disks(self):
         self.layout_partitions()
@@ -251,8 +242,9 @@ class Image:
             d = self.disks[dev]
             msger.debug("Initializing partition table for %s" % \
                         (d['disk'].device))
-            self.__run_parted(["-s", d['disk'].device, "mklabel",
-                               d['ptable_format']])
+            exec_native_cmd("parted -s %s mklabel %s" % \
+                            (d['disk'].device, d['ptable_format']),
+                            self.native_sysroot)
 
         msger.debug("Creating partitions")
 
@@ -305,8 +297,9 @@ class Image:
                 flag_name = "legacy_boot" if d['ptable_format'] == 'gpt' else "boot"
                 msger.debug("Set '%s' flag for partition '%s' on disk '%s'" % \
                             (flag_name, p['num'], d['disk'].device))
-                self.__run_parted(["-s", d['disk'].device, "set",
-                                   "%d" % p['num'], flag_name, "on"])
+                exec_native_cmd("parted -s %s set %d %s on" % \
+                                (d['disk'].device, p['num'], flag_name),
+                                self.native_sysroot)
 
             # Parted defaults to enabling the lba flag for fat16 partitions,
             # which causes compatibility issues with some firmware (and really
@@ -315,8 +308,9 @@ class Image:
                 if d['ptable_format'] == 'msdos':
                     msger.debug("Disable 'lba' flag for partition '%s' on disk '%s'" % \
                                 (p['num'], d['disk'].device))
-                    self.__run_parted(["-s", d['disk'].device, "set",
-                                       "%d" % p['num'], "lba", "off"])
+                    exec_native_cmd("parted -s %s set %d lba off" % \
+                                    (d['disk'].device, p['num']),
+                                    self.native_sysroot)
 
     def cleanup(self):
         if self.disks:
-- 
2.1.4



  parent reply	other threads:[~2015-06-05  8:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-05  6:13 [wic][PATCH 0/4] Code cleanup and refactoring Ed Bartosh
2015-06-05  6:13 ` [wic][PATCH 1/4] wic: removed exec_cmd_quiet and exec_native_cmd_quiet Ed Bartosh
2015-06-05  6:13 ` [wic][PATCH 2/4] wic: move checks to exec_native_cmd Ed Bartosh
2015-06-05  6:13 ` Ed Bartosh [this message]
2015-06-05 16:33   ` [wic][PATCH 3/4] wic: replaced __run_parted with exec_native_cmd Ross Burton
2015-06-08  9:46     ` Ed Bartosh
2015-06-05  6:13 ` [wic][PATCH 4/4] wic: pylinted partitionedfs.py Ed Bartosh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433484789-304-4-git-send-email-ed.bartosh@linux.intel.com \
    --to=ed.bartosh@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox