Skip to contentSkip to conversation

wic: bootimg-partition: simplify BOOT_IMAGE_FILES logic

PATCH New Vivien Didelot 1 participant 2 messages Jan 30, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wic: bootimg-partition: simplify BOOT_IMAGE_FILES logic

bootimg-partition fills a partition for the files specified with the IMAGE_BOOT_FILES variable, optionally suffixed with _label-<label> or _uuid-<uuid>. Simplify the variables lookup to make this logic clearer to read.

---
 scripts/lib/wic/plugins/source/bootimg-partition.py | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
scripts/lib/wic/plugins/source/bootimg-partition.py +3 -7
index 5dbe2558d2..f22364766a 100644
@@ -48,13 +48,9 @@ class BootimgPartitionPlugin(SourcePlugin):
                 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
 
         boot_files = None
-        for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), (None, None)):
-            if fmt:
-                var = fmt % id
-            else:
-                var = ""
-
-            boot_files = get_bitbake_var("IMAGE_BOOT_FILES" + var)
+        vars = ("IMAGE_BOOT_FILES_uuid-%s" % part.uuid, "IMAGE_BOOT_FILES_label-%s" % part.label, "IMAGE_BOOT_FILES")
+        for var in vars:
+            boot_files = get_bitbake_var(var)
             if boot_files is not None:
                 break
 
Signature · 1 line
2.35.0
#1 lore raw

PATCH 2/2 wic: bootimg-partition: allow empty partition

It is possible to use the bootimg-partition source plugin to fill an optional boot partition, e.g. for data files or for kernel artifacts, in case they aren't embedded in the root filesystem. In these scenarios such partition may be empty, which is correct.

Instead of erroring out, just warn the user. While at it, make it clearer how to populate such partition, by mentioning the IMAGE_BOOT_FILES{,_uuid-<uuid>,_label-<label>} variables, as well as their presence in WICVARS, which isn't obvious for a new user.

---
 scripts/lib/wic/plugins/source/bootimg-partition.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/lib/wic/plugins/source/bootimg-partition.py +2 -1
index f22364766a..d7d9842b8c 100644
@@ -55,7 +55,8 @@ class BootimgPartitionPlugin(SourcePlugin):
                 break
 
         if boot_files is None:
-            raise WicError('No boot files defined, IMAGE_BOOT_FILES unset for entry #%d' % part.lineno)
+            logger.warn('No boot files defined for entry #%d, %s unset or not in WICVARS.' % (part.lineno, ', '.join(vars)))
+            return
 
         logger.debug('Boot files: %s', boot_files)
 
Signature · 1 line
2.35.0