Explorar el Código

add some basic genimage support

Waldemar Brodkorb hace 8 años
padre
commit
3e337374f3

+ 10 - 0
mk/image.mk

@@ -271,5 +271,15 @@ ${FW_DIR}/${ROOTFSISO}: ${TARGET_DIR} kernel-package
 		-c boot/syslinux/boot.cat -no-emul-boot \
 		-boot-load-size 4 -boot-info-table ${TARGET_DIR}
 
+${FW_DIR}/${GENIMAGE}: ${TARGET_DIR} kernel-package
+	rm -rf ${FW_DIR}/temp
+	mkdir -p ${FW_DIR}/temp
+	PATH='${HOST_PATH}' genimage \
+		--config "$(ADK_TOPDIR)/target/$(ADK_TARGET_CPU_ARCH)/$(ADK_TARGET_SYSTEM)/genimage.cfg" \
+		--tmppath "${FW_DIR}/temp" \
+		--rootpath "$(TARGET_DIR)" \
+		--inputpath "$(FW_DIR)" \
+		--outputpath "$(FW_DIR)"
+
 imageclean:
 	rm -f $(FW_DIR)/$(ADK_TARGET_SYSTEM)-* ${BUILD_DIR}/$(ADK_TARGET_SYSTEM)-*

+ 1 - 0
mk/rootfs.mk

@@ -64,5 +64,6 @@ $(eval $(call rootfs_template,jffs2,JFFS2,$(MTDDEV) rootfstype=jffs2))
 $(eval $(call rootfs_template,nfsroot,NFSROOT,root=/dev/nfs ip=dhcp))
 $(eval $(call rootfs_template,encrypted,ENCRYPTED))
 $(eval $(call rootfs_template,iso,ISO))
+$(eval $(call rootfs_template,genimage,GENIMAGE))
 
 export ADK_TARGET_FS

+ 52 - 6
package/grub/Makefile

@@ -19,17 +19,52 @@ PKG_ARCH_DEPENDS:=	x86 x86_64
 PKG_SUBPKGS:=		GRUB GRUB_TOOLS
 PKGSD_GRUB_TOOLS:=	grub2 tools
 
-PKG_CHOICES_GRUB:=	PC EFI
+PKG_CHOICES_GRUB:=	PC EFI_X86 EFI_X86_64
 PKGCD_PC:=		build for PC BIOS
-PKGCD_EFI:=		build for EFI
+PKGCD_EFI_X86:=		build for EFI x86
+PKGCD_EFI_X86_64:=	build for EFI x86_64
 
+include $(ADK_TOPDIR)/mk/host.mk
 include $(ADK_TOPDIR)/mk/package.mk
 
+$(eval $(call HOST_template,GRUB,grub,$(PKG_VERSION)-${PKG_RELEASE}))
 $(eval $(call PKG_template,GRUB,grub,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))
 $(eval $(call PKG_template,GRUB_TOOLS,grub-tools,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))
 
-TARGET_CFLAGS:=          $(filter-out -fstack-protector-all,$(TARGET_CFLAGS))
-TARGET_CFLAGS:=          $(filter-out -flto,$(TARGET_CFLAGS))
+TARGET_CFLAGS:=$(filter-out -fstack-protector-all,$(TARGET_CFLAGS))
+TARGET_CFLAGS:=$(filter-out -flto,$(TARGET_CFLAGS))
+
+GRUB2_BOOT_PARTITION:=	hd0,msdos1
+
+ifeq ($(ADK_PACKAGE_GRUB_PC),y)
+GRUB2_IMAGE = $(FW_DIR)/grub.img
+GRUB2_CFG = $(TARGET_DIR)/boot/grub/grub.cfg
+GRUB2_PREFIX = ($(GRUB2_BOOT_PARTITION))/boot/grub
+GRUB2_TUPLE = i386-pc
+GRUB2_TARGET = i386
+GRUB2_PLATFORM = pc
+GRUB2_MODULES = boot linux ext2 fat part_msdos part_gpt normal biosdisk
+endif
+
+ifeq ($(ADK_PACKAGE_GRUB_EFI_X86),y)
+GRUB2_IMAGE = $(FW_DIR)/efi-part/EFI/BOOT/bootia32.efi
+GRUB2_CFG = $(FW_DIR)/efi-part/EFI/BOOT/grub.cfg
+GRUB2_PREFIX = /EFI/BOOT
+GRUB2_TUPLE = i386-efi
+GRUB2_TARGET = i386
+GRUB2_PLATFORM = efi
+GRUB2_MODULES = boot linux ext2 fat part_msdos part_gpt normal efi_gop
+endif
+
+ifeq ($(ADK_PACKAGE_GRUB_EFI_X86_64),y)
+GRUB2_IMAGE = $(FW_DIR)/efi-part/EFI/BOOT/bootx64.efi
+GRUB2_CFG = $(FW_DIR)/efi-part/EFI/BOOT/grub.cfg
+GRUB2_PREFIX = /EFI/BOOT
+GRUB2_TUPLE = x86_64-efi
+GRUB2_TARGET = x86_64
+GRUB2_PLATFORM = efi
+GRUB2_MODULES = boot linux ext2 fat part_msdos part_gpt normal efi_gop
+endif
 
 # core.img is generated via
 # grub-mkimage -O ${GRUB_ARCH} -o core.img -c embed.cfg ${GRUB_MODULES}
@@ -39,7 +74,7 @@ ifeq ($(ADK_PACKAGE_GRUB_PC),y)
 GRUB_ARCH:=		i386-pc
 CONFIGURE_ARGS+=	--with-platform=pc
 endif
-ifeq ($(ADK_PACKAGE_GRUB_EFI),y)
+ifeq ($(ADK_PACKAGE_GRUB_EFI_X86)$(ADK_PACKAGE_GRUB_EFI_X86_64),y)
 GRUB_ARCH:=		x86_64-efi
 CONFIGURE_ARGS+=	--with-platform=efi
 endif
@@ -55,8 +90,18 @@ grub-install:
 	${INSTALL_DIR} $(IDIR_GRUB)/boot/grub/${GRUB_ARCH}
 	${CP} ${WRKINST}/usr/lib/grub/${GRUB_ARCH}/*{mod,lst,img} \
 		$(IDIR_GRUB)/boot/grub/${GRUB_ARCH}/
-	-${CP} ./files/core.img.${GRUB_ARCH} \
+	$(STAGING_HOST_DIR)/usr/bin/grub-mkimage \
+		-d $(STAGING_HOST_DIR)/usr/lib/grub/$(GRUB2_TUPLE) \
+		-O $(GRUB2_TUPLE) \
+		-o $(GRUB2_IMAGE) \
+		-p "$(GRUB2_PREFIX)" \
+		$(GRUB2_MODULES)
+ifeq ($(ADK_PACKAGE_GRUB_PC),y)
+	$(CP) ./files/core.img.${GRUB_ARCH} \
 		$(IDIR_GRUB)/boot/grub/core.img
+	$(CP) $(WRKINST)/usr/lib/grub/i386-pc/boot.img \
+		$(FW_DIR)/
+endif
 
 grub-tools-install:
 	${INSTALL_DIR} $(IDIR_GRUB_TOOLS)/usr/{sbin,bin,share,lib}
@@ -77,4 +122,5 @@ grub-tools-install:
 	${CP} ${WRKINST}/usr/share/grub \
 		$(IDIR_GRUB_TOOLS)/usr/share
 
+include ${ADK_TOPDIR}/mk/host-bottom.mk
 include ${ADK_TOPDIR}/mk/pkg-bottom.mk

+ 7 - 0
target/config/Config.in.rootfs

@@ -150,6 +150,13 @@ config ADK_TARGET_ROOTFS_ARCHIVE
 	help
 	  Use this option if your root filesystem is ext2/ext3/ext4/xfs.
 
+config ADK_TARGET_ROOTFS_GENIMAGE
+	bool "Create a disk image for the target"
+	select ADK_KERNEL_EXT2_FS if ADK_TARGET_QEMU || ADK_TARGET_VBOX
+	select ADK_TARGET_QEMU_WITH_BLOCK
+	help
+	  Create a complete disk image for the target with genimage.
+
 endchoice
 
 choice

+ 3 - 0
target/x86_64/Makefile

@@ -108,6 +108,9 @@ endif
 ifeq (${ADK_TARGET_FS},iso)
 imageinstall: ${FW_DIR}/${ROOTFSISO} targethelp
 endif
+ifeq (${ADK_TARGET_FS},genimage)
+imageinstall: ${FW_DIR}/${GENIMAGE} targethelp
+endif
 ifeq ($(ADK_TARGET_FS),nfsroot)
 imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL) targethelp
 endif

+ 25 - 0
target/x86_64/qemu-x86_64/genimage.cfg

@@ -0,0 +1,25 @@
+image disk.img {
+
+  hdimage {
+  }
+
+  partition boot {
+    in-partition-table = "no"
+    image = "boot.img"
+    offset = 0
+    size = 512
+  }
+
+  partition grub {
+    in-partition-table = "no"
+    image = "grub.img"
+    offset = 512
+  }
+
+  partition root {
+    partition-type = 0x83
+    image = "rootfs.ext2"
+  }
+
+}
+