Grow EFI image before syncing GRUB theme assets
This commit is contained in:
@@ -876,6 +876,26 @@ copy_file_to_fat_image() {
|
||||
mcopy -o -i "$img" "$src" "$dst" >/dev/null
|
||||
}
|
||||
|
||||
grow_efi_grub_fat_image() {
|
||||
img="$1"
|
||||
tmpdir="$(mktemp -d)"
|
||||
newimg="$(mktemp "${img##*/}.XXXXXX")"
|
||||
|
||||
current_size="$(wc -c < "$img" | tr -d '[:space:]')"
|
||||
[ -n "$current_size" ] || current_size=0
|
||||
extra_bytes=$((2 * 1024 * 1024))
|
||||
new_size=$((current_size + extra_bytes))
|
||||
|
||||
# Recreate the FAT image with extra headroom and copy the original payload
|
||||
# back in before injecting the larger GRUB theme assets.
|
||||
mcopy -s -i "$img" :: "$tmpdir" >/dev/null
|
||||
truncate -s "$new_size" "$newimg"
|
||||
mformat -i "$newimg" -F :: >/dev/null
|
||||
mcopy -s -i "$newimg" "$tmpdir"/* :: >/dev/null
|
||||
mv "$newimg" "$img"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
sync_efi_grub_theme_assets() {
|
||||
lb_dir="$1"
|
||||
found=0
|
||||
@@ -886,11 +906,17 @@ sync_efi_grub_theme_assets() {
|
||||
fi
|
||||
found=1
|
||||
echo "bootloader sync: patching EFI GRUB image $img"
|
||||
grow_efi_grub_fat_image "$img"
|
||||
mmd -i "$img" "::/boot" >/dev/null 2>&1 || true
|
||||
mmd -i "$img" "::/boot/grub" >/dev/null 2>&1 || true
|
||||
mmd -i "$img" "::/boot/grub/live-theme" >/dev/null 2>&1 || true
|
||||
|
||||
copy_file_to_fat_image "$img" "${BUILDER_DIR}/config/bootloaders/grub-efi/config.cfg" "::/boot/grub/config.cfg"
|
||||
copy_file_to_fat_image "$img" "${BUILDER_DIR}/config/bootloaders/grub-efi/theme.cfg" "::/boot/grub/theme.cfg"
|
||||
for asset in "${BUILDER_DIR}"/config/bootloaders/grub-efi/live-theme/*; do
|
||||
[ -f "$asset" ] || continue
|
||||
copy_file_to_fat_image "$img" "$asset" "::/boot/grub/live-theme/"
|
||||
done
|
||||
|
||||
fat_image_has_file "$img" "::/boot/grub/config.cfg" || {
|
||||
echo "ERROR: EFI GRUB image missing /boot/grub/config.cfg after sync: $img" >&2
|
||||
@@ -900,6 +926,14 @@ sync_efi_grub_theme_assets() {
|
||||
echo "ERROR: EFI GRUB image missing /boot/grub/theme.cfg after sync: $img" >&2
|
||||
exit 1
|
||||
}
|
||||
fat_image_has_file "$img" "::/boot/grub/live-theme/theme.txt" || {
|
||||
echo "ERROR: EFI GRUB image missing /boot/grub/live-theme/theme.txt after sync: $img" >&2
|
||||
exit 1
|
||||
}
|
||||
fat_image_has_file "$img" "::/boot/grub/live-theme/bee-logo.tga" || {
|
||||
echo "ERROR: EFI GRUB image missing /boot/grub/live-theme/bee-logo.tga after sync: $img" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
if [ "$found" != "1" ]; then
|
||||
|
||||
Reference in New Issue
Block a user