diff options
| -rw-r--r-- | meta/classes/image.bbclass | 30 | ||||
| -rw-r--r-- | meta/lib/oe/utils.py | 13 |
2 files changed, 43 insertions, 0 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index 30dfd64828..af789f4588 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass | |||
| @@ -275,6 +275,36 @@ do_image_complete[dirs] = "${TOPDIR}" | |||
| 275 | do_image_complete[umask] = "022" | 275 | do_image_complete[umask] = "022" |
| 276 | addtask do_image_complete after do_image before do_build | 276 | addtask do_image_complete after do_image before do_build |
| 277 | 277 | ||
| 278 | # Add image-level QA/sanity checks to IMAGE_QA_COMMANDS | ||
| 279 | # | ||
| 280 | # IMAGE_QA_COMMANDS += " \ | ||
| 281 | # image_check_everything_ok \ | ||
| 282 | # " | ||
| 283 | # This task runs all functions in IMAGE_QA_COMMANDS after the image | ||
| 284 | # construction has completed in order to validate the resulting image. | ||
| 285 | fakeroot python do_image_qa () { | ||
| 286 | from oe.utils import ImageQAFailed | ||
| 287 | |||
| 288 | qa_cmds = (d.getVar('IMAGE_QA_COMMANDS', True) or '').split() | ||
| 289 | qamsg = "" | ||
| 290 | |||
| 291 | for cmd in qa_cmds: | ||
| 292 | try: | ||
| 293 | bb.build.exec_func(cmd, d) | ||
| 294 | except oe.utils.ImageQAFailed as e: | ||
| 295 | qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description) | ||
| 296 | except bb.build.FuncFailed as e: | ||
| 297 | qamsg = qamsg + '\tImage QA function %s failed' % e.name | ||
| 298 | if e.logfile: | ||
| 299 | qamsg = qamsg + ' (log file is located at %s)' % e.logfile | ||
| 300 | qamsg = qamsg + '\n' | ||
| 301 | |||
| 302 | if qamsg: | ||
| 303 | imgname = d.getVar('IMAGE_NAME', True) | ||
| 304 | bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg)) | ||
| 305 | } | ||
| 306 | addtask do_image_qa after do_image_complete before do_build | ||
| 307 | |||
| 278 | # | 308 | # |
| 279 | # Write environment variables used by wic | 309 | # Write environment variables used by wic |
| 280 | # to tmp/sysroots/<machine>/imgdata/<image>.env | 310 | # to tmp/sysroots/<machine>/imgdata/<image>.env |
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py index cecddc657f..19db540779 100644 --- a/meta/lib/oe/utils.py +++ b/meta/lib/oe/utils.py | |||
| @@ -304,3 +304,16 @@ def write_ld_so_conf(d): | |||
| 304 | with open(ldsoconf, "w") as f: | 304 | with open(ldsoconf, "w") as f: |
| 305 | f.write(d.getVar("base_libdir", True) + '\n') | 305 | f.write(d.getVar("base_libdir", True) + '\n') |
| 306 | f.write(d.getVar("libdir", True) + '\n') | 306 | f.write(d.getVar("libdir", True) + '\n') |
| 307 | |||
| 308 | class ImageQAFailed(bb.build.FuncFailed): | ||
| 309 | def __init__(self, description, name=None, logfile=None): | ||
| 310 | self.description = description | ||
| 311 | self.name = name | ||
| 312 | self.logfile=logfile | ||
| 313 | |||
| 314 | def __str__(self): | ||
| 315 | msg = 'Function failed: %s' % self.name | ||
| 316 | if self.description: | ||
| 317 | msg = msg + ' (%s)' % self.description | ||
| 318 | |||
| 319 | return msg | ||
