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.
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,
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)