summaryrefslogtreecommitdiffstats
path: root/yocto-poky/scripts/lib/wic/utils
diff options
context:
space:
mode:
Diffstat (limited to 'yocto-poky/scripts/lib/wic/utils')
-rw-r--r--yocto-poky/scripts/lib/wic/utils/misc.py37
-rw-r--r--yocto-poky/scripts/lib/wic/utils/oe/misc.py18
-rw-r--r--yocto-poky/scripts/lib/wic/utils/partitionedfs.py36
3 files changed, 65 insertions, 26 deletions
diff --git a/yocto-poky/scripts/lib/wic/utils/misc.py b/yocto-poky/scripts/lib/wic/utils/misc.py
index 9d750694d..1415ae906 100644
--- a/yocto-poky/scripts/lib/wic/utils/misc.py
+++ b/yocto-poky/scripts/lib/wic/utils/misc.py
@@ -17,6 +17,7 @@
import os
import time
+import wic.engine
def build_name(kscfg, release=None, prefix=None, suffix=None):
"""Construct and return an image name string.
@@ -56,3 +57,39 @@ def build_name(kscfg, release=None, prefix=None, suffix=None):
ret = prefix + name + suffix
return ret
+
+def find_canned(scripts_path, file_name):
+ """
+ Find a file either by its path or by name in the canned files dir.
+
+ Return None if not found
+ """
+ if os.path.exists(file_name):
+ return file_name
+
+ layers_canned_wks_dir = wic.engine.build_canned_image_list(scripts_path)
+ for canned_wks_dir in layers_canned_wks_dir:
+ for root, dirs, files in os.walk(canned_wks_dir):
+ for fname in files:
+ if fname == file_name:
+ fullpath = os.path.join(canned_wks_dir, fname)
+ return fullpath
+
+def get_custom_config(boot_file):
+ """
+ Get the custom configuration to be used for the bootloader.
+
+ Return None if the file can't be found.
+ """
+ scripts_path = os.path.abspath(os.path.dirname(__file__))
+ # Get the scripts path of poky
+ for x in range(0, 3):
+ scripts_path = os.path.dirname(scripts_path)
+
+ cfg_file = find_canned(scripts_path, boot_file)
+ if cfg_file:
+ with open(cfg_file, "r") as f:
+ config = f.read()
+ return config
+
+ return None
diff --git a/yocto-poky/scripts/lib/wic/utils/oe/misc.py b/yocto-poky/scripts/lib/wic/utils/oe/misc.py
index c6d2e5f20..81239ac35 100644
--- a/yocto-poky/scripts/lib/wic/utils/oe/misc.py
+++ b/yocto-poky/scripts/lib/wic/utils/oe/misc.py
@@ -89,7 +89,7 @@ def cmd_in_path(cmd, path):
return bb.utils.which(path, cmd) != "" or False
-def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
+def exec_native_cmd(cmd_and_args, native_sysroot, catch=3, pseudo=""):
"""
Execute native command, catching stderr, stdout
@@ -97,6 +97,12 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
Always need to execute native commands as_shell
"""
+ # The reason -1 is used is because there may be "export" commands.
+ args = cmd_and_args.split(';')[-1].split()
+ msger.debug(args)
+
+ if pseudo:
+ cmd_and_args = pseudo + cmd_and_args
native_paths = \
"%s/sbin:%s/usr/sbin:%s/usr/bin" % \
(native_sysroot, native_sysroot, native_sysroot)
@@ -104,18 +110,16 @@ def exec_native_cmd(cmd_and_args, native_sysroot, catch=3):
(native_paths, cmd_and_args)
msger.debug("exec_native_cmd: %s" % cmd_and_args)
- # The reason -1 is used is because there may be "export" commands.
- args = cmd_and_args.split(';')[-1].split()
- msger.debug(args)
-
# If the command isn't in the native sysroot say we failed.
if cmd_in_path(args[0], native_paths):
ret, out = _exec_cmd(native_cmd_and_args, True, catch)
else:
ret = 127
- if ret == 127: # shell command-not-found
- prog = args[0]
+ prog = args[0]
+ # shell command-not-found
+ if ret == 127 \
+ or (pseudo and ret == 1 and out == "Can't find '%s' in $PATH." % prog):
msg = "A native program %s required to build the image "\
"was not found (see details above).\n\n" % prog
recipe = NATIVE_RECIPES.get(prog)
diff --git a/yocto-poky/scripts/lib/wic/utils/partitionedfs.py b/yocto-poky/scripts/lib/wic/utils/partitionedfs.py
index 5a103bbc7..ad596d26f 100644
--- a/yocto-poky/scripts/lib/wic/utils/partitionedfs.py
+++ b/yocto-poky/scripts/lib/wic/utils/partitionedfs.py
@@ -96,25 +96,23 @@ class Image(object):
# Converting kB to sectors for parted
size = size * 1024 / self.sector_size
- # We still need partition for "/" or non-subvolume
- if mountpoint == "/" or not fsopts:
- part = {'ks_pnum': ks_pnum, # Partition number in the KS file
- 'size': size, # In sectors
- 'mountpoint': mountpoint, # Mount relative to chroot
- 'source_file': source_file, # partition contents
- 'fstype': fstype, # Filesystem type
- 'fsopts': fsopts, # Filesystem mount options
- 'label': label, # Partition label
- 'disk_name': disk_name, # physical disk name holding partition
- 'device': None, # kpartx device node for partition
- 'num': None, # Partition number
- 'boot': boot, # Bootable flag
- 'align': align, # Partition alignment
- 'no_table' : no_table, # Partition does not appear in partition table
- 'part_type' : part_type, # Partition type
- 'uuid': uuid} # Partition UUID
-
- self.__add_partition(part)
+ part = {'ks_pnum': ks_pnum, # Partition number in the KS file
+ 'size': size, # In sectors
+ 'mountpoint': mountpoint, # Mount relative to chroot
+ 'source_file': source_file, # partition contents
+ 'fstype': fstype, # Filesystem type
+ 'fsopts': fsopts, # Filesystem mount options
+ 'label': label, # Partition label
+ 'disk_name': disk_name, # physical disk name holding partition
+ 'device': None, # kpartx device node for partition
+ 'num': None, # Partition number
+ 'boot': boot, # Bootable flag
+ 'align': align, # Partition alignment
+ 'no_table' : no_table, # Partition does not appear in partition table
+ 'part_type' : part_type, # Partition type
+ 'uuid': uuid} # Partition UUID
+
+ self.__add_partition(part)
def layout_partitions(self, ptable_format="msdos"):
""" Layout the partitions, meaning calculate the position of every
OpenPOWER on IntegriCloud