From 4fcf797368139cb42ced99fc3b14bd543b37108d Mon Sep 17 00:00:00 2001 From: antznin Date: Fri, 29 May 2020 09:59:15 +0200 Subject: image_types_ostree: allow specifying a device tree to deploy When setting `OSTREE_DEPLOY_DEVICETREE` to 1, it will by default deploy all the device tree blobs present in `KERNEL_DEVICETREE`. Adding `OSTREE_DEVICETREE` would allow specifying a specific device tree blob (or several dtbs), thus resulting in only the specified ones in the image. This is particularely useful because ostree selects the first device tree it finds in /boot, and discards the remaining ones. Signed-off-by: antznin --- classes/image_types_ostree.bbclass | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 8d68b5a..c95aa5e 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -8,6 +8,7 @@ OSTREE_COMMIT_BODY ??= "" OSTREE_COMMIT_VERSION ??= "${DISTRO_VERSION}" OSTREE_UPDATE_SUMMARY ??= "0" OSTREE_DEPLOY_DEVICETREE ??= "0" +OSTREE_DEVICETREE ??= "${KERNEL_DEVICETREE}" BUILD_OSTREE_TARBALL ??= "1" @@ -140,9 +141,9 @@ IMAGE_CMD_ostree () { checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") touch boot/initramfs-${checksum} else - if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${KERNEL_DEVICETREE}" ]; then - checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") - for DTS_FILE in ${KERNEL_DEVICETREE}; do + if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${OSTREE_DEVICETREE}" ]; then + checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${OSTREE_DEVICETREE} | sha256sum | cut -f 1 -d " ") + for DTS_FILE in ${OSTREE_DEVICETREE}; do DTS_FILE_BASENAME=$(basename ${DTS_FILE}) cp ${DEPLOY_DIR_IMAGE}/${DTS_FILE_BASENAME} boot/devicetree-${DTS_FILE_BASENAME}-${checksum} done -- cgit v1.2.3-54-g00ecf From 75069b6a653a19e298c1b2ea791e80955a26b7b6 Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Mon, 11 May 2020 20:16:05 +0200 Subject: meta: introduce ostree-kernel-initramfs recipe We package kernel image, devicetrees, initramfs and install them to /usr/lib/modules/${KERNEL_VERSION}, which is the preferred location according to ostree's new implementation, this could simplify the deployment. Reference: https://github.com/ostreedev/ostree/commit/3ab0d5e6644885440bac6abd17b6d2637df5435f To let initramfs-ostree-image be able to be depended by ostree-kernel-initramfs, it must inherit nopackages to avoid a annoying QA warning like the follows: | WARNING: initramfs-ostree-image-0.0.1-r0 do_package: Manifest ...initramfs-ostree-image.packagedata | not found in colibri_imx6 armv7ahf-neon-imx armv7at2hf-neon-imx armv7at2hf-neon armv7ahf-neon armv7at2hf-vfp | armv7ahf-vfp armv6thf-vfp armv6hf-vfp armv5tehf-vfp armv5ehf-vfp armv5thf-vfp armv5hf-vfp allarch | x86_64_x86_64-nativesdk (variant '')? Also we need define OSTREE_KERNEL, OSTREE_DEPLOY_DEVICETREE and OSTREE_DEVICETREE in sota.bbclass so they could be accessed in other recipes as well as in image recipes. Signed-off-by: Stefan Agner Signed-off-by: Ming Liu --- classes/image_types_ostree.bbclass | 24 ---------- classes/sota.bbclass | 8 +++- recipes-core/images/initramfs-ostree-image.bb | 2 +- .../ostree-kernel-initramfs_0.0.1.bb | 52 ++++++++++++++++++++++ 4 files changed, 60 insertions(+), 26 deletions(-) create mode 100644 recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index c95aa5e..219218d 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -1,14 +1,11 @@ # OSTree deployment inherit distro_features_check -OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" OSTREE_ROOTFS ??= "${WORKDIR}/ostree-rootfs" OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" OSTREE_COMMIT_BODY ??= "" OSTREE_COMMIT_VERSION ??= "${DISTRO_VERSION}" OSTREE_UPDATE_SUMMARY ??= "0" -OSTREE_DEPLOY_DEVICETREE ??= "0" -OSTREE_DEVICETREE ??= "${KERNEL_DEVICETREE}" BUILD_OSTREE_TARBALL ??= "1" @@ -134,27 +131,6 @@ IMAGE_CMD_ostree () { ln -sf ../var/usrlocal usr/local - if [ "${KERNEL_IMAGETYPE}" = "fitImage" ]; then - # this is a hack for ostree not to override init= in kernel cmdline - - # make it think that the initramfs is present (while it is in FIT image) - # since initramfs is fake file, it does not need to be included in checksum - checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") - touch boot/initramfs-${checksum} - else - if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${OSTREE_DEVICETREE}" ]; then - checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${OSTREE_DEVICETREE} | sha256sum | cut -f 1 -d " ") - for DTS_FILE in ${OSTREE_DEVICETREE}; do - DTS_FILE_BASENAME=$(basename ${DTS_FILE}) - cp ${DEPLOY_DIR_IMAGE}/${DTS_FILE_BASENAME} boot/devicetree-${DTS_FILE_BASENAME}-${checksum} - done - else - checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} | sha256sum | cut -f 1 -d " ") - fi - cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} boot/initramfs-${checksum} - fi - - cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} boot/vmlinuz-${checksum} - # Copy image manifest cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest } diff --git a/classes/sota.bbclass b/classes/sota.bbclass index 71bd303..dc18cbc 100644 --- a/classes/sota.bbclass +++ b/classes/sota.bbclass @@ -5,8 +5,11 @@ SOTA_CLIENT_PROV ??= "aktualizr-shared-prov" SOTA_DEPLOY_CREDENTIALS ?= "1" SOTA_HARDWARE_ID ??= "${MACHINE}" -IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV}" IMAGE_CLASSES += " image_types_ostree image_types_ota image_repo_manifest" +IMAGE_INSTALL_append_sota = " ${SOTA_CLIENT} ${SOTA_CLIENT_PROV} \ + ostree os-release ostree-kernel \ + ${@'ostree-initramfs' if d.getVar('KERNEL_IMAGETYPE') != 'fitImage' else ''} \ + ${@'ostree-devicetrees' if oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}') else ''}" IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'ostreepush garagesign garagecheck ota-ext4 wic', ' ', d)}" IMAGE_FSTYPES += "${@bb.utils.contains('BUILD_OSTREE_TARBALL', '1', 'ostree.tar.bz2', ' ', d)}" @@ -27,6 +30,9 @@ OSTREE_BRANCHNAME ?= "${SOTA_HARDWARE_ID}" OSTREE_OSNAME ?= "poky" OSTREE_BOOTLOADER ??= 'u-boot' OSTREE_BOOT_PARTITION ??= "/boot" +OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" +OSTREE_DEPLOY_DEVICETREE ??= "0" +OSTREE_DEVICETREE ??= "${KERNEL_DEVICETREE}" INITRAMFS_IMAGE ?= "initramfs-ostree-image" diff --git a/recipes-core/images/initramfs-ostree-image.bb b/recipes-core/images/initramfs-ostree-image.bb index bc21ed3..4af1548 100644 --- a/recipes-core/images/initramfs-ostree-image.bb +++ b/recipes-core/images/initramfs-ostree-image.bb @@ -20,7 +20,7 @@ IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" # Avoid circular dependencies EXTRA_IMAGEDEPENDS = "" -inherit core-image +inherit core-image nopackages IMAGE_ROOTFS_SIZE = "8192" diff --git a/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb b/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb new file mode 100644 index 0000000..fe8a9cc --- /dev/null +++ b/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb @@ -0,0 +1,52 @@ +SUMMARY = "Ostree linux kernel, devicetrees and initramfs packager" +DESCRIPTION = "Ostree linux kernel, devicetrees and initramfs packager" +SECTION = "kernel" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" + +# Whilst not a module, this ensures we don't get multilib extended (which would make no sense) +inherit module-base kernel-artifact-names + +PACKAGES = "ostree-kernel ostree-initramfs ostree-devicetrees" + +ALLOW_EMPTY_ostree-initramfs = "1" +ALLOW_EMPTY_ostree-devicetrees = "1" + +FILES_ostree-kernel = "${nonarch_base_libdir}/modules/*/vmlinuz" +FILES_ostree-initramfs = "${nonarch_base_libdir}/modules/*/initramfs.img" +FILES_ostree-devicetrees = "${nonarch_base_libdir}/modules/*/dtb/*" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +KERNEL_BUILD_ROOT = "${nonarch_base_libdir}/modules/" + +# There's nothing to do here, except install the artifacts where we can package them +do_fetch[noexec] = "1" +do_unpack[noexec] = "1" +do_patch[noexec] = "1" +do_configure[noexec] = "1" +do_compile[noexec] = "1" +deltask do_populate_sysroot + +do_install() { + kerneldir=${D}${KERNEL_BUILD_ROOT}${KERNEL_VERSION} + install -d $kerneldir + + cp ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} $kerneldir/vmlinuz + + if [ "${KERNEL_IMAGETYPE}" != "fitImage" ]; then + if [ -n "${INITRAMFS_IMAGE}" ]; then + cp ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} $kerneldir/initramfs.img + fi + + if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${OSTREE_DEVICETREE}" ]; then + mkdir -p $kerneldir/dtb + for dts_file in ${KERNEL_DEVICETREE}; do + dts_file_basename=$(basename $dts_file) + cp ${DEPLOY_DIR_IMAGE}/$dts_file_basename $kerneldir/dtb/$dts_file_basename + done + fi + fi +} +do_install[vardepsexclude] = "KERNEL_VERSION" +do_install[depends] = "virtual/kernel:do_deploy ${@['${INITRAMFS_IMAGE}:do_image_complete', ''][d.getVar('INITRAMFS_IMAGE') == '']}" -- cgit v1.2.3-54-g00ecf From 6a0fa6a8a4e66fb1502e2ff2e1b708eb45d4e179 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 15 Jun 2020 08:27:36 +0000 Subject: aktualizr: make use of boot-complete.target From the systemd.special(7) man page section boot-complete.target: This target is intended as generic synchronization point for services that shall determine or act on whether the boot process completed successfully. Let's make use of the target. Since aktualizr by default marks a boot as successful, we consider aktualizr.service a service which needs to be executed on successful boot (hence after the boot-complete.target). This allows to declare a service as crucial by simply ordering it before the boot-complete.target. The systemd example service systemd-boot-check-no-failures.service can serve as an example. This change does not add any service dependency by default as boot-complete.target by default does not has any extra dependencies. Note that rebooting in the failure case is not handled by this mechanism. This can be added by using FailureAction. Boot assessement infrastructure got introduced with systemd 240. See also: https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT/ Signed-off-by: Stefan Agner --- recipes-sota/aktualizr/files/aktualizr.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes-sota/aktualizr/files/aktualizr.service b/recipes-sota/aktualizr/files/aktualizr.service index 3d807a1..ae5d23a 100644 --- a/recipes-sota/aktualizr/files/aktualizr.service +++ b/recipes-sota/aktualizr/files/aktualizr.service @@ -1,6 +1,7 @@ [Unit] Description=Aktualizr SOTA Client -After=network-online.target nss-lookup.target +After=network-online.target nss-lookup.target boot-complete.target +Requires=boot-complete.target Wants=network-online.target [Service] -- cgit v1.2.3-54-g00ecf From b712720da6d82e2a4b43f89c380cd33e2ddce86d Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Fri, 26 Jun 2020 20:16:02 +0200 Subject: ostree-kernel-initramfs: fix parsing for MACHINEs which don't define INITRAMFS_IMAGE * when INITRAMFS_IMAGE isn't defined at all, the "d.getVar('INITRAMFS_IMAGE') == ''" part doesn't do anything useful, because the unexpanded version of this ends in do_install[depends] variable and breaks parsing: meta-updater/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb:do_install[depends], dependency ''][d.getVar('INITRAMFS_IMAGE') in 'virtual/kernel:do_deploy ${@['${INITRAMFS_IMAGE}:do_image_complete', ''][d.getVar('INITRAMFS_IMAGE') == '']} virtual/fakeroot-native:do_populate_sysroot' does not contain exactly one ':' character. Task 'depends' should be specified in the form 'packagename:task' Signed-off-by: Martin Jansa --- recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb b/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb index fe8a9cc..9139c7f 100644 --- a/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb +++ b/recipes-sota/ostree-kernel-initramfs/ostree-kernel-initramfs_0.0.1.bb @@ -49,4 +49,5 @@ do_install() { fi } do_install[vardepsexclude] = "KERNEL_VERSION" +INITRAMFS_IMAGE ?= "" do_install[depends] = "virtual/kernel:do_deploy ${@['${INITRAMFS_IMAGE}:do_image_complete', ''][d.getVar('INITRAMFS_IMAGE') == '']}" -- cgit v1.2.3-54-g00ecf