package/mender-grubenv: fix installation with genimage.sh script
PATCH v2 1/1 package/mender-grubenv: fix installation with genimage.sh script
From: Adam Duskett <[email protected]>
mender-grubenv currently has 3 problems that prevent an x86_64-efi image from successfully being made with the genimage.sh script.
- mender-grubenv does not currently depend on Grub2.
While Grub2 is not needed to build the mender-grubenv package, Grub2 needs to be built first for mender-grubenv to overwrite the default Grub2 files reliably.
- The MENDER_GRUBENV_ENV_DIR variable points to /boot/efi/EFI/BOOT instead of /boot/EFI/BOOT, which is where the Grub2 package installs the default files. This variable now points to the correct location.
- The Grub2 package installs images to $(BINARIES_DIR)/efi-part, which the mender-grubenv package currently does not do. As such; the default Grub2 configuration file is used instead of the one provided by mender-grubenv. Adding a MENDER_GRUBENV_INSTALL_IMAGES_CMDS define in mender-grubenv.mk which copies the installed files from $(TARGET_DIR)/boot/EFI to $(BINARIES_DIR)/efi-part fixes this issue.
--- package/mender-grubenv/mender-grubenv.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
package/mender-grubenv/mender-grubenv.mk +11 -1
@@ -8,11 +8,15 @@ MENDER_GRUBENV_VERSION = 1.3.0 MENDER_GRUBENV_SITE = $(call github,mendersoftware,grub-mender-grubenv,$(MENDER_GRUBENV_VERSION)) MENDER_GRUBENV_LICENSE = Apache-2.0 MENDER_GRUBENV_LICENSE_FILES = LICENSE +# Grub2 must be built first so this package can overwrite the config files +# provided by grub. +MENDER_GRUBENV_DEPENDENCIES = grub2 +MENDER_GRUBENV_INSTALL_IMAGES = YES ifeq ($(BR2_TARGET_GRUB2_I386_PC)$(BR2_TARGET_GRUB2_ARM_UBOOT),y) MENDER_GRUBENV_ENV_DIR = /boot/grub else -MENDER_GRUBENV_ENV_DIR = /boot/efi/EFI/BOOT +MENDER_GRUBENV_ENV_DIR = /boot/EFI/BOOT endif MENDER_GRUBENV_MAKE_ENV = \
@@ -50,4 +54,10 @@ define MENDER_GRUBENV_INSTALL_TARGET_CMDS $(MENDER_GRUBENV_MAKE_ENV) $(MAKE) DESTDIR=$(TARGET_DIR) -C $(@D) install endef +# Overwrite the default grub2 config files with the ones in this package. +define MENDER_GRUBENV_INSTALL_IMAGES_CMDS + mkdir -p $(dir $(GRUB2_IMAGE)) + cp -dpfr $(TARGET_DIR)/boot/EFI $(BINARIES_DIR)/efi-part +endef + $(eval $(generic-package))
Signature · 1 line
2.21.0
PATCH v2 1/1 board/mender: add a mender board example configuration.
From: Adam Duskett <[email protected]>
Buildroot currently has all of the needed packages to use Mender as the primary update system. However; there isn't any documentation or examples now that provide a starting point for users. This lack of documentation makes setting up a Mender based update system difficult and time-consuming.
Provided in this patch series is a mender_x86_64_efi_defconfig -that sets up an x86_64 EFI based build that is ready to flash to a USB pen drive or use in a QEMU environment. The system partition schema comprises of two equally sized root partitions and a 32M data partition that is mounted to /var/lib/mender as a persistent data store partition.
There is a board/mender/readme.txt provided which gives users documentation on how to flash the built image or boot the image using QEMU as well.
---
Changes v1 -> v2:
- Remove uneeded entries in board/mender/overlays/etc/fstab
- Rename post-image-efi-gpt.sh to post-image-efi.sh
- Rename pre-image.sh to post-build.sh to keep with standard naming conventions.
- Check if /var/lib/mender is a symlink, and if so; remove it and create a directory in its place. This change prevents the mender init script from doing the same thing and preventing the data partition from mounting correctly on the initial boot.
- Make creating a mender artifact optional after the build.
- Add more documentation in board/mender/readme.txt.
- Add genimage-efi.cfg [Thomas]
- Use genimage.sh instead of the old-style found in board/pc/post-image-efi-gpt.sh (Thomas)
.gitlab-ci.yml | 1 + DEVELOPERS | 1 + board/mender/genimage-efi.cfg | 49 ++++++++++++++ board/mender/linux.config | 64 ++++++++++++++++++ board/mender/mender_grubenv_defines | 32 +++++++++ board/mender/overlay/etc/fstab | 7 ++ board/mender/overlay/etc/mender/mender.conf | 10 +++ board/mender/post-build.sh | 14 ++++ board/mender/post-image-efi.sh | 20 ++++++ board/mender/readme.txt | 65 ++++++++++++++++++ configs/mender_x86_64_efi_defconfig | 74 +++++++++++++++++++++ 11 files changed, 337 insertions(+) create mode 100644 board/mender/genimage-efi.cfg create mode 100644 board/mender/linux.config create mode 100644 board/mender/mender_grubenv_defines create mode 100644 board/mender/overlay/etc/fstab create mode 100644 board/mender/overlay/etc/mender/mender.conf create mode 100755 board/mender/post-build.sh create mode 100755 board/mender/post-image-efi.sh create mode 100644 board/mender/readme.txt create mode 100644 configs/mender_x86_64_efi_defconfig
.gitlab-ci.yml +1 -0
@@ -203,6 +203,7 @@ imx8mpico_defconfig: { extends: .defconfig } lego_ev3_defconfig: { extends: .defconfig } licheepi_zero_defconfig: { extends: .defconfig } linksprite_pcduino_defconfig: { extends: .defconfig } +mender_x86_64_efi_defconfig: { extends: .defconfig } minnowboard_max-graphical_defconfig: { extends: .defconfig } minnowboard_max_defconfig: { extends: .defconfig } mx25pdk_defconfig: { extends: .defconfig }
DEVELOPERS +1 -0
@@ -27,6 +27,7 @@ # modify packages that use this infrastructure. N: Adam Duskett <[email protected]> +F: configs/mender_x86_64_efi_defconfig F: package/audit/ F: package/busybox/ F: package/checkpolicy/
board/mender/genimage-efi.cfg new file +49 -0
49 lines not on this page · raw message
board/mender/linux.config new file +64 -0
64 lines not on this page · raw message
board/mender/mender_grubenv_defines new file +32 -0
@@ -0,0 +1,32 @@ +################################################################################ +# Mandatory +################################################################################ +# Warning: This file is an example and should be customized to fit your needs! + +# Partition index of root filesystem A +mender_rootfsa_part=2 + +# Partition index of root filesystem B +mender_rootfsb_part=3 + +# Device file corresponding to the root filesystem partitions, without index. +mender_kernel_root_base=/dev/vda + +# Name of the storage device containing root filesystem partitions in GRUB +# format. +mender_grub_storage_device=hd0 + +# Type of kernel (bzImage or zImage) +kernel_imagetype=bzImage + +# Type of initrd image. +# Note: An initrd image is not strictly necessary, and the system will boot and +# update without a initrd image. +initrd_imagetype=initrd.img + +################################################################################ +# Mandatory on ARM +################################################################################ + +# Basename of DTB that should be loaded by the bootloader. +# kernel_devicetree=kernel.dtb
board/mender/overlay/etc/fstab new file +7 -0
@@ -0,0 +1,7 @@ +# <file system> <mount pt> <type> <options> <dump> <pass> +/dev/vda1 /boot/EFI vfat defaults 0 0 +/dev/vda4 /var/lib/mender vfat defaults,user 0 0 +/dev/root / ext4 rw,noauto 0 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0 +sysfs /sys sysfs defaults 0 0
board/mender/overlay/etc/mender/mender.conf new file +10 -0
@@ -0,0 +1,10 @@ +{ + "InventoryPollIntervalSeconds": 1800, + "UpdatePollIntervalSeconds": 1800, + "RetryPollIntervalSeconds": 300, + "RootfsPartA": "/dev/vda2", + "RootfsPartB": "/dev/vda3", + "ServerCertificate": "/etc/mender/server.crt", + "ServerURL": "https://docker.mender.io", + "TenantToken": "dummy" +}
board/mender/post-build.sh new file +14 -0
@@ -0,0 +1,14 @@ +#!/bin/sh -e +cd ${TARGET_DIR} + +# Create a persistent directory to mount the data partition at. +if [[ -L var/lib/mender ]]; then + rm var/lib/mender + mkdir -p var/lib/mender +fi + +# The common paradigm is to have the persistent data volume at /data for mender. +if [[ ! -L data ]]; then + ln -s var/lib/mender data +fi +
board/mender/post-image-efi.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/bash + +mkdir -p ${BINARIES_DIR}/data-part/ +echo "device_type=buildroot" > ${BINARIES_DIR}/data-part/device_type +sh support/scripts/genimage.sh $2 board/mender/genimage-efi.cfg + +function create_mender_image(){ + echo "Creating ${BINARIES_DIR}/${1}" + ${HOST_DIR}/bin/mender-artifact \ + --compression lzma \ + write rootfs-image \ + -t BUILDROOT_DEVICE \ + -n ${BR2_VERSION} \ + -f ${BINARIES_DIR}/rootfs.ext2 \ + -o ${BINARIES_DIR}/${1} +} + +# Uncomment this line to generate a mender artifact after the image is built. +# create_mender_image "update-${BR2_VERSION}.mender"
board/mender/readme.txt new file +64 -0
64 lines not on this page · raw message
configs/mender_x86_64_efi_defconfig new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.21.0
Thomas Petazzoni
AppliedPATCH v2 1/1 package/mender-grubenv: fix installation with genimage.sh script
In reply to aduskett at gmail.comQuoted 21 lines · On Mon, 2 Sep 2019 15:34:41 -0700 aduskett at gmail.com wrote:
From: Adam Duskett <[email protected]>
mender-grubenv currently has 3 problems that prevent an x86_64-efi image from successfully being made with the
genimage.shscript.- mender-grubenv does not currently depend on Grub2.
While Grub2 is not needed to build the mender-grubenv package, Grub2 needs to be built first for mender-grubenv to overwrite the default Grub2 files reliably.- The
MENDER_GRUBENV_ENV_DIRvariable points to/boot/efi/EFI/BOOTinstead of/boot/EFI/BOOT, which is where the Grub2 package installs the default files. This variable now points to the correct location.- The Grub2 package installs images to $(BINARIES_DIR)/efi-part, which the mender-grubenv package currently does not do. As such; the default Grub2 configuration file is used instead of the one provided by mender-grubenv. Adding a
MENDER_GRUBENV_INSTALL_IMAGES_CMDSdefine in mender-grubenv.mk which copies the installed files from $(TARGET_DIR)/boot/EFI to $(BINARIES_DIR)/efi-part fixes this issue.
Quoted 4 lines
Signed-off-by Adam Duskett <[email protected]>--- package/mender-grubenv/mender-grubenv.mk | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Applied to master with the following changes:
[Thomas:
- drop "runtime" on the depends on BR2_TARGET_GRUB2 since we now have a build-time dependency on it
- explicitly copy the files installed by mender-grubenv in MENDER_GRUBENV_INSTALL_IMAGES_CMDS instead of blindly copying everything that is in $(TARGET_DIR)/boot/EFI]
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v2 1/1 package/mender-grubenv: fix installation with genimage.sh script
Quoted 31 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni <[email protected]> writes:
Quoted 21 lines · On Mon, 2 Sep 2019 15:34:41 -0700 aduskett at gmail.com wrote:
From: Adam Duskett <[email protected]>
mender-grubenv currently has 3 problems that prevent an x86_64-efi image from successfully being made with the
genimage.shscript.- mender-grubenv does not currently depend on Grub2.
While Grub2 is not needed to build the mender-grubenv package, Grub2 needs to be built first for mender-grubenv to overwrite the default Grub2 files reliably.- The
MENDER_GRUBENV_ENV_DIRvariable points to/boot/efi/EFI/BOOTinstead of/boot/EFI/BOOT, which is where the Grub2 package installs the default files. This variable now points to the correct location.- The Grub2 package installs images to $(BINARIES_DIR)/efi-part, which the mender-grubenv package currently does not do. As such; the default Grub2 configuration file is used instead of the one provided by mender-grubenv. Adding a
MENDER_GRUBENV_INSTALL_IMAGES_CMDSdefine in mender-grubenv.mk which copies the installed files from $(TARGET_DIR)/boot/EFI to $(BINARIES_DIR)/efi-part fixes this issue.Quoted 4 lines
Signed-off-by Adam Duskett <[email protected]>---
package/mender-grubenv/mender-grubenv.mk| 12 +++++++++++-1 file changed, 11 insertions(+), 1 deletion(-)
Quoted 8 lines
Applied to master with the following changes:
[Thomas:
- drop "runtime" on the depends onBR2_TARGET_GRUB2since we now have a build-time dependency on it
- explicitly copy the files installed by mender-grubenv inMENDER_GRUBENV_INSTALL_IMAGES_CMDSinstead of blindly copying everything that is in $(TARGET_DIR)/boot/EFI]
Committed to 2019.11.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard