diff --git a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc b/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc deleted file mode 100644 index f07d416..0000000 --- a/layers/meta-belden-coreos-bsp/conf/machine/include/coreos-generic-features/legacy-mbr-disk.inc +++ /dev/null @@ -1,15 +0,0 @@ - -# MBR disk are still supported by CoreOS, but only for legacy product -# This ensure that efibootguard / swupdate work with MBR disk - -# MBR can't disk can't use partition label, but may use filesystem label -# This will only work with an initramfs. If no initramfs is used, this will -# have to be set to the right disk device inside the machine configuration -# like that COREOS_PLATFORMx_ROOT = "/dev/mmcblkp" -COREOS_PLATFORM0_ROOT ?= "LABEL=platform0" -COREOS_PLATFORM1_ROOT ?= "LABEL=platform1" - -# MBR disk can't use --part-type but can use system-id -WKS_PART_EFI ?= 'part --source efibootguard-efi --label efi --system-id 0xef' -WKS_PART_EFIBOOTGUARD_A ?= 'part --source efibootguard-boot --label boot0 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=2,kernel=kernel0-${MACHINE}.efi;KERNEL0.EFI"' -WKS_PART_EFIBOOTGUARD_B ?= 'part --source efibootguard-boot --label boot1 --sourceparams "watchdog=${EFIBOOTGUARD_TIMEOUT},revision=1,kernel=kernel1-${MACHINE}.efi;KERNEL1.EFI"' diff --git a/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass b/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass index dca81fd..56cfd4d 100644 --- a/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass +++ b/layers/meta-belden-coreos/classes/coreos-image-swupdate.bbclass @@ -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} diff --git a/layers/meta-belden-coreos/files/sw-description b/layers/meta-belden-coreos/files/sw-description index 5f16386..0a47093 100644 --- a/layers/meta-belden-coreos/files/sw-description +++ b/layers/meta-belden-coreos/files/sw-description @@ -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) ); } }