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] wic: use native parted
Date: Mon,  6 Apr 2015 20:43:35 +0300	[thread overview]
Message-ID: <1428342215-7850-1-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <CAP9ODKprO_BWYjr4x0w2PXELXrZa6Y4C2=XgKMWXE+ppULZXTQ@mail.gmail.com>

Used exec_native_cmd instead of find_binary_path to run parted.
Got rid of find_binary_path as it's not used anywhere else.

There are several tools wic is trying to find not only in sysroot,
but also in host root. Parted is a special as on some distros it's
installed in /usr/sbin, which is not in the user's PATH. This makes
wic to fail with error "External command 'parted' not found, exiting."

[YOCTO #7122]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
 scripts/lib/wic/imager/direct.py       |  2 +-
 scripts/lib/wic/utils/fs_related.py    | 18 ------------------
 scripts/lib/wic/utils/partitionedfs.py | 11 ++++++-----
 3 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py
index d368401..c3d0563 100644
--- a/scripts/lib/wic/imager/direct.py
+++ b/scripts/lib/wic/imager/direct.py
@@ -242,7 +242,7 @@ class DirectImageCreator(BaseImageCreator):
         """
         parts = self._get_parts()
 
-        self.__image = Image()
+        self.__image = Image(self.native_sysroot)
 
         for p in parts:
             # as a convenience, set source to the boot partition source
diff --git a/scripts/lib/wic/utils/fs_related.py b/scripts/lib/wic/utils/fs_related.py
index ea9f85c..033acc9 100644
--- a/scripts/lib/wic/utils/fs_related.py
+++ b/scripts/lib/wic/utils/fs_related.py
@@ -31,24 +31,6 @@ from wic.utils import runner
 from wic.utils.errors import *
 from wic.utils.oe.misc import *
 
-def find_binary_path(binary):
-    if os.environ.has_key("PATH"):
-        paths = os.environ["PATH"].split(":")
-    else:
-        paths = []
-        if os.environ.has_key("HOME"):
-            paths += [os.environ["HOME"] + "/bin"]
-        paths += ["/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin"]
-
-    for path in paths:
-        bin_path = "%s/%s" % (path, binary)
-        if os.path.exists(bin_path):
-            return bin_path
-
-    print "External command '%s' not found, exiting." % binary
-    print "  (Please install '%s' on your host system)" % binary
-    sys.exit(1)
-
 def makedirs(dirname):
     """A version of os.makedirs() that doesn't throw an
     exception if the leaf directory already exists.
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py
index 162f8e1..1c10cb5 100644
--- a/scripts/lib/wic/utils/partitionedfs.py
+++ b/scripts/lib/wic/utils/partitionedfs.py
@@ -42,13 +42,13 @@ class Image:
     An Image is a container for a set of DiskImages and associated
     partitions.
     """
-    def __init__(self):
+    def __init__(self, native_sysroot=None):
         self.disks = {}
         self.partitions = []
-        self.parted = find_binary_path("parted")
         # Size of a sector used in calculations
         self.sector_size = SECTOR_SIZE
         self._partitions_layed_out = False
+        self.native_sysroot = native_sysroot
 
     def __add_disk(self, disk_name):
         """ Add a disk 'disk_name' to the internal list of disks. Note,
@@ -227,11 +227,12 @@ class Image:
     def __run_parted(self, args):
         """ Run parted with arguments specified in the 'args' list. """
 
-        args.insert(0, self.parted)
+        args.insert(0, "parted")
+        args = ' '.join(args)
         msger.debug(args)
 
-        rc, out = runner.runtool(args, catch = 3)
-        out = out.strip()
+        rc, out = exec_native_cmd(args, self.native_sysroot)
+
         if out:
             msger.debug('"parted" output: %s' % out)
 
-- 
2.1.4



  parent reply	other threads:[~2015-04-06 17:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-04 17:20 [wic][PATCH] wic: extended list of paths in find_binary_path Ed Bartosh
2015-04-04 18:34 ` Otavio Salvador
2015-04-04 21:34   ` Ed Bartosh
2015-04-05 19:13     ` Philip Balister
2015-04-06 17:43   ` Ed Bartosh [this message]
2015-04-06 18:20     ` [wic][PATCH] wic: use native parted Otavio Salvador
2015-04-05 19:16 ` [wic][PATCH] wic: extended list of paths in find_binary_path Philip Balister
2015-04-06 12:00   ` Otavio Salvador
2015-04-06 14:15     ` Ed Bartosh
2015-04-06 14:28       ` Otavio Salvador
2015-04-07 10:52         ` Ed Bartosh
2015-04-07 11:23           ` Otavio Salvador

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=1428342215-7850-1-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