diff mbox series

[2/2] image_types_wic: fix dependencies on wks files

Message ID 20250520075325.64756-3-fhoerni.opensource@witekio.com
State New
Headers show
Series image_types_wic: fix dependencies on wks files | expand

Commit Message

fhoerni.opensource@witekio.com May 20, 2025, 7:53 a.m. UTC
From: Frederic Hoerni <fhoerni@witekio.com>

Add dependencies on all eligible files in WKS_SEARCH_PATH.

Before this patch, adding a wks file earlier in the search path
was not taken into account automatically.

To reproduce the issue:

1. Init (use default WKS_FILE="qemux86-directdisk.wks")

    . oe-init-build-env
    echo 'IMAGE_FSTYPES += "wic"' >> conf/local.conf

2. First clean build

    rm -f wic/qemux86-directdisk.wks
    bitbake core-image-minimal -c cleansstate && bitbake core-image-minimal

3. Create an override for WKS_FILE (earlier in WKS_SEARCH_PATH)
and introduce an error (a very small partition size) so that we can see it happen (or not).

    mkdir -p wic
    echo "part / --source rootfs --fstype=ext4 --fixed-size 1M" > wic/qemux86-directdisk.wks

4. Build again

    bitbake core-image-minimal
    ...
    NOTE: Tasks Summary: Attempted 4670 tasks of which 4670 didn't need to be rerun and all succeeded.

=> Nothing gets built, whereas we should see this error:
| ERROR: Actual rootfs size (28713 kB) is larger than allowed size 1024 kB

Signed-off-by: Frederic Hoerni <fhoerni@witekio.com>
---
 meta/classes-recipe/image_types_wic.bbclass | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/image_types_wic.bbclass b/meta/classes-recipe/image_types_wic.bbclass
index 61f028bd7b..33773db2e5 100644
--- a/meta/classes-recipe/image_types_wic.bbclass
+++ b/meta/classes-recipe/image_types_wic.bbclass
@@ -45,17 +45,11 @@  inherit_defer ${@bb.utils.contains('INITRAMFS_IMAGE_BUNDLE', '1', 'kernel-artifa
 WKS_FILE ??= "${IMAGE_BASENAME}.${MACHINE}.wks"
 WKS_FILES ?= "${WKS_FILE} ${IMAGE_BASENAME}.wks"
 WKS_SEARCH_PATH ?= "${THISDIR}:${@':'.join('%s/wic' % p for p in '${BBPATH}'.split(':'))}:${@':'.join('%s/scripts/lib/wic/canned-wks' % l for l in '${BBPATH}:${COREBASE}'.split(':'))}"
-WKS_FULL_PATH = "${@wks_search(d.getVar('WKS_FILES').split(), d.getVar('WKS_SEARCH_PATH')) or ''}"
+WKS_FULL_PATH = "${@wks_search(d.getVar('WKS_FILES').split(), d.getVar('WKS_SEARCH_PATH'), d) or ''}"
 
-def wks_search(files, search_path):
-    for f in files:
-        if os.path.isabs(f):
-            if os.path.exists(f):
-                return f
-        else:
-            searched = bb.utils.which(search_path, f)
-            if searched:
-                return searched
+def wks_search(files, search_path, d):
+    from oe.searchfile import search_file
+    return search_file(search_path, files, d)
 
 WIC_CREATE_EXTRA_ARGS ?= ""
 
@@ -160,10 +154,6 @@  python () {
             d.setVar('WKS_TEMPLATE_PATH', wks_file_u)
             d.setVar('WKS_FILE_CHECKSUM', '${WKS_TEMPLATE_PATH}:True')
 
-            # We need to re-parse each time the file changes, and bitbake
-            # needs to be told about that explicitly.
-            bb.parse.mark_dependency(d, wks_file)
-
             try:
                 with open(wks_file, 'r') as f:
                     body = f.read()