diff options
author | Ming Liu <liu.ming50@gmail.com> | 2019-02-12 16:20:01 +0100 |
---|---|---|
committer | Patrick Vacek <patrickvacek@gmail.com> | 2019-04-29 09:16:27 +0200 |
commit | cf436b1582bf970bcebe901ecc791b9c6881d4c0 (patch) | |
tree | 328ff38fae5a59b2fa18852b4964a56a1d77596d | |
parent | f5c5ac3e444b765bfcd48b1a6d2b63ef7aec54aa (diff) | |
download | meta-updater-cf436b1582bf970bcebe901ecc791b9c6881d4c0.tar.gz |
wic:plugins:otaimage.py: fix a potential issue
do_image_wic task is a standalone task that depending on
do_image_ota_ext4, so it's possible that do_image_wic runs
(taskhash contaminated) but do_image_ota_ext4 does not (taskhash not
contaminated), in which case, the otaimage would be in DEPLOY_DIR_IMAGE
instead of in IMGDEPLOYDIR, so we need check both of them.
Also, the logger.error is not supposed to raise a error, it just
prints out a error message, so we should use WicError.
And another typo is it checks IMGDEPLOYDIR but reports DEPLOY_DIR_IMAGE
not exist, also fix that.
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
-rw-r--r-- | scripts/lib/wic/plugins/source/otaimage.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/scripts/lib/wic/plugins/source/otaimage.py b/scripts/lib/wic/plugins/source/otaimage.py index ee8088b..e7f3e75 100644 --- a/scripts/lib/wic/plugins/source/otaimage.py +++ b/scripts/lib/wic/plugins/source/otaimage.py | |||
@@ -19,6 +19,7 @@ import logging | |||
19 | import os | 19 | import os |
20 | import sys | 20 | import sys |
21 | 21 | ||
22 | from wic import WicError | ||
22 | from wic.plugins.source.rawcopy import RawCopyPlugin | 23 | from wic.plugins.source.rawcopy import RawCopyPlugin |
23 | from wic.misc import get_bitbake_var | 24 | from wic.misc import get_bitbake_var |
24 | 25 | ||
@@ -32,6 +33,18 @@ class OTAImagePlugin(RawCopyPlugin): | |||
32 | name = 'otaimage' | 33 | name = 'otaimage' |
33 | 34 | ||
34 | @classmethod | 35 | @classmethod |
36 | def _get_src_file(cls, image_dir_var): | ||
37 | """ | ||
38 | Get OTA image file from image directory variable. | ||
39 | """ | ||
40 | image_dir = get_bitbake_var(image_dir_var) | ||
41 | if not image_dir: | ||
42 | raise WicError("Couldn't find %s, exiting" % image_dir_var) | ||
43 | |||
44 | image_file = image_dir + "/" + get_bitbake_var("IMAGE_LINK_NAME") + ".otaimg" | ||
45 | return image_file if os.path.exists(image_file) else "" | ||
46 | |||
47 | @classmethod | ||
35 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | 48 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, |
36 | oe_builddir, bootimg_dir, kernel_dir, | 49 | oe_builddir, bootimg_dir, kernel_dir, |
37 | rootfs_dir, native_sysroot): | 50 | rootfs_dir, native_sysroot): |
@@ -39,13 +52,12 @@ class OTAImagePlugin(RawCopyPlugin): | |||
39 | Called to do the actual content population for a partition i.e. it | 52 | Called to do the actual content population for a partition i.e. it |
40 | 'prepares' the partition to be incorporated into the image. | 53 | 'prepares' the partition to be incorporated into the image. |
41 | """ | 54 | """ |
42 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
43 | if not bootimg_dir: | ||
44 | logger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | ||
45 | |||
46 | logger.debug('Bootimg dir: %s' % bootimg_dir) | ||
47 | 55 | ||
48 | src = bootimg_dir + "/" + get_bitbake_var("IMAGE_LINK_NAME") + ".otaimg" | 56 | src = cls._get_src_file("IMGDEPLOYDIR") |
57 | if not src: | ||
58 | src = cls._get_src_file("DEPLOY_DIR_IMAGE") | ||
59 | if not src: | ||
60 | raise WicError("Couldn't find ota image in IMGDEPLOYDIR or DEPLOY_DIR_IMAGE, exiting") | ||
49 | 61 | ||
50 | logger.debug('Preparing partition using image %s' % (src)) | 62 | logger.debug('Preparing partition using image %s' % (src)) |
51 | source_params['file'] = src | 63 | source_params['file'] = src |