From 73f991081c110acd3aaa660b2beaf10a85edcd97 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 17 Aug 2023 16:35:26 +0200 Subject: [PATCH] post-image: Allow disk images to be built from downloaded release This is useful when we're only building a bootloader, but we still want to create a full disk image on the format expected by Infix. --- board/common/Config.in | 55 +++++++++++++++++++++++++++++++++++++- board/common/mkdisk.sh | 34 +++++++++++++++++------ board/common/post-image.sh | 33 ++++++++++++++++------- 3 files changed, 104 insertions(+), 18 deletions(-) diff --git a/board/common/Config.in b/board/common/Config.in index cfd945cb..c3e59d34 100644 --- a/board/common/Config.in +++ b/board/common/Config.in @@ -31,7 +31,7 @@ menuconfig DISK_IMAGE - Creating a GNS3 appliance - Developing/debugging issues in the boot process in QEMU -config DISK_IMAGE_SIZE +menuconfig DISK_IMAGE_SIZE string "Image size" depends on DISK_IMAGE default "512M" @@ -44,6 +44,59 @@ config DISK_IMAGE_SIZE Minimum supported size is 512M. +choice + prompt "Bootloader" + depends on DISK_IMAGE + default DISK_IMAGE_BOOT_EFI if BR2_x86_64 + default DISK_IMAGE_BOOT_NONE + +config DISK_IMAGE_BOOT_NONE + bool "None" + help + Do not create any bootloader partition in the disk image. + +config DISK_IMAGE_BOOT_EFI + bool "EFI" + help + Create a boot partition from a directory containing an EFI + boot application, e.g. GRUB. + +config DISK_IMAGE_BOOT_BIN + bool "Binary" + help + Create a boot partition from a raw image containing the boot + application, e.g. U-Boot. + +endchoice + +config DISK_IMAGE_BOOT_DATA + string "Bootloader data" + depends on DISK_IMAGE + depends on DISK_IMAGE_BOOT_EFI || DISK_IMAGE_BOOT_BIN + default "${BINARIES_DIR}/efi-part/EFI" if BR2_x86_64 + help + Path to the directory or file holding the bootloader data. + +config DISK_IMAGE_BOOT_OFFSET + hex "Bootloader offset" + depends on DISK_IMAGE + depends on DISK_IMAGE_BOOT_EFI || DISK_IMAGE_BOOT_BIN + default 0x8000 + help + Offset at which the bootloader partition is placed. Remember + to make sure that the GPT still fits at the start of the + image. + +config DISK_IMAGE_RELEASE_URL + string "Infix URL" + depends on DISK_IMAGE + depends on !BR2_TARGET_ROOTFS_SQUASHFS + default "https://github.com/kernelkit/infix/releases/download/latest/infix-${BR2_ARCH}.tar.gz" + help + In situations where Infix itself is not being built, but a + disk image is, i.e. when building a bootloader: place this + Infix release in the primary and secondary partitions. + menuconfig GNS3_APPLIANCE bool "GNS3 Appliance" select DISK_IMAGE diff --git a/board/common/mkdisk.sh b/board/common/mkdisk.sh index 777a164b..cc99b4a3 100755 --- a/board/common/mkdisk.sh +++ b/board/common/mkdisk.sh @@ -30,14 +30,14 @@ dimension() cfgsize=$((256 << M)) # var is at least ~1.75G elif [ $total -ge $((1 << G)) ]; then - bootsize=$(( 4 << M)) - auxsize=$(( 4 << M)) + bootsize=$(( 8 << M)) + auxsize=$(( 8 << M)) imgsize=$((256 << M)) cfgsize=$(( 64 << M)) # var is at least ~0.5G elif [ $total -ge $((512 << M)) ]; then - bootsize=$(( 4 << M)) - auxsize=$(( 4 << M)) + bootsize=$(( 8 << M)) + auxsize=$(( 8 << M)) imgsize=$((192 << M)) cfgsize=$(( 16 << M)) # var is at least ~100M @@ -80,7 +80,7 @@ probeboot() genboot() { - if [ -d $BINARIES_DIR/efi-part/EFI ]; then + if [ -d "$bootdata" ]; then bootimg=$(cat <"$BINARIES_DIR/rauc.status" - $common/mkdisk.sh -a $BR2_ARCH -s $DISK_IMAGE_SIZE + $common/mkdisk.sh -a $BR2_ARCH -s $DISK_IMAGE_SIZE $bootcfg fi load_cfg GNS3_APPLIANCE @@ -49,12 +62,14 @@ if [ "$FIT_IMAGE" = "y" ]; then $common/mkfit.sh fi -if [ -z "${NAME##*minimal*}" ]; then - NAME=$(echo "$NAME" | sed 's/-minimal//') -fi +if [ "$BR2_TARGET_ROOTFS_SQUASHFS" = "y" ]; then + if [ -z "${NAME##*minimal*}" ]; then + NAME=$(echo "$NAME" | sed 's/-minimal//') + fi -rel=$(ver) -ln -sf rootfs.squashfs "$BINARIES_DIR/${NAME}${rel}.img" -if [ -n "$rel" ]; then - ln -sf "$BINARIES_DIR/${NAME}${rel}.img" "$BINARIES_DIR/${NAME}.img" + rel=$(ver) + ln -sf rootfs.squashfs "$BINARIES_DIR/${NAME}${rel}.img" + if [ -n "$rel" ]; then + ln -sf "$BINARIES_DIR/${NAME}${rel}.img" "$BINARIES_DIR/${NAME}.img" + fi fi