From 39aa2586e8cce1ba5e76d09e0102613097fd5eff Mon Sep 17 00:00:00 2001
From: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
Date: Thu, 10 Sep 2015 15:00:54 +0200
Subject: [PATCH] grub: move early config to a (built-in) memdisk

This allows us to execute the early config in normal mode and thus,
we can use things like "if" etc.
---
 Makefile | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b92875b..eb7c2c3 100644
--- a/Makefile
+++ b/Makefile
@@ -435,11 +435,21 @@ $(IMAGE_PART_FILE):
 	@echo
 	@echo "Image partition skeleton is ready: $@"
 
+image_grub_memdisk: $(GRUB_ASSEMBLE_DIR)/memdisk.tar
+$(GRUB_ASSEMBLE_DIR)/memdisk.tar:
+	mkdir -p "$(GRUB_ASSEMBLE_DIR)"
+	tar cvf "$@" -C "$(CURDIR)/contrib/image/" "grub_early.cfg"
+
 image_grub_mkimage_efi: $(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi
-$(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi $(GRUB_ASSEMBLE_DIR)/grub.i386-efi : $(GRUB_ASSEMBLE_DIR)/grub.%-efi : | $(WORKSPACE)
+$(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi $(GRUB_ASSEMBLE_DIR)/grub.i386-efi : $(GRUB_ASSEMBLE_DIR)/grub.%-efi : $(GRUB_ASSEMBLE_DIR)/memdisk.tar | $(WORKSPACE)
 	mkdir -p "$(GRUB_ASSEMBLE_DIR)"
-	grub-mkimage --config "$(CURDIR)/contrib/image/grub_early.cfg" \
+	echo "normal (memdisk)/grub_early.cfg" \
+		> "$(GRUB_ASSEMBLE_DIR)/grub_pre_normal.cfg"
+	grub-mkimage  \
+		--memdisk "$(GRUB_ASSEMBLE_DIR)/memdisk.tar" \
 		--output "$@" --format "$*-efi" \
+		--config "$(GRUB_ASSEMBLE_DIR)/grub_pre_normal.cfg" \
+		--prefix "/grub" \
 		$(IMAGE_GRUB_EFI_MODULES)
 
 image_grub_mkimage_mbr: $(GRUB_ASSEMBLE_DIR)/grub.i386-pc
-- 
GitLab