summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Henrique Ferreira de Freitas <joaohf@gmail.com>2014-05-14 22:37:27 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-05-21 09:09:02 +0100
commit8af57a6ca269203b79aacfa3048dc177df2cf6ac (patch)
treea53f926b7cf65529c3792335a133179246b708e6
parentac9707c501f5cd9e390854dc40589a9e755ffbd2 (diff)
downloadpoky-8af57a6ca269203b79aacfa3048dc177df2cf6ac.tar.gz
wic: add support to look in all layers and get .wks file
.wks file are looked in 'scripts/lib/image/canned-wks' directory on all BBLAYERS variable returned by bitbake environment. If found, it will be used. The user could create your own .wks and keep it inside its layers. For now the path must be <layer-dir>/scripts/lib/image/canned-wks. (From OE-Core rev: 1f3e312211f277a1befd707a59a0c0a9bf6cbcbc) Signed-off-by: João Henrique Ferreira de Freitas <joaohf@gmail.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/image/engine.py72
-rwxr-xr-xscripts/wic6
2 files changed, 49 insertions, 29 deletions
diff --git a/scripts/lib/image/engine.py b/scripts/lib/image/engine.py
index 311737a5c0..3bda1bf205 100644
--- a/scripts/lib/image/engine.py
+++ b/scripts/lib/image/engine.py
@@ -90,6 +90,20 @@ def find_artifacts(image_name):
90 90
91 91
92CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts 92CANNED_IMAGE_DIR = "lib/image/canned-wks" # relative to scripts
93SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR
94
95def build_canned_image_list(dl):
96 layers_path = get_bitbake_var("BBLAYERS")
97 canned_wks_layer_dirs = []
98
99 for layer_path in layers_path.split():
100 path = os.path.join(layer_path, SCRIPTS_CANNED_IMAGE_DIR)
101 canned_wks_layer_dirs.append(path)
102
103 path = os.path.join(dl, CANNED_IMAGE_DIR)
104 canned_wks_layer_dirs.append(path)
105
106 return canned_wks_layer_dirs
93 107
94def find_canned_image(scripts_path, wks_file): 108def find_canned_image(scripts_path, wks_file):
95 """ 109 """
@@ -97,15 +111,16 @@ def find_canned_image(scripts_path, wks_file):
97 111
98 Return False if not found 112 Return False if not found
99 """ 113 """
100 canned_wks_dir = os.path.join(scripts_path, CANNED_IMAGE_DIR) 114 layers_canned_wks_dir = build_canned_image_list(scripts_path)
101 115
102 for root, dirs, files in os.walk(canned_wks_dir): 116 for canned_wks_dir in layers_canned_wks_dir:
103 for file in files: 117 for root, dirs, files in os.walk(canned_wks_dir):
104 if file.endswith("~") or file.endswith("#"): 118 for file in files:
105 continue 119 if file.endswith("~") or file.endswith("#"):
106 if file.endswith(".wks") and wks_file + ".wks" == file: 120 continue
107 fullpath = os.path.join(canned_wks_dir, file) 121 if file.endswith(".wks") and wks_file + ".wks" == file:
108 return fullpath 122 fullpath = os.path.join(canned_wks_dir, file)
123 return fullpath
109 return None 124 return None
110 125
111 126
@@ -113,32 +128,31 @@ def list_canned_images(scripts_path):
113 """ 128 """
114 List the .wks files in the canned image dir, minus the extension. 129 List the .wks files in the canned image dir, minus the extension.
115 """ 130 """
116 canned_wks_dir = os.path.join(scripts_path, CANNED_IMAGE_DIR) 131 layers_canned_wks_dir = build_canned_image_list(scripts_path)
117 132
118 for root, dirs, files in os.walk(canned_wks_dir): 133 for canned_wks_dir in layers_canned_wks_dir:
119 for file in files: 134 for root, dirs, files in os.walk(canned_wks_dir):
120 if file.endswith("~") or file.endswith("#"): 135 for file in files:
121 continue 136 if file.endswith("~") or file.endswith("#"):
122 if file.endswith(".wks"): 137 continue
123 fullpath = os.path.join(canned_wks_dir, file) 138 if file.endswith(".wks"):
124 f = open(fullpath, "r") 139 fullpath = os.path.join(canned_wks_dir, file)
125 lines = f.readlines() 140 f = open(fullpath, "r")
126 for line in lines: 141 lines = f.readlines()
127 desc = "" 142 for line in lines:
128 idx = line.find("short-description:") 143 desc = ""
129 if idx != -1: 144 idx = line.find("short-description:")
130 desc = line[idx + len("short-description:"):].strip() 145 if idx != -1:
131 break 146 desc = line[idx + len("short-description:"):].strip()
132 basename = os.path.splitext(file)[0] 147 break
133 print " %s\t\t%s" % (basename, desc) 148 basename = os.path.splitext(file)[0]
149 print " %s\t\t%s" % (basename.ljust(30), desc)
134 150
135 151
136def list_canned_image_help(scripts_path, fullpath): 152def list_canned_image_help(scripts_path, fullpath):
137 """ 153 """
138 List the help and params in the specified canned image. 154 List the help and params in the specified canned image.
139 """ 155 """
140 canned_wks_dir = os.path.join(scripts_path, CANNED_IMAGE_DIR)
141
142 f = open(fullpath, "r") 156 f = open(fullpath, "r")
143 lines = f.readlines() 157 lines = f.readlines()
144 found = False 158 found = False
diff --git a/scripts/wic b/scripts/wic
index 442334030f..2d3fd09d71 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -214,6 +214,12 @@ def wic_list_subcommand(args, usage_str):
214 214
215 (options, args) = parser.parse_args(args) 215 (options, args) = parser.parse_args(args)
216 216
217 bitbake_env_lines = find_bitbake_env_lines(None)
218 if not bitbake_env_lines:
219 print "Couldn't get bitbake environment, exiting."
220 sys.exit(1)
221 set_bitbake_env_lines(bitbake_env_lines)
222
217 if not wic_list(args, scripts_path, options.properties_file): 223 if not wic_list(args, scripts_path, options.properties_file):
218 logging.error("Bad list arguments, exiting\n") 224 logging.error("Bad list arguments, exiting\n")
219 parser.print_help() 225 parser.print_help()