-- 
Ward Vandewege <[EMAIL PROTECTED]>
Free Software Foundation - Senior Systems Administrator
Move from our grub2 fork to mainline grub2, now that the features we need have
been included there.

This patch also makes sure that LZMA compression of the payload is
automatically disabled for filo, etherboot and grub2, since it breaks booting
in those cases.

It also removes a few bash-isms in fetchsvn.sh.

Many, many thanks to Robert Milan for fixing the bugs in grub2 that I found
while testing.

This was build- and boot-tested on qemu, on v2 and v3.

Signed-off-by: Ward Vandewege <[EMAIL PROTECTED]>

Index: config/platforms/qemu.conf
===================================================================
--- config/platforms/qemu.conf	(revision 253)
+++ config/platforms/qemu.conf	(working copy)
@@ -15,7 +15,7 @@
 ETHERBOOT_ARCH=i386
 
 # coreboot-v2 configuration
-CBV2_TAG=3481
+CBV2_TAG=3772
 CBV2_TDIR=qemu-x86
 
 # coreboot v3 configuration
Index: config/payloads/Config.in
===================================================================
--- config/payloads/Config.in	(revision 253)
+++ config/payloads/Config.in	(working copy)
@@ -5,6 +5,9 @@
 
 config USE_LZMA
 	bool "Enable LZMA compression"
+	depends on !PAYLOAD_FILO
+	depends on !PAYLOAD_GRUB2
+	depends on !PAYLOAD_ETHERBOOT
 	depends on COREBOOT_V3 || (COREBOOT_V2 && !PLATFORM_GEODE)
 	default y
 	help
Index: bin/fetchsvn.sh
===================================================================
--- bin/fetchsvn.sh	(revision 253)
+++ bin/fetchsvn.sh	(working copy)
@@ -8,7 +8,7 @@
 
 SVNV=`svn --version --quiet`
 
-if [ $? -ne 0 ]; then
+if [ "$?" != "0" ]; then
 	echo "You don't have SVN installed."
 	exit 1
 fi
@@ -18,21 +18,21 @@
 if [ ! -d $DIR/svn/.svn ]; then
 	echo "Fetching $URL..."	
 	svn co -r $REV $URL $DIR/svn
-	if [ $? -ne 0 ]; then
+	if [ "$?" != "0" ]; then
 		echo "Couldn't fetch the code from $URL"
 		exit 1
 	fi	
 else
 	CURREV=`svn info $DIR/svn | grep "Last Changed Rev" | awk '{ print $4 }'`
 
-	if [ $CURREV -ne $REV ]; then
+	if [ "$CURREV" != "$REV" ]; then
 		(cd $DIR/svn; \
 		echo "Updating from $CURREV to $REV"
 		svn update -r $REV || {
 			echo "Couldn't update the repository."
 			exit 1
 		})
-		if [ `echo $?` -ne 0 ]; then
+		if [ "$?" != "0" ]; then
 			# The parentheses around the cd $DIR/svn; svn update ... commands above
 			# cause those commands to be executed as a list, in a subshell. As a
 			# consequence, if something goes wrong the exit command exits the
Index: packages/grub2/boot/grub/grub.cfg
===================================================================
--- packages/grub2/boot/grub/grub.cfg	(revision 0)
+++ packages/grub2/boot/grub/grub.cfg	(revision 0)
@@ -0,0 +1,7 @@
+serial --speed=115200 --word=8 --parity=no --stop=1
+terminal_output serial
+terminal_input serial
+
+search -s -f /grub.cfg
+source /grub.cfg
+
Index: packages/grub2/conf/grub.cfg
===================================================================
--- packages/grub2/conf/grub.cfg	(revision 253)
+++ packages/grub2/conf/grub.cfg	(working copy)
@@ -1,5 +0,0 @@
-coreboot
-
-menuentry "sample" {
-  set root=(ata0)
-}
Index: packages/grub2/grub2.mk
===================================================================
--- packages/grub2/grub2.mk	(revision 253)
+++ packages/grub2/grub2.mk	(working copy)
@@ -1,80 +1,93 @@
-GRUB2_REVISION=7e743dc7b9262c132488d7bb601ea48e4f730c60
-GRUB2_URL=http://coreboot.org/viewmtn/revision/tar/$(GRUB2_REVISION)
-GRUB2_TAR=grub2-$(GRUB2_REVISION).tar
+GRUB2_URL=svn://svn.savannah.gnu.org/grub/trunk/grub2
+GRUB2_TAG=1929
 
 GRUB2_DIR=$(BUILD_DIR)/grub2
-GRUB2_SRC_DIR=$(GRUB2_DIR)/$(GRUB2_REVISION)
+GRUB2_SRC_DIR=$(GRUB2_DIR)/svn
 GRUB2_STAMP_DIR=$(GRUB2_DIR)/stamps
 GRUB2_LOG_DIR=$(GRUB2_DIR)/logs
 
 ifeq ($(CONFIG_VERBOSE),y)
-GRUB2_CONFIG_LOG=/dev/stdout
+GRUB2_FETCH_LOG=/dev/stdout
 GRUB2_BUILD_LOG=/dev/stdout
 GRUB2_INSTALL_LOG=/dev/stdout
 else
 GRUB2_BUILD_LOG=$(GRUB2_LOG_DIR)/build.log
 GRUB2_INSTALL_LOG=$(GRUB2_LOG_DIR)/install.log
-GRUB2_CONFIG_LOG=$(GRUB2_LOG_DIR)/config.log
+GRUB2_FETCH_LOG=$(GRUB2_LOG_DIR)/fetch.log
 endif
 
-GRUB2_CFG=$(PACKAGE_DIR)/grub2/conf/grub.cfg
-GRUB2_MODULES=coreboot cat cmp iso9660 help lspci \
-	      serial terminal lar terminfo memdisk ata ls \
-              configfile boot hexdump linux multiboot ext2
+GRUB2_MODULES=normal ls cat help ext2 iso9660 reiserfs xfs fat pc gpt ata serial memdisk multiboot linux boot cpio configfile search terminal
 
-ifeq ($(CONFIG_PAYLOAD_GRUB2),y)
-HAVE_RUBY:=$(call find-tool,ruby)
+GRUB2_TARBALL=grub2-svn-$(GRUB2_TAG).tar.gz
 
-ifeq ($(HAVE_RUBY),n)
-$(error To build GRUB2, you need to install 'ruby')
+GRUB2_MEMDISK_DIR=$(STAGING_DIR)/grub2_memdisk
+GRUB2_MEMDISK_TARBALL=$(GRUB2_MEMDISK_DIR)/memdisk.tar
+
+ifeq ($(shell if [ -f $(PACKAGE_DIR)/grub2/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD) ]; then echo 1; fi),1)
+	GRUB2_CONFIG = $(PACKAGE_DIR)/grub2/conf/customconfig--$(PAYLOAD)--$(COREBOOT_VENDOR)-$(COREBOOT_BOARD)
+else
+	GRUB2_CONFIG = $(GRUB2_SRC_DIR)/configs/defconfig
 endif
-endif
 
-$(SOURCE_DIR)/$(GRUB2_TAR):
-	@ mkdir -p $(SOURCE_DIR)
-	@ wget $(WGET_Q) -O $@ $(GRUB2_URL)
+$(SOURCE_DIR)/$(GRUB2_TARBALL): 
+	@ mkdir -p $(SOURCE_DIR)/grub2
+	@ $(BIN_DIR)/fetchsvn.sh $(GRUB2_URL) $(SOURCE_DIR)/grub2 \
+	$(GRUB2_TAG) $(SOURCE_DIR)/$(GRUB2_TARBALL) \
+	> $(GRUB2_FETCH_LOG) 2>&1
 
-$(GRUB2_STAMP_DIR)/.unpacked: $(SOURCE_DIR)/$(GRUB2_TAR) | $(GRUB2_DIR) $(GRUB2_STAMP_DIR)
-	@ tar -C $(GRUB2_DIR) -xf $(SOURCE_DIR)/$(GRUB2_TAR)
-	@ touch $@
+$(GRUB2_STAMP_DIR)/.unpacked: $(SOURCE_DIR)/$(GRUB2_TARBALL) | $(GRUB2_STAMP_DIR) $(GRUB2_DIR)
+	@ echo "Unpacking grub2..."
+	@ tar -C $(GRUB2_DIR) -zxf $(SOURCE_DIR)/$(GRUB2_TARBALL)
+	@ touch $@      
 
-$(GRUB2_STAMP_DIR)/.configured: $(GRUB2_STAMP_DIR)/.unpacked | $(GRUB2_LOG_DIR)
-	@ echo "Configuring GRUB2..."
-	@ (cd $(GRUB2_SRC_DIR); sh ./autogen.sh > $(GRUB2_CONFIG_LOG) 2>&1)
-	@ (cd $(GRUB2_SRC_DIR); export LIBS= CC= LDFLAGS= CFLAGS=; ./configure --with-platform=linuxbios --prefix=$(STAGING_DIR) >> $(GRUB2_CONFIG_LOG) 2>&1)
+$(GRUB2_STAMP_DIR)/.configured: $(GRUB2_STAMP_DIR)/.unpacked
 	@ touch $@
 
-$(GRUB2_SRC_DIR)/grub-mkimage: $(GRUB2_STAMP_DIR)/.configured
-	@ echo "Building GRUB2..."
-	@ (cd $(GRUB2_SRC_DIR); make > $(GRUB2_CONFIG_LOG) 2>&1)
+$(GRUB2_SRC_DIR)/grub-mkelfimage: $(GRUB2_STAMP_DIR)/.configured
+ifeq ($(findstring customconfig,$(GRUB2_CONFIG)),customconfig)
+	@ echo "Using custom config $(GRUB2_CONFIG)"
+endif
+	@ echo "Building grub2..."
+	@ ln -s $(GRUB2_SRC_DIR)/config.log $(GRUB2_LOG_DIR)
+	@ (cd $(GRUB2_SRC_DIR) ; sh ./autogen.sh >> $(GRUB2_BUILD_LOG) 2>&1)
+	@ (cd $(GRUB2_SRC_DIR) ; export LIBS= CC= LDFLAGS= CFLAGS=; ./configure --with-platform=coreboot --prefix=$(STAGING_DIR) >> $(GRUB2_BUILD_LOG) 2>&1)
+	@ make -C $(GRUB2_SRC_DIR) >> $(GRUB2_BUILD_LOG) 2>&1
 
-$(GRUB2_STAMP_DIR)/.installed: $(GRUB2_SRC_DIR)/grub-mkimage
+$(GRUB2_STAMP_DIR)/.installed: $(GRUB2_SRC_DIR)/grub-mkelfimage
 	@ chmod uga+x $(GRUB2_SRC_DIR)/mkinstalldirs
 	@ (cd $(GRUB2_SRC_DIR); make install > $(GRUB2_INSTALL_LOG) 2>&1)
 	@ touch $@
 
-$(GRUB2_DIR)/grub2.elf: $(GRUB2_STAMP_DIR)/.installed
-	@ $(STAGING_DIR)/bin/grub-mkimage -o $@ $(GRUB2_MODULES)
+$(GRUB2_MEMDISK_TARBALL): $(GRUB2_STAMP_DIR)/.configured $(GRUB2_MEMDISK_DIR)
+	@ (cd $(GRUB2_MEMDISK_DIR); mkdir -p boot/grub)
+	@ cp $(PACKAGE_DIR)/grub2/boot/grub/grub.cfg $(GRUB2_MEMDISK_DIR)/boot/grub/
+	@ (cd $(GRUB2_MEMDISK_DIR); tar -cf $@ boot)
 
+
+$(GRUB2_DIR)/grub2.elf: $(GRUB2_STAMP_DIR)/.installed $(GRUB2_MEMDISK_TARBALL)
+	@ (cd $(GRUB2_SRC_DIR) ; $(STAGING_DIR)/bin/grub-mkelfimage -d . -o $@ $(GRUB2_MODULES) -m $(GRUB2_MEMDISK_TARBALL) --prefix='(memdisk)/boot/grub')
+
 $(GRUB2_STAMP_DIR)/.copied: $(GRUB2_DIR)/grub2.elf
 	@ mkdir -p $(shell dirname $(PAYLOAD_ELF))
 	@ cp $(GRUB2_DIR)/grub2.elf $(PAYLOAD_ELF)
 	@ touch $@
 
-$(GRUB2_DIR) $(GRUB2_LOG_DIR) $(GRUB2_STAMP_DIR):
+$(GRUB2_STAMP_DIR) $(GRUB2_LOG_DIR) $(GRUB2_MEMDISK_DIR):
 	@ mkdir -p $@
 
-grub2: $(GRUB2_STAMP_DIR)/.copied
+grub2: $(GRUB2_STAMP_DIR) $(GRUB2_LOG_DIR) $(GRUB2_STAMP_DIR)/.copied
 
 grub2-clean:
-	@ rm -f $(GRUB2_DIR)/grub2.lar
+	@ echo "Cleaning grub2..."
 	@ rm -f $(GRUB2_DIR)/grub2.elf
 	@ rm -f $(GRUB2_STAMP_DIR)/.configured
 	@ rm -f $(GRUB2_STAMP_DIR)/.copied
-	@ rm -f $(GRUB2_STAMP_DIR)/.installed
-ifneq ($(wildcard $(GRUB_SRC_DIR)/Makefile),)
+ifneq ($(wildcard $(GRUB2_SRC_DIR)/Makefile),)
 	@ $(MAKE) -C $(GRUB2_SRC_DIR) clean > /dev/null 2>&1
 endif
 
 grub2-distclean:
 	@ rm -rf $(GRUB2_DIR)/*
+
+grub2-extract: $(GRUB2_STAMP_DIR)/.patched
+
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to