diff --git a/tools-image/build-arm-image.sh b/tools-image/build-arm-image.sh index 29932e6..ad5c369 100755 --- a/tools-image/build-arm-image.sh +++ b/tools-image/build-arm-image.sh @@ -16,6 +16,7 @@ load_vars() { oem_size="${OEM_SIZE:-64}" recovery_size="${RECOVERY_SIZE:-2192}" default_active_size="${DEFAULT_ACTIVE_SIZE:-2400}" + menu_entry="${DEFAULT_MENU_ENTRY:-Kairos}" ## Repositories final_repo="${FINAL_REPO:-quay.io/costoolkit/releases-teal-arm64}" @@ -287,6 +288,12 @@ else rsync -axq --exclude='host' --exclude='mnt' --exclude='proc' --exclude='sys' --exclude='dev' --exclude='tmp' ${directory}/ $TARGET fi +# We copy the grubmenu.cfg to a temporary location to be copied later in the state partition +# https://github.com/kairos-io/kairos/blob/62c67e3e61d49435c362014522e5c6696335376f/overlay/files/system/oem/08_grub.yaml#L105 +# This is a hack and we need a better way: https://github.com/kairos-io/kairos/issues/1427 +tmpgrubconfig=$(mktemp /tmp/grubmeny.cfg.XXXXXX) +cp -rfv $TARGET/etc/kairos/branding/grubmenu.cfg "${tmpgrubconfig}" + umount $TARGET sync @@ -332,6 +339,8 @@ if [ -n "$EFI" ] && [ -n "$efi_dir" ]; then cp -rfv $efi_dir/* $EFI fi +partprobe + echo ">> Writing image and partition table" dd if=/dev/zero of="${output_image}" bs=1024000 count="${size}" || exit 1 if [ "$model" == "rpi64" ]; then @@ -419,7 +428,10 @@ mkdir -p $WORKDIR/persistent/cloud-config cp -rfv /defaults.yaml $WORKDIR/persistent/cloud-config/01_defaults.yaml -grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=Kairos" +grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=$menu_entry" + +# We copy the file we saved earier to the STATE partition +cp -rfv "${tmpgrubconfig}" $WORKDIR/state/grubmenu # Set a OEM config file if specified if [ -n "$config" ]; then diff --git a/tools-image/prepare_arm_images.sh b/tools-image/prepare_arm_images.sh index d96eea6..1fc0381 100755 --- a/tools-image/prepare_arm_images.sh +++ b/tools-image/prepare_arm_images.sh @@ -20,6 +20,7 @@ size="${SIZE:-7544}" state_size="${STATE_SIZE:-4992}" recovery_size="${RECOVERY_SIZE:-2192}" default_active_size="${DEFAULT_ACTIVE_SIZE:-2400}" +menu_entry="${DEFAULT_MENU_ENTRY:-Kairos}" container_image="${container_image:-quay.io/kairos/kairos-opensuse-leap-arm-rpi:v1.5.1-k3sv1.25.6-k3s1}" @@ -67,6 +68,12 @@ else rsync -axq --exclude='host' --exclude='mnt' --exclude='proc' --exclude='sys' --exclude='dev' --exclude='tmp' ${directory}/ $TARGET fi +# We copy the grubmenu.cfg to a temporary location to be copied later in the state partition +# https://github.com/kairos-io/kairos/blob/62c67e3e61d49435c362014522e5c6696335376f/overlay/files/system/oem/08_grub.yaml#L105 +# This is a hack and we need a better way: https://github.com/kairos-io/kairos/issues/1427 +tmpgrubconfig=$(mktemp /tmp/grubmeny.cfg.XXXXXX) +cp -rfv $TARGET/etc/kairos/branding/grubmenu.cfg "${tmpgrubconfig}" + umount $TARGET sync @@ -106,7 +113,11 @@ LOOP=$(losetup --show -f state_partition.img) mkdir -p $WORKDIR/state mount $LOOP $WORKDIR/state cp -arf $STATEDIR/* $WORKDIR/state -grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=Kairos" +grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=$menu_entry" + +# We copy the file we saved earier to the STATE partition +cp -rfv "${tmpgrubconfig}" $WORKDIR/state/grubmenu + umount $WORKDIR/state losetup -d $LOOP