feat(coreos-image-swupdate.bbclass): add a way to dynamically extends the

sw-description files

The COREOS_SWUPDATE_EXTENDS_FOR and COREOS_IMAGE_SWUPDATE_EXTRACLASSES
variable can now be used to configure the coreos-image-swupdate to
dynamically extends some part of the sw-description by calling some
python function
This commit is contained in:
Samuel Dolt 2023-05-15 17:51:50 +02:00
parent d77f448f5c
commit 917f491c5f
2 changed files with 53 additions and 0 deletions

View File

@ -38,3 +38,38 @@ python () {
}
FILESEXTRAPATHS:append := ":${COREOS_ROOT}/layers/meta-belden-coreos/files"
# Space seperated list of extension points
COREOS_SWUPDATE_EXTENDS_FOR ??= ""
def coreos_swupdate_extends(d, s, key):
"""
Extends the swupdate for each extension points defined by COREOS_SWUPDATE_EXTENDS_FOR
"""
extends_for = d.getVar('COREOS_SWUPDATE_EXTENDS_FOR', True).replace("-", "_").split()
def kv_to_sw_description(kv):
swdescr = ",{\n"
for key, value in kv.items():
swdescr += f'{key} = "{value}";\n'
swdescr += "}\n"
return swdescr
text = ""
# BSP and Distro can extends the swupdate by implementing some python
# function that return a list of dictionary.
for extension_point in extends_for:
try:
kv_list = globals()[f"coreos_swupdate_extends_{key}_for_{extension_point}"](d,s)
except KeyError:
# Don't fail if the extension is not implemented
pass
else:
for kv in kv_list:
text += kv_to_sw_description(kv)
return text
COREOS_IMAGE_SWUPDATE_EXTRACLASSES ?= ""
inherit ${COREOS_IMAGE_SWUPDATE_EXTRACLASSES}

View File

@ -16,6 +16,9 @@ software =
type = "raw";
sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)";
}
# Don't remove the trailing whitspace on the next line otherwise
# it will not work due to a regex bug in meta-swupdate
$coreos_swupdate_extends(images)
);
files: (
@ -33,6 +36,9 @@ software =
filesystem = "vfat";
sha256 = "$swupdate_get_sha256(@@COREOS_EFIBOOTGUARD_FILENAME@@)";
}
# Don't remove the trailing whitspace on the next line otherwise
# it will not work due to a regex bug in meta-swupdate
$coreos_swupdate_extends(files)
);
bootenv: (
@ -49,6 +55,9 @@ software =
value = "C:BOOT0:KERNEL.EFI";
}
# Don't remove the trailing whitspace on the next line otherwise
# it will not work due to a regex bug in meta-swupdate
$coreos_swupdate_extends(bootenv)
);
}
@ -64,6 +73,9 @@ software =
type = "raw";
sha256 = "$swupdate_get_sha256(@@PN@@-@@MACHINE@@.ext4.zst)";
}
# Don't remove the trailing whitspace on the next line otherwise
# it will not work due to a regex bug in meta-swupdate
$coreos_swupdate_extends(images)
);
files: (
@ -81,6 +93,9 @@ software =
filesystem = "vfat";
sha256 = "$swupdate_get_sha256(@@COREOS_EFIBOOTGUARD_FILENAME@@)";
}
# Don't remove the trailing whitspace on the next line otherwise
# it will not work due to a regex bug in meta-swupdate
$coreos_swupdate_extends(files)
);
bootenv: (
{
@ -96,6 +111,9 @@ software =
value = "C:BOOT1:KERNEL.EFI";
}
# Don't remove the trailing whitspace on the next line otherwise
# it will not work due to a regex bug in meta-swupdate
$coreos_swupdate_extends(bootenv)
);
}
}