From c4f001bef9df08c7dbdd6f8bbbc1be5338fc3d16 Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> Date: Fri, 22 Apr 2022 10:33:40 +0200 Subject: [PATCH] sysota: generate RAUC configuration file from template As we add support for additional boards, doing it by copying and modifying a file with relatively few parts changing got tedious. The change adds half a dozen new variables for selecting the boot loader type, various strings and directories. The defaults are safe, even if unused, for all kinds of boards. The machine-specific overrides tune the bootloader used by each board and provide proper identification strings. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> --- .../sysota/files/qemux86-64/sysotad.conf | 20 ---------- .../sysota/files/qemux86/sysotad.conf | 20 ---------- .../sysota/files/raspberrypi4/sysotad.conf | 17 --------- .../recipes-core/sysota/files/sysotad.conf | 10 ----- .../recipes-core/sysota/files/sysotad.conf.in | 20 ++++++++++ .../recipes-core/sysota/sysota_git.bb | 38 ++++++++++++++++--- 6 files changed, 53 insertions(+), 72 deletions(-) delete mode 100644 meta-oniro-core/recipes-core/sysota/files/qemux86-64/sysotad.conf delete mode 100644 meta-oniro-core/recipes-core/sysota/files/qemux86/sysotad.conf delete mode 100644 meta-oniro-core/recipes-core/sysota/files/raspberrypi4/sysotad.conf create mode 100644 meta-oniro-core/recipes-core/sysota/files/sysotad.conf.in diff --git a/meta-oniro-core/recipes-core/sysota/files/qemux86-64/sysotad.conf b/meta-oniro-core/recipes-core/sysota/files/qemux86-64/sysotad.conf deleted file mode 100644 index 0488748f..00000000 --- a/meta-oniro-core/recipes-core/sysota/files/qemux86-64/sysotad.conf +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-FileCopyrightText: Huawei Inc. -# -# SPDX-License-Identifier: Apache-2.0 - -[OTA] -BootLoaderType=GRUB -BootPartitionMountDir=/run/mount/boot - -[GRUB] -EnvPath=/run/mount/boot/EFI/BOOT/grubenv - -[Device] -Maker=Oniro Project -Model=QEMU Virtual Machine - -[Compatible] -Machine=qemux86-64 - -[Quirks] -RebootDelay=180 diff --git a/meta-oniro-core/recipes-core/sysota/files/qemux86/sysotad.conf b/meta-oniro-core/recipes-core/sysota/files/qemux86/sysotad.conf deleted file mode 100644 index e45d5355..00000000 --- a/meta-oniro-core/recipes-core/sysota/files/qemux86/sysotad.conf +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-FileCopyrightText: Huawei Inc. -# -# SPDX-License-Identifier: Apache-2.0 - -[OTA] -BootLoaderType=GRUB -BootPartitionMountDir=/run/mount/boot - -[GRUB] -EnvPath=/run/mount/boot/EFI/BOOT/grubenv - -[Device] -Maker=Oniro Project -Model=QEMU Virtual Machine - -[Compatible] -Machine=qemux86 - -[Quirks] -RebootDelay=180 diff --git a/meta-oniro-core/recipes-core/sysota/files/raspberrypi4/sysotad.conf b/meta-oniro-core/recipes-core/sysota/files/raspberrypi4/sysotad.conf deleted file mode 100644 index dadd6a71..00000000 --- a/meta-oniro-core/recipes-core/sysota/files/raspberrypi4/sysotad.conf +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-FileCopyrightText: Huawei Inc. -# -# SPDX-License-Identifier: Apache-2.0 - -[OTA] -BootLoaderType=pi-boot -BootPartitionMountDir=/run/mount/boot - -[Device] -Maker=Oniro Project -Model=Raspberry Pi 4B - -[Compatible] -Machine=raspberrypi4-64 - -[Quirks] -RebootDelay=180 diff --git a/meta-oniro-core/recipes-core/sysota/files/sysotad.conf b/meta-oniro-core/recipes-core/sysota/files/sysotad.conf index ca1a87de..e69de29b 100644 --- a/meta-oniro-core/recipes-core/sysota/files/sysotad.conf +++ b/meta-oniro-core/recipes-core/sysota/files/sysotad.conf @@ -1,10 +0,0 @@ -# SPDX-FileCopyrightText: Huawei Inc. -# -# SPDX-License-Identifier: Apache-2.0 - -[OTA] -BootLoaderType=inert - -[Device] -Maker=Oniro Project -Model=Reference Device diff --git a/meta-oniro-core/recipes-core/sysota/files/sysotad.conf.in b/meta-oniro-core/recipes-core/sysota/files/sysotad.conf.in new file mode 100644 index 00000000..a4d0c62e --- /dev/null +++ b/meta-oniro-core/recipes-core/sysota/files/sysotad.conf.in @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +[OTA] +BootLoaderType=@SYSOTA_BOOTLOADER_TYPE@ +BootPartitionMountDir=@SYSOTA_BOOT_PARTITION_MOUNT_DIR@ + +[Device] +Maker=@SYSOTA_MAKER@ +Model=@SYSOTA_MODEL@ + +[GRUB] +EnvPath=@SYSOTA_GRUB_ENV_PATH@ + +[Compatible] +Machine=@SYSOTA_COMPAT_MACHINE@ + +[Quirks] +RebootDelay=@SYSOTA_QUIRK_REBOOT_DELAY@ diff --git a/meta-oniro-core/recipes-core/sysota/sysota_git.bb b/meta-oniro-core/recipes-core/sysota/sysota_git.bb index 41802ffa..fe324aaf 100644 --- a/meta-oniro-core/recipes-core/sysota/sysota_git.bb +++ b/meta-oniro-core/recipes-core/sysota/sysota_git.bb @@ -7,7 +7,7 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSES/Apache-2.0.txt;md5=c846ebb396f8b174b10ded4771514fcc" SRC_URI = "git://gitlab.eclipse.org/eclipse/oniro-core/sysota.git;protocol=https;branch=main \ - file://sysotad.conf \ + file://sysotad.conf.in \ " SRCREV = "4fc590e1d329aa9e05e64ae3a15d91481aa86e1d" S = "${WORKDIR}/git" @@ -88,6 +88,38 @@ do_compile:append() { do_compile[network] = "1" +# Generate sysotad.conf configuration file based on several variables. + +SYSOTA_BOOTLOADER_TYPE ?= "inert" +SYSOTA_BOOT_PARTITION_MOUNT_DIR ?= "/run/mount/boot" +SYSOTA_MAKER ?= "Oniro Project" +SYSOTA_MODEL ?= "Reference Device" +SYSOTA_GRUB_ENV_PATH ?= "/run/mount/boot/EFI/BOOT/grubenv" +SYSOTA_COMPAT_MACHINE ?= "${MACHINE}" +SYSOTA_QUIRK_REBOOT_DELAY ?= "180" + +# Define machine-specific configuration overrides. +SYSOTA_MODEL:raspberrypi4-64 := "Raspberry Pi 4B" +SYSOTA_BOOTLOADER_TYPE:raspberrypi4-64 := "pi-boot" + +SYSOTA_MODEL:qemux86 := "QEMU Virtual Machine" +SYSOTA_BOOTLOADER_TYPE:qemux86 := "GRUB" + +SYSOTA_MODEL:qemux86-64 := "QEMU Virtual Machine" +SYSOTA_BOOTLOADER_TYPE:qemux86-64 := "GRUB" + +do_install:prepend() { + sed \ + -e 's,@SYSOTA_BOOTLOADER_TYPE@,${SYSOTA_BOOTLOADER_TYPE},g' \ + -e 's,@SYSOTA_BOOT_PARTITION_MOUNT_DIR@,${SYSOTA_BOOT_PARTITION_MOUNT_DIR},g' \ + -e 's,@SYSOTA_MAKER@,${SYSOTA_MAKER},g' \ + -e 's,@SYSOTA_MODEL@,${SYSOTA_MODEL},g' \ + -e 's,@SYSOTA_GRUB_ENV_PATH@,${SYSOTA_GRUB_ENV_PATH},g' \ + -e 's,@SYSOTA_COMPAT_MACHINE@,${SYSOTA_COMPAT_MACHINE},g' \ + -e 's,@SYSOTA_QUIRK_REBOOT_DELAY@,${SYSOTA_QUIRK_REBOOT_DELAY},g' \ + <"${WORKDIR}/sysotad.conf.in" >"${WORKDIR}/sysotad.conf" +} + do_install:append() { oe_runmake -C ${B}/make-build --warn-undefined-variables install DESTDIR=${D} @@ -115,10 +147,6 @@ RDEPENDS:${PN}-dev += "bash" REQUIRED_DISTRO_FEATURES = "systemd" SYSTEMD_SERVICE:${PN} = "sysotad.service" -# Specific MACHINE configurations have sysotad.conf which provides the right -# settings, like the boot loader type. -FILESEXTRAPATHS:prepend:raspberrypi4-64 := "${THISDIR}/files/raspberrypi4:" - # Make the SystemOTA package machine-specific. This lets us put the specific # configuration file, which encodes boot loader type, into it safely. PACKAGE_ARCH = "${MACHINE_ARCH}" -- GitLab