ls
)
+GRUB_EFI_MODULES=(
+ "disk"
+ "iso9660"
+ "search"
+)
+
+make_label() {
+ echo "BL_$(date -u "+%Y%m%d%H%M")"
+}
+
allocate_file() {
local path="${1}"
local size="${2}"
return 0
}
+make_grub_efi_config() {
+ local label="${1}"
+
+ echo "search.fs_label \"${label}\" root"
+ echo "set prefix=(\$root)/EFI/BOOT"
+}
+
make_grub_efi_image() {
local path="${1}"
+ local label="${2}"
local grub_efi_arch="${arch}"
esac
# Allocate file
- if ! allocate_file "${path}" 2880; then
+ if ! allocate_file "${path}" 1440; then
return 1
fi
fi
local tempdir="$(mktemp -d)"
+ local config="$(mktemp)"
# Mount the disk
if ! mount -o loop "${path}" "${tempdir}"; then
mkdir -p "${tempdir}/EFI/BOOT"
+ # Write early GRUB configuration
+ make_grub_efi_config "${label}" > "${config}"
+
# Generate a GRUB image
- if ! in_buildsystem --bind="${tempdir}" \
- grub-mkstandalone \
+ if ! in_buildsystem --bind="${tempdir}" --bind="${config}" \
+ grub-mkimage \
--format="${arch}-efi" \
+ --prefix="/EFI/BOOT" \
--output="${tempdir}/EFI/BOOT/boot${grub_efi_arch}.efi" \
- --fonts="" --locales="" --themes=""; then
+ --config="${config}" \
+ "${GRUB_EFI_MODULES[@]}"; then
echo "Could not generate GRUB EFI image" >&2
umount "${tempdir}"
- rm -rf "${tempdir}"
+ rm -rf "${tempdir}" "${config}"
return 1
fi
if ! umount "${tempdir}"; then
- rm -rf "${tempdir}"
+ rm -rf "${tempdir}" "${config}"
return 1
fi
+ rm -rf "${tempdir}" "${config}"
+
return 0
}
# Generate GRUB EFI image
if [ "${has_efi_boot}" = "true" ]; then
- if ! make_grub_efi_image "${tempdir}/boot/efiboot.img"; then
+ if ! make_grub_efi_image "${tempdir}/boot/efiboot.img" "${label}"; then
rm -rf "${tempdir}"
return 1
fi