summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/image_types.bbclass46
1 files changed, 46 insertions, 0 deletions
diff --git a/meta/classes/image_types.bbclass b/meta/classes/image_types.bbclass
index f7de756b71..2b97397a51 100644
--- a/meta/classes/image_types.bbclass
+++ b/meta/classes/image_types.bbclass
@@ -218,6 +218,52 @@ USING_WIC = "${@bb.utils.contains_any('IMAGE_FSTYPES', 'wic ' + ' '.join('wic.%s
218WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}" 218WKS_FILE_CHECKSUM = "${@'${WKS_FULL_PATH}:%s' % os.path.exists('${WKS_FULL_PATH}') if '${USING_WIC}' else ''}"
219do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}" 219do_image_wic[file-checksums] += "${WKS_FILE_CHECKSUM}"
220 220
221python do_write_wks_template () {
222 """Write out expanded template contents to WKS_FULL_PATH."""
223 import re
224
225 template_body = d.getVar('_WKS_TEMPLATE', True)
226
227 # Remove any remnant variable references left behind by the expansion
228 # due to undefined variables
229 expand_var_regexp = re.compile(r"\${[^{}@\n\t :]+}")
230 while True:
231 new_body = re.sub(expand_var_regexp, '', template_body)
232 if new_body == template_body:
233 break
234 else:
235 template_body = new_body
236
237 wks_file = d.getVar('WKS_FULL_PATH', True)
238 with open(wks_file, 'w') as f:
239 f.write(template_body)
240}
241
242python () {
243 if d.getVar('USING_WIC', True):
244 wks_file_u = d.getVar('WKS_FULL_PATH', False)
245 wks_file = d.expand(wks_file_u)
246 base, ext = os.path.splitext(wks_file)
247 if ext == '.in' and os.path.exists(wks_file):
248 wks_out_file = os.path.join(d.getVar('WORKDIR', True), os.path.basename(base))
249 d.setVar('WKS_FULL_PATH', wks_out_file)
250 d.setVar('WKS_TEMPLATE_PATH', wks_file_u)
251 d.setVar('WKS_FILE_CHECKSUM', '${WKS_TEMPLATE_PATH}:True')
252
253 try:
254 with open(wks_file, 'r') as f:
255 body = f.read()
256 except (IOError, OSError) as exc:
257 pass
258 else:
259 # Previously, I used expandWithRefs to get the dependency list
260 # and add it to WICVARS, but there's no point re-parsing the
261 # file in process_wks_template as well, so just put it in
262 # a variable and let the metadata deal with the deps.
263 d.setVar('_WKS_TEMPLATE', body)
264 bb.build.addtask('do_write_wks_template', 'do_image_wic', None, d)
265}
266
221EXTRA_IMAGECMD = "" 267EXTRA_IMAGECMD = ""
222 268
223inherit siteinfo 269inherit siteinfo