Skip to content

Commit 8762230

Browse files
authored
Merge pull request #53 from kairos-io/622-copy-grub-config
Copy our grub config in place
2 parents 0e9d3b6 + df7e436 commit 8762230

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

tools-image/build-arm-image.sh

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ load_vars() {
1616
oem_size="${OEM_SIZE:-64}"
1717
recovery_size="${RECOVERY_SIZE:-2192}"
1818
default_active_size="${DEFAULT_ACTIVE_SIZE:-2400}"
19+
menu_entry="${DEFAULT_MENU_ENTRY:-Kairos}"
1920

2021
## Repositories
2122
final_repo="${FINAL_REPO:-quay.io/costoolkit/releases-teal-arm64}"
@@ -287,6 +288,12 @@ else
287288
rsync -axq --exclude='host' --exclude='mnt' --exclude='proc' --exclude='sys' --exclude='dev' --exclude='tmp' ${directory}/ $TARGET
288289
fi
289290

291+
# We copy the grubmenu.cfg to a temporary location to be copied later in the state partition
292+
# https://github.com/kairos-io/kairos/blob/62c67e3e61d49435c362014522e5c6696335376f/overlay/files/system/oem/08_grub.yaml#L105
293+
# This is a hack and we need a better way: https://github.com/kairos-io/kairos/issues/1427
294+
tmpgrubconfig=$(mktemp /tmp/grubmeny.cfg.XXXXXX)
295+
cp -rfv $TARGET/etc/kairos/branding/grubmenu.cfg "${tmpgrubconfig}"
296+
290297
umount $TARGET
291298
sync
292299

@@ -332,6 +339,8 @@ if [ -n "$EFI" ] && [ -n "$efi_dir" ]; then
332339
cp -rfv $efi_dir/* $EFI
333340
fi
334341

342+
partprobe
343+
335344
echo ">> Writing image and partition table"
336345
dd if=/dev/zero of="${output_image}" bs=1024000 count="${size}" || exit 1
337346
if [ "$model" == "rpi64" ]; then
@@ -419,7 +428,10 @@ mkdir -p $WORKDIR/persistent/cloud-config
419428

420429
cp -rfv /defaults.yaml $WORKDIR/persistent/cloud-config/01_defaults.yaml
421430

422-
grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=Kairos"
431+
grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=$menu_entry"
432+
433+
# We copy the file we saved earier to the STATE partition
434+
cp -rfv "${tmpgrubconfig}" $WORKDIR/state/grubmenu
423435

424436
# Set a OEM config file if specified
425437
if [ -n "$config" ]; then

tools-image/prepare_arm_images.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ size="${SIZE:-7544}"
2020
state_size="${STATE_SIZE:-4992}"
2121
recovery_size="${RECOVERY_SIZE:-2192}"
2222
default_active_size="${DEFAULT_ACTIVE_SIZE:-2400}"
23+
menu_entry="${DEFAULT_MENU_ENTRY:-Kairos}"
2324

2425
container_image="${container_image:-quay.io/kairos/kairos-opensuse-leap-arm-rpi:v1.5.1-k3sv1.25.6-k3s1}"
2526

@@ -67,6 +68,12 @@ else
6768
rsync -axq --exclude='host' --exclude='mnt' --exclude='proc' --exclude='sys' --exclude='dev' --exclude='tmp' ${directory}/ $TARGET
6869
fi
6970

71+
# We copy the grubmenu.cfg to a temporary location to be copied later in the state partition
72+
# https://github.com/kairos-io/kairos/blob/62c67e3e61d49435c362014522e5c6696335376f/overlay/files/system/oem/08_grub.yaml#L105
73+
# This is a hack and we need a better way: https://github.com/kairos-io/kairos/issues/1427
74+
tmpgrubconfig=$(mktemp /tmp/grubmeny.cfg.XXXXXX)
75+
cp -rfv $TARGET/etc/kairos/branding/grubmenu.cfg "${tmpgrubconfig}"
76+
7077
umount $TARGET
7178
sync
7279

@@ -106,7 +113,11 @@ LOOP=$(losetup --show -f state_partition.img)
106113
mkdir -p $WORKDIR/state
107114
mount $LOOP $WORKDIR/state
108115
cp -arf $STATEDIR/* $WORKDIR/state
109-
grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=Kairos"
116+
grub2-editenv $WORKDIR/state/grub_oem_env set "default_menu_entry=$menu_entry"
117+
118+
# We copy the file we saved earier to the STATE partition
119+
cp -rfv "${tmpgrubconfig}" $WORKDIR/state/grubmenu
120+
110121
umount $WORKDIR/state
111122
losetup -d $LOOP
112123

0 commit comments

Comments
 (0)