summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/utils
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-01-19 18:51:07 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-20 17:07:13 +0000
commit15ea18041419fe239b64b388e429020153bb28ed (patch)
tree8ba0e39a1e4d65f3623857fecb129bb60a2e5446 /scripts/lib/wic/utils
parentd304162269ccc93767439b3e80b57f6d33f8d9bc (diff)
downloadpoky-15ea18041419fe239b64b388e429020153bb28ed.tar.gz
wic: refactor get_boot_config
This function is going to be used by ks parser to find include .wks files. get_boot_config name is a bit confusing as function is quite generic. It looks if file is present in the canned wks directories. Renamed get_boot_config -> get_canned. Renamed parameter file_boot -> file_name. Updated description. (From OE-Core rev: 8ea9a4c0422c9600cd33ec6e815ebcf2d0aad364) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/utils')
-rw-r--r--scripts/lib/wic/utils/misc.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/scripts/lib/wic/utils/misc.py b/scripts/lib/wic/utils/misc.py
index d886d75b95..1415ae906c 100644
--- a/scripts/lib/wic/utils/misc.py
+++ b/scripts/lib/wic/utils/misc.py
@@ -58,25 +58,23 @@ def build_name(kscfg, release=None, prefix=None, suffix=None):
58 58
59 return ret 59 return ret
60 60
61def find_boot_config(scripts_path, boot_file): 61def find_canned(scripts_path, file_name):
62 """ 62 """
63 Find a config file with the given name in the canned files dir. 63 Find a file either by its path or by name in the canned files dir.
64 64
65 Return False if not found 65 Return None if not found
66 """ 66 """
67 if os.path.exists(boot_file): 67 if os.path.exists(file_name):
68 return boot_file 68 return file_name
69 69
70 layers_canned_wks_dir = wic.engine.build_canned_image_list(scripts_path) 70 layers_canned_wks_dir = wic.engine.build_canned_image_list(scripts_path)
71 for canned_wks_dir in layers_canned_wks_dir: 71 for canned_wks_dir in layers_canned_wks_dir:
72 for root, dirs, files in os.walk(canned_wks_dir): 72 for root, dirs, files in os.walk(canned_wks_dir):
73 for fname in files: 73 for fname in files:
74 if fname == boot_file: 74 if fname == file_name:
75 fullpath = os.path.join(canned_wks_dir, fname) 75 fullpath = os.path.join(canned_wks_dir, fname)
76 return fullpath 76 return fullpath
77 77
78 return None
79
80def get_custom_config(boot_file): 78def get_custom_config(boot_file):
81 """ 79 """
82 Get the custom configuration to be used for the bootloader. 80 Get the custom configuration to be used for the bootloader.
@@ -88,7 +86,7 @@ def get_custom_config(boot_file):
88 for x in range(0, 3): 86 for x in range(0, 3):
89 scripts_path = os.path.dirname(scripts_path) 87 scripts_path = os.path.dirname(scripts_path)
90 88
91 cfg_file = find_boot_config(scripts_path, boot_file) 89 cfg_file = find_canned(scripts_path, boot_file)
92 if cfg_file: 90 if cfg_file:
93 with open(cfg_file, "r") as f: 91 with open(cfg_file, "r") as f:
94 config = f.read() 92 config = f.read()