x86/grub2: move grub2 image creation to package

Let the grub2 package take care of creating installable grub2 images,
this will allow creating grub2 images without first calling x86 image
generation recipe. Also as side effect, since those images are now
shared, it'll reduce the number of calling grub-mkimage.

Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
[rebase, adjusted commit title]
Signed-off-by: Paul Spooren <mail@aparcar.org>
This commit is contained in:
Paul Spooren 2020-03-20 00:10:54 -10:00 committed by Daniel Golle
parent e6e1e12dc3
commit 5a5df62d95
3 changed files with 39 additions and 22 deletions

View File

@ -82,6 +82,37 @@ define Host/Configure
$(Host/Configure/Default) $(Host/Configure/Default)
endef endef
define Host/Install
$(call Host/Install/Default)
$(INSTALL_DIR) $(STAGING_DIR_HOST)/lib/grub/grub2-generic
$(STAGING_DIR_HOST)/bin/grub-mkimage \
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
-p /boot/grub \
-O i386-pc \
-c ./files/grub-early.cfg \
-o $(STAGING_DIR_HOST)/lib/grub/grub2-generic/core.img \
at_keyboard biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
$(INSTALL_DIR) $(STAGING_DIR_HOST)/lib/grub/grub2-iso
$(STAGING_DIR_HOST)/bin/grub-mkimage \
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
-p /boot/grub \
-O i386-pc \
-c ./files/grub-early.cfg \
-o $(STAGING_DIR_HOST)/lib/grub/grub2-iso/eltorito.img \
at_keyboard biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial vga
$(INSTALL_DIR) $(STAGING_DIR_HOST)/lib/grub/grub2-legacy
$(STAGING_DIR_HOST)/bin/grub-mkimage \
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
-p /boot/grub \
-O i386-pc \
-c ./files/grub-early.cfg \
-o $(STAGING_DIR_HOST)/lib/grub/grub2-legacy/core.img \
biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga
endef
define Package/grub2/install define Package/grub2/install
$(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-bios-setup $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/grub-bios-setup $(1)/usr/sbin/

View File

@ -9,8 +9,7 @@ include $(INCLUDE_DIR)/image.mk
export PATH=$(TARGET_PATH):/sbin export PATH=$(TARGET_PATH):/sbin
GRUB2_MODULES = biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial test vga GRUB2_VARIANT =
GRUB2_MODULES_ISO = biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial test vga
GRUB_TERMINALS = GRUB_TERMINALS =
GRUB_SERIAL_CONFIG = GRUB_SERIAL_CONFIG =
GRUB_TERMINAL_CONFIG = GRUB_TERMINAL_CONFIG =
@ -19,8 +18,9 @@ GRUB_CONSOLE_CMDLINE =
USE_ATKBD = generic 64 USE_ATKBD = generic 64
ifneq ($(strip $(foreach subtarget,$(USE_ATKBD),$(CONFIG_TARGET_x86_$(subtarget)))),) ifneq ($(strip $(foreach subtarget,$(USE_ATKBD),$(CONFIG_TARGET_x86_$(subtarget)))),)
GRUB2_MODULES += at_keyboard GRUB2_VARIANT := generic
GRUB2_MODULES_ISO += at_keyboard else
GRUB2_VARIANT := legacy
endif endif
ifneq ($(CONFIG_GRUB_CONSOLE),) ifneq ($(CONFIG_GRUB_CONSOLE),)
@ -63,14 +63,9 @@ ifneq ($(CONFIG_GRUB_IMAGES),)
rm -fR $(KDIR)/root.grub $(KDIR)/grub2 rm -fR $(KDIR)/root.grub $(KDIR)/grub2
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
grub-mkimage \ $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img \
-p /boot/grub \ $(STAGING_DIR_HOST)/lib/grub/grub2-$(strip $(GRUB2_VARIANT))/core.img \
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \ $(KDIR)/grub2/
-o $(KDIR)/root.grub/boot/grub/core.img \
-O i386-pc \
-c ./grub-early.cfg \
$(GRUB2_MODULES)
$(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/root.grub/boot/grub/
echo '(hd0) $(BIN_DIR)/$(IMG_COMBINED)-$(1).img' > $(KDIR)/grub2/device.map echo '(hd0) $(BIN_DIR)/$(IMG_COMBINED)-$(1).img' > $(KDIR)/grub2/device.map
sed \ sed \
-e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \ -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \
@ -98,16 +93,7 @@ define Image/Build/iso
rm -fR $(KDIR)/root.grub $(KDIR)/grub2 rm -fR $(KDIR)/root.grub $(KDIR)/grub2
$(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2 $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
$(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
grub-mkimage \ $(STAGING_DIR_HOST)/lib/grub/grub2-iso/eltorito.img \
-p /boot/grub \
-d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
-o $(KDIR)/grub2/eltorito.img \
-O i386-pc \
-c ./grub-early.cfg \
$(GRUB2_MODULES_ISO)
cat \
$(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \
$(KDIR)/grub2/eltorito.img \
> $(KDIR)/root.grub/boot/grub/eltorito.img > $(KDIR)/root.grub/boot/grub/eltorito.img
sed \ sed \
-e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \ -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \