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.
This commit is contained in:
Tobias Waldekranz
2023-08-25 10:51:45 +02:00
committed by Joachim Wiberg
parent c08fe9f522
commit 73f991081c
3 changed files with 104 additions and 18 deletions
+54 -1
View File
@@ -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
+26 -8
View File
@@ -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 <<EOF
image efi-part.vfat {
size = $bootsize
@@ -102,6 +102,17 @@ EOF
EOF
)
elif [ -f "$bootdata" ]; then
bootpart=$(cat <<EOF
partition boot {
offset = $bootoffs
partition-type-uuid = U
bootable = true
image = $bootdata
size = $bootsize
}
EOF
)
fi
}
@@ -110,15 +121,22 @@ root=$BUILD_DIR/genimage.root
tmp=$BUILD_DIR/genimage.tmp
total=$((512 << M))
bootoffs=
bootoffs=$((32 << K))
bootdata=
bootimg=
bootpart=
while getopts "a:s:" opt; do
while getopts "a:b:B:s:" opt; do
case ${opt} in
a)
arch=$OPTARG
;;
b)
bootdata=$OPTARG
;;
B)
bootoffs=$(($OPTARG))
;;
s)
total=$(size2int $OPTARG)
;;
@@ -157,7 +175,7 @@ awk \
mkdir -p $root/aux
cp -f $BINARIES_DIR/rootfs.itbh $root/aux/primary.itbh
cp -f $BINARIES_DIR/rootfs.itbh $root/aux/secondary.itbh
cp -f $BUILD_DIR/mkrauc/rauc.status $root/aux/rauc.status
cp -f $BINARIES_DIR/rauc.status $root/aux/rauc.status
case "$arch" in
aarch64)
+24 -9
View File
@@ -5,6 +5,7 @@ common=$(dirname "$(readlink -f "$0")")
load_cfg BR2_ARCH
load_cfg BR2_DEFCONFIG
load_cfg BR2_EXTERNAL_INFIX_PATH
load_cfg BR2_TARGET_ROOTFS
NAME=infix-$(basename "$BR2_DEFCONFIG" _defconfig | tr _ - | sed 's/x86-64/x86_64/')
ver()
@@ -28,11 +29,23 @@ if [ "$SIGN_ENABLED" = "y" ]; then
fi
load_cfg DISK_IMAGE
load_cfg DISK_IMAGE_SIZE
if [ "$DISK_IMAGE" = "y" ]; then
ixmsg "Creating Disk Image"
bootcfg=
if [ "$DISK_IMAGE_BOOT_DATA" ]; then
bootcfg="-b $DISK_IMAGE_BOOT_DATA -B $DISK_IMAGE_BOOT_OFFSET"
fi
if [ "$BR2_TARGET_ROOTFS_SQUASHFS" != "y" ] && \
[ ! -f "$BINARIES_DIR/rootfs.squashfs" ]; then
ixmsg " Injecting $DISK_IMAGE_RELEASE_URL"
archive="$BINARIES_DIR/$(basename $DISK_IMAGE_RELEASE_URL)"
[ -f "$archive" ] || wget -O"$archive" "$DISK_IMAGE_RELEASE_URL"
tar -xa --strip-components=1 -C "$BINARIES_DIR" -f "$archive"
fi
$common/mkrauc-status.sh "$BINARIES_DIR/${NAME}.pkg" >"$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