Message ID | 20230104030214.465039-1-felix.moessbauer@siemens.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [isar-cip-core,1/1] Use global variables for abrootfs partition uuids | expand |
On 04.01.23 04:02, Felix Moessbauer wrote: > This patch converts the abrootfs partition uuids to a template and adds > two global variables to control their values. By that, the partition > uuids used in the WIC files can be kept in sync with the uuids used in > the sw-description file. This helps to avoid issues where the part uuids > are inconsistent and hence the update using swupdate fails. > > To help users migrate, we also add a check for the validity of the UUIDs > added to ABROOTFS_PART_UUID_(A|B). > > Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> > --- > kas/opt/swupdate.yml | 2 ++ > recipes-core/images/files/sw-description.tmpl | 2 +- > recipes-core/images/swupdate.inc | 19 +++++++++++++++++++ > wic/bbb-efibootguard.wks.in | 4 ++-- > wic/qemu-amd64-efibootguard-secureboot.wks.in | 4 ++-- > wic/qemu-arm64-efibootguard-secureboot.wks.in | 4 ++-- > wic/qemu-arm64-efibootguard.wks.in | 4 ++-- > wic/x86-efibootguard.wks.in | 4 ++-- > 8 files changed, 32 insertions(+), 11 deletions(-) > > diff --git a/kas/opt/swupdate.yml b/kas/opt/swupdate.yml > index f0d3f1b..60a4aec 100644 > --- a/kas/opt/swupdate.yml > +++ b/kas/opt/swupdate.yml > @@ -25,3 +25,5 @@ local_conf_header: > WKS_FILE ?= "${MACHINE}-${SWUPDATE_BOOTLOADER}.wks.in" > INITRAMFS_INSTALL_append = " initramfs-squashfs-hook" > WIC_DEPLOY_PARTITIONS = "1" > + ABROOTFS_PART_UUID_A ?= "fedcba98-7654-3210-cafe-5e0710000001" > + ABROOTFS_PART_UUID_B ?= "fedcba98-7654-3210-cafe-5e0710000002" It feels like we are piling up too much stuff in the kas option that is hard to reuse by downstream. Maybe a conf include for distro confs instead? > diff --git a/recipes-core/images/files/sw-description.tmpl b/recipes-core/images/files/sw-description.tmpl > index f7105c7..05125e6 100644 > --- a/recipes-core/images/files/sw-description.tmpl > +++ b/recipes-core/images/files/sw-description.tmpl > @@ -14,7 +14,7 @@ software = > name = "cip software update"; > images: ({ > filename = "${ROOTFS_PARTITION_NAME}"; > - device = "C:BOOT0:linux.efi->fedcba98-7654-3210-cafe-5e0710000001,C:BOOT1:linux.efi->fedcba98-7654-3210-cafe-5e0710000002"; > + device = "C:BOOT0:linux.efi->${ABROOTFS_PART_UUID_A},C:BOOT1:linux.efi->${ABROOTFS_PART_UUID_B}"; > type = "roundrobin"; > compressed = "zlib"; > filesystem = "ext4"; > diff --git a/recipes-core/images/swupdate.inc b/recipes-core/images/swupdate.inc > index 0ba3a0e..f98082c 100644 > --- a/recipes-core/images/swupdate.inc > +++ b/recipes-core/images/swupdate.inc > @@ -16,6 +16,11 @@ inherit read-only-rootfs > IMAGE_INSTALL += " swupdate" > IMAGE_INSTALL += " swupdate-handler-roundrobin" > > +# The uuids correspond to the partition uuids > +# in the wic script. Set via machine or local config. > +ABROOTFS_PART_UUID_A ??= "" > +ABROOTFS_PART_UUID_B ??= "" > + Just handle the undefined case for those vars below - or let things crash on resolving those undefined vars. > ROOTFS_PARTITION_NAME = "${IMAGE_FULLNAME}.wic.p4.gz" > > FILESEXTRAPATHS_prepend := "${THISDIR}/files:" > @@ -29,3 +34,17 @@ addtask do_transform_template before do_swupdate_binary after do_generate_image_ > TEMPLATE_VARS += "ROOTFS_PARTITION_NAME TARGET_IMAGE_UUID" > > SWU_ADDITIONAL_FILES += "linux.efi ${ROOTFS_PARTITION_NAME}" > + > +python() { > + import uuid > + def is_valid(value): > + try: > + uuid.UUID(value) > + except ValueError: > + return False > + return True > + > + for u in ['A', 'B']: > + if not is_valid(d.getVar('ABROOTFS_PART_UUID_' + u)): > + bb.fatal('ABROOTFS_PART_UUID_' + u + ' is not a valid UUID') > +} Quite some boilerplate... We don't have that in place for other inteface vars that need to have proper values, so I'm unsure if these here are so much different to justify it. It would be nicer to have a cookbook on how to consume the swupdate integration in a downstream layer, and that would then have an entry on these vars. > diff --git a/wic/bbb-efibootguard.wks.in b/wic/bbb-efibootguard.wks.in > index e48cc7f..a714694 100644 > --- a/wic/bbb-efibootguard.wks.in > +++ b/wic/bbb-efibootguard.wks.in > @@ -11,8 +11,8 @@ part --source rawcopy --sourceparams "file=/usr/lib/u-boot/bbb/u-boot.img" --no- > > include ebg-sysparts.inc > > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" > > # home and var are extra partitions > part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G > diff --git a/wic/qemu-amd64-efibootguard-secureboot.wks.in b/wic/qemu-amd64-efibootguard-secureboot.wks.in > index 0e298bc..8305ebd 100644 > --- a/wic/qemu-amd64-efibootguard-secureboot.wks.in > +++ b/wic/qemu-amd64-efibootguard-secureboot.wks.in > @@ -1,7 +1,7 @@ > include ebg-signed-sysparts.inc > > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" > > # home and var are extra partitions > part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G > diff --git a/wic/qemu-arm64-efibootguard-secureboot.wks.in b/wic/qemu-arm64-efibootguard-secureboot.wks.in > index 3b8dadd..6b01443 100644 > --- a/wic/qemu-arm64-efibootguard-secureboot.wks.in > +++ b/wic/qemu-arm64-efibootguard-secureboot.wks.in > @@ -1,7 +1,7 @@ > include ebg-signed-sysparts.inc > > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" > > # home and var are extra partitions > part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G > diff --git a/wic/qemu-arm64-efibootguard.wks.in b/wic/qemu-arm64-efibootguard.wks.in > index 9ff03e1..bc684f3 100644 > --- a/wic/qemu-arm64-efibootguard.wks.in > +++ b/wic/qemu-arm64-efibootguard.wks.in > @@ -3,8 +3,8 @@ > > include ebg-sysparts.inc > > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" > > # home and var are extra partitions > part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G > diff --git a/wic/x86-efibootguard.wks.in b/wic/x86-efibootguard.wks.in > index c71253d..0604deb 100644 > --- a/wic/x86-efibootguard.wks.in > +++ b/wic/x86-efibootguard.wks.in > @@ -3,8 +3,8 @@ > > include ebg-sysparts.inc > > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" > -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" > +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" > > # home and var are extra partitions > part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G Jan
diff --git a/kas/opt/swupdate.yml b/kas/opt/swupdate.yml index f0d3f1b..60a4aec 100644 --- a/kas/opt/swupdate.yml +++ b/kas/opt/swupdate.yml @@ -25,3 +25,5 @@ local_conf_header: WKS_FILE ?= "${MACHINE}-${SWUPDATE_BOOTLOADER}.wks.in" INITRAMFS_INSTALL_append = " initramfs-squashfs-hook" WIC_DEPLOY_PARTITIONS = "1" + ABROOTFS_PART_UUID_A ?= "fedcba98-7654-3210-cafe-5e0710000001" + ABROOTFS_PART_UUID_B ?= "fedcba98-7654-3210-cafe-5e0710000002" diff --git a/recipes-core/images/files/sw-description.tmpl b/recipes-core/images/files/sw-description.tmpl index f7105c7..05125e6 100644 --- a/recipes-core/images/files/sw-description.tmpl +++ b/recipes-core/images/files/sw-description.tmpl @@ -14,7 +14,7 @@ software = name = "cip software update"; images: ({ filename = "${ROOTFS_PARTITION_NAME}"; - device = "C:BOOT0:linux.efi->fedcba98-7654-3210-cafe-5e0710000001,C:BOOT1:linux.efi->fedcba98-7654-3210-cafe-5e0710000002"; + device = "C:BOOT0:linux.efi->${ABROOTFS_PART_UUID_A},C:BOOT1:linux.efi->${ABROOTFS_PART_UUID_B}"; type = "roundrobin"; compressed = "zlib"; filesystem = "ext4"; diff --git a/recipes-core/images/swupdate.inc b/recipes-core/images/swupdate.inc index 0ba3a0e..f98082c 100644 --- a/recipes-core/images/swupdate.inc +++ b/recipes-core/images/swupdate.inc @@ -16,6 +16,11 @@ inherit read-only-rootfs IMAGE_INSTALL += " swupdate" IMAGE_INSTALL += " swupdate-handler-roundrobin" +# The uuids correspond to the partition uuids +# in the wic script. Set via machine or local config. +ABROOTFS_PART_UUID_A ??= "" +ABROOTFS_PART_UUID_B ??= "" + ROOTFS_PARTITION_NAME = "${IMAGE_FULLNAME}.wic.p4.gz" FILESEXTRAPATHS_prepend := "${THISDIR}/files:" @@ -29,3 +34,17 @@ addtask do_transform_template before do_swupdate_binary after do_generate_image_ TEMPLATE_VARS += "ROOTFS_PARTITION_NAME TARGET_IMAGE_UUID" SWU_ADDITIONAL_FILES += "linux.efi ${ROOTFS_PARTITION_NAME}" + +python() { + import uuid + def is_valid(value): + try: + uuid.UUID(value) + except ValueError: + return False + return True + + for u in ['A', 'B']: + if not is_valid(d.getVar('ABROOTFS_PART_UUID_' + u)): + bb.fatal('ABROOTFS_PART_UUID_' + u + ' is not a valid UUID') +} diff --git a/wic/bbb-efibootguard.wks.in b/wic/bbb-efibootguard.wks.in index e48cc7f..a714694 100644 --- a/wic/bbb-efibootguard.wks.in +++ b/wic/bbb-efibootguard.wks.in @@ -11,8 +11,8 @@ part --source rawcopy --sourceparams "file=/usr/lib/u-boot/bbb/u-boot.img" --no- include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" # home and var are extra partitions part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G diff --git a/wic/qemu-amd64-efibootguard-secureboot.wks.in b/wic/qemu-amd64-efibootguard-secureboot.wks.in index 0e298bc..8305ebd 100644 --- a/wic/qemu-amd64-efibootguard-secureboot.wks.in +++ b/wic/qemu-amd64-efibootguard-secureboot.wks.in @@ -1,7 +1,7 @@ include ebg-signed-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" # home and var are extra partitions part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G diff --git a/wic/qemu-arm64-efibootguard-secureboot.wks.in b/wic/qemu-arm64-efibootguard-secureboot.wks.in index 3b8dadd..6b01443 100644 --- a/wic/qemu-arm64-efibootguard-secureboot.wks.in +++ b/wic/qemu-arm64-efibootguard-secureboot.wks.in @@ -1,7 +1,7 @@ include ebg-signed-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.verity" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" # home and var are extra partitions part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G diff --git a/wic/qemu-arm64-efibootguard.wks.in b/wic/qemu-arm64-efibootguard.wks.in index 9ff03e1..bc684f3 100644 --- a/wic/qemu-arm64-efibootguard.wks.in +++ b/wic/qemu-arm64-efibootguard.wks.in @@ -3,8 +3,8 @@ include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" # home and var are extra partitions part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G diff --git a/wic/x86-efibootguard.wks.in b/wic/x86-efibootguard.wks.in index c71253d..0604deb 100644 --- a/wic/x86-efibootguard.wks.in +++ b/wic/x86-efibootguard.wks.in @@ -3,8 +3,8 @@ include ebg-sysparts.inc -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000001" -part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "fedcba98-7654-3210-cafe-5e0710000002" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_A}" +part --source rawcopy --sourceparams "file=${IMAGE_FULLNAME}.squashfs" --align 1024 --fixed-size 1G --uuid "${ABROOTFS_PART_UUID_B}" # home and var are extra partitions part /home --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/home --fstype=ext4 --label home --align 1024 --size 1G
This patch converts the abrootfs partition uuids to a template and adds two global variables to control their values. By that, the partition uuids used in the WIC files can be kept in sync with the uuids used in the sw-description file. This helps to avoid issues where the part uuids are inconsistent and hence the update using swupdate fails. To help users migrate, we also add a check for the validity of the UUIDs added to ABROOTFS_PART_UUID_(A|B). Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com> --- kas/opt/swupdate.yml | 2 ++ recipes-core/images/files/sw-description.tmpl | 2 +- recipes-core/images/swupdate.inc | 19 +++++++++++++++++++ wic/bbb-efibootguard.wks.in | 4 ++-- wic/qemu-amd64-efibootguard-secureboot.wks.in | 4 ++-- wic/qemu-arm64-efibootguard-secureboot.wks.in | 4 ++-- wic/qemu-arm64-efibootguard.wks.in | 4 ++-- wic/x86-efibootguard.wks.in | 4 ++-- 8 files changed, 32 insertions(+), 11 deletions(-)