[arch-commits] Commit in (8 files)

Ronald van Haren ronald at archlinux.org
Wed Dec 3 11:21:36 UTC 2008


    Date: Wednesday, December 3, 2008 @ 06:21:36
  Author: ronald
Revision: 20420

initial grub2 upload

Added:
  grub2/
  grub2/repos/
  grub2/trunk/
  grub2/trunk/PKGBUILD
  grub2/trunk/grub-1.96-chainloader.patch
  grub2/trunk/grub.cfg
  grub2/trunk/grub2.install
  grub2/trunk/install-grub

-----------------------------+
 PKGBUILD                    |   65 ++++++++++++++
 grub-1.96-chainloader.patch |   23 +++++
 grub.cfg                    |   32 +++++++
 grub2.install               |   15 +++
 install-grub                |  187 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 322 insertions(+)

Added: grub2/trunk/PKGBUILD
===================================================================
--- grub2/trunk/PKGBUILD	                        (rev 0)
+++ grub2/trunk/PKGBUILD	2008-12-03 11:21:36 UTC (rev 20420)
@@ -0,0 +1,65 @@
+# $Id$
+# Maintainer: Ronald van Haren <ronald.archlinux.org>
+# Contributor: dongiovanni <dongiovanni.archlinux.de>
+
+pkgname=grub2
+pkgver=1.96
+pkgrel=1
+pkgdesc="The GNU GRand Unified Bootloader"
+url="http://www.gnu.org/software/grub/"
+arch=('i686' 'x86_64')
+license=('GPL3')
+depends=()
+conflicts=('grub')
+provides=('grub')
+backup=('boot/grub/grub.cfg')
+install=(${pkgname}.install)
+source=(ftp://alpha.gnu.org/gnu/grub/grub-${pkgver}.tar.gz 'grub.cfg' 'install-grub' 
+	'grub-1.96-chainloader.patch')
+md5sums=('0a40cd2326a4e84d1978060f2e02a956'
+         '743215998a581a54ac77630f0db222ce'
+         '3182c4ae4963a16930bc772bba89dacf'
+         '83cc4ebc0d41caa67a9954bd2ae3af15')
+
+build() {
+  # Set destination architecture here
+  #DESTARCH="i686"
+  DESTARCH="x86_64"
+
+  cd $srcdir/grub-${pkgver}
+
+  # Fix chainloader issue
+  patch -Np1 -i $srcdir/grub-1.96-chainloader.patch || return 1  
+
+  # Arch64 grub2 needs to be statically build on i686
+  if [ "$CARCH" = "x86_64" ]; then
+    echo "this package has to be built on i686, won't compile on x86_64"
+    sleep 5
+  else
+
+    if [ "$DESTARCH" = "x86_64" ]; then
+	export LDFLAGS=-static
+        export CFLAGS=-static
+	./configure --prefix=/usr --bindir=/bin --sbindir=/sbin \
+                        --mandir=/usr/share/man --infodir=/usr/share/info \
+			--sysconfdir=/etc
+	unset CFLAGS CPPFLAGS LDFLAGS
+
+    else
+      CFLAGS= ./configure --prefix=/usr --bindir=/bin --sbindir=/sbin \
+                --mandir=/usr/share/man --infodir=/usr/share/info \
+		--sysconfdir=/etc
+    fi
+  fi
+
+  CFLAGS= make || return 1
+  make DESTDIR=${pkgdir} install || return 1
+  
+  install -Dm644 ${srcdir}/grub.cfg $startdir/pkg/boot/grub/grub.cfg
+  install -Dm755 ${srcdir}/install-grub $startdir/pkg/sbin/install-grub
+
+  # Fool makepkg into building a x86_64 package
+  if [ "$DESTARCH" = "x86_64" ]; then
+    export CARCH="x86_64"
+  fi
+}


Property changes on: grub2/trunk/PKGBUILD
___________________________________________________________________
Added: svn:keywords
   + Id

Added: grub2/trunk/grub-1.96-chainloader.patch
===================================================================
--- grub2/trunk/grub-1.96-chainloader.patch	                        (rev 0)
+++ grub2/trunk/grub-1.96-chainloader.patch	2008-12-03 11:21:36 UTC (rev 20420)
@@ -0,0 +1,23 @@
+diff -Nru grub-1.96.orig/kern/i386/pc/startup.S grub-1.96/kern/i386/pc/startup.S
+--- grub-1.96.orig/kern/i386/pc/startup.S	2008-02-03 14:11:32.000000000 +0100
++++ grub-1.96/kern/i386/pc/startup.S	2008-02-17 06:22:54.000000000 +0100
+@@ -594,15 +594,15 @@
+ 
+ 	call	EXT_C(grub_dl_unload_all)
+ 
++	/* Turn off Gate A20 */
++	xorl	%eax, %eax
++	call	EXT_C(grub_gate_a20)       
++
+ 	/* set up to pass boot drive */
+ 	popl	%edx
+ 
+ 	/* ESI must point to a partition table entry */
+ 	popl	%esi
+-
+-	/* Turn off Gate A20 */
+-	xorl	%eax, %eax
+-	call	EXT_C(grub_gate_a20)
+ 	
+ 	call	prot_to_real
+ 	.code16

Added: grub2/trunk/grub.cfg
===================================================================
--- grub2/trunk/grub.cfg	                        (rev 0)
+++ grub2/trunk/grub.cfg	2008-12-03 11:21:36 UTC (rev 20420)
@@ -0,0 +1,32 @@
+# Config file for GRUB2 - The GNU GRand Unified Bootloader
+# /boot/grub/grub.cfg
+
+# DEVICE NAME CONVERSIONS
+#
+#  Linux           Grub
+# -------------------------
+#  /dev/fd0        (fd0)
+#  /dev/sda        (hd0)
+#  /dev/sdb2       (hd1,2)
+#  /dev/sda3       (hd0,3)
+#
+
+# Timeout for menu
+set timeout=5
+
+# Set default boot entry as Entry 0
+set default=0
+
+# (0) Arch Linux
+menuentry "Arch Linux" {
+set root=(hd0,1)
+linux /vmlinuz26 root=/dev/sda1 ro
+initrd /kernel26.img
+}
+
+## (1) Windows
+#menuentry "Windows" {
+#set root=(hd0,3)
+#chainloader +1
+#}
+

Added: grub2/trunk/grub2.install
===================================================================
--- grub2/trunk/grub2.install	                        (rev 0)
+++ grub2/trunk/grub2.install	2008-12-03 11:21:36 UTC (rev 20420)
@@ -0,0 +1,15 @@
+post_install() {
+cat << EOF 
+ GRUB2 is still expiremental and under heavy development!. 
+ Only install it if you know what you are doing. 
+
+ GRUB2 has a different configuration then GRUB legacy."
+ Look at http://grub.enbug.org for more information."
+
+EOF
+}
+
+post_upgrade() {
+        post_install
+}
+

Added: grub2/trunk/install-grub
===================================================================
--- grub2/trunk/install-grub	                        (rev 0)
+++ grub2/trunk/install-grub	2008-12-03 11:21:36 UTC (rev 20420)
@@ -0,0 +1,187 @@
+#!/bin/bash
+
+#
+# This is a little helper script that tries to convert linux-style device
+# names to grub-style.  It's not very smart, so it
+# probably won't work for more complicated setups.
+#
+# If it doesn't work for you, try installing grub manually:
+#
+#    # mkdir -p /boot/grub
+#    # cp /usr/lib/grub/i386-pc/* /boot/grub/
+#
+# Then start up the 'grub' shell and run something like the following:
+#
+#    grub> root(hd0,0)
+#    grub> setup(hd0)
+#
+# The "root" line should point to the partition your kernel is located on,
+# /boot if you have a separate boot partition, otherwise your root (/).
+#
+# The "setup" line tells grub which disc/partition to install the
+# bootloader to.  In the example above, it will install to the MBR of the
+# primary master hard drive.
+#
+
+usage() {
+	echo "usage: install-grub <install_device> [boot_device]"
+	echo
+	echo "where <install_device> is the device where Grub will be installed"
+	echo "and [boot_device] is the partition that contains the /boot"
+	echo "directory (auto-detected if omitted)"
+	echo
+	echo "examples: install-grub /dev/hda"
+	echo "          install-grub /dev/hda /dev/hda1"
+	echo
+	exit 0
+}
+
+## new install-grub, code was taken from setup script
+ROOTDEV=$1
+PART_ROOT=$2
+VMLINUZ=vmlinuz26
+
+if [ "$ROOTDEV" = "" ]; then
+	usage
+fi
+if [ "$PART_ROOT" = "" ]; then
+	PART_ROOT=$(mount | grep "on /boot type" | cut -d' ' -f 1)
+fi
+if [ "$PART_ROOT" = "" ]; then
+	PART_ROOT=$(mount | grep "on / type" | cut -d' ' -f 1)
+fi
+if [ "$PART_ROOT" = "" ]; then
+	echo "error: could not determine BOOT_DEVICE, please specify manually" >&2
+	exit 1
+fi
+
+
+get_grub_map() {
+	[ -e /tmp/dev.map ]  && rm /tmp/dev.map	
+	/sbin/grub --no-floppy --device-map /tmp/dev.map >/tmp/grub.log 2>&1 <<EOF
+quit
+EOF
+}
+
+mapdev() {
+	partition_flag=0
+	device_found=0
+	devs=$(cat /tmp/dev.map | grep -v fd | sed 's/ *\t/ /' | sed ':a;$!N;$!ba;s/\n/ /g')
+	linuxdevice=$(echo $1 | cut -b1-8)
+	if [ "$(echo $1 | egrep '[0-9]$')" ]; then
+		# /dev/hdXY
+		pnum=$(echo $1 | cut -b9-)
+		pnum=$(($pnum-1))
+		partition_flag=1
+	fi
+	for  dev in $devs
+	do
+	    if [ "(" = $(echo $dev | cut -b1) ]; then
+		grubdevice="$dev"
+	    else
+		if [ "$dev" = "$linuxdevice" ]; then
+			device_found=1
+			break   
+		fi
+	   fi
+	done	
+	if [ "$device_found" = "1" ]; then
+		if [ "$partition_flag" = "0" ]; then
+			echo "$grubdevice"
+		else
+			grubdevice_stringlen=${#grubdevice}
+			let grubdevice_stringlen--
+			grubdevice=$(echo $grubdevice | cut -b1-$grubdevice_stringlen)
+			echo "$grubdevice,$pnum)"
+		fi
+	else
+		echo " DEVICE NOT FOUND"
+	fi
+}
+
+dogrub() {
+	get_grub_map	
+	if [ ! -f /boot/grub/menu.lst ]; then
+		echo "Error: Couldn't find /boot/grub/menu.lst.  Is GRUB installed?"
+		exit 1
+	fi
+	# try to auto-configure GRUB...
+	if [ "$PART_ROOT" != "" -a "$S_GRUB" != "1" ]; then
+		grubdev=$(mapdev $PART_ROOT)
+		# look for a separately-mounted /boot partition
+		bootdev=$(mount | grep /boot | cut -d' ' -f 1)
+		if [ "$grubdev" != "" -o "$bootdev" != "" ]; then
+			cp /boot/grub/menu.lst /tmp/.menu.lst
+			# remove the default entries by truncating the file at our little tag (#-*)
+			head -n $(cat /tmp/.menu.lst | grep -n '#-\*' | cut -d: -f 1) /tmp/.menu.lst >/boot/grub/menu.lst
+			rm -f /tmp/.menu.lst
+			echo "" >>/boot/grub/menu.lst
+			echo "# (0) Arch Linux" >>/boot/grub/menu.lst
+			echo "title  Arch Linux" >>/boot/grub/menu.lst
+			subdir=
+			if [ "$bootdev" != "" ]; then
+				grubdev=$(mapdev $bootdev)
+			else
+				subdir="/boot"
+			fi
+			echo "root   $grubdev" >>/boot/grub/menu.lst
+			echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>/boot/grub/menu.lst
+			if [ "$VMLINUZ" = "vmlinuz26" ]; then
+				echo "initrd $subdir/kernel26.img" >>/boot/grub/menu.lst
+			fi
+			echo "" >>/boot/grub/menu.lst
+			# adding fallback/full image
+			echo "# (1) Arch Linux" >>/boot/grub/menu.lst
+			echo "title  Arch Linux Fallback" >>/boot/grub/menu.lst
+			echo "root   $grubdev" >>/boot/grub/menu.lst
+			echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>/boot/grub/menu.lst
+			if [ "$VMLINUZ" = "vmlinuz26" ]; then
+				echo "initrd $subdir/kernel26-fallback.img" >>/boot/grub/menu.lst
+			fi
+			echo "" >>/boot/grub/menu.lst
+		fi
+	fi
+
+	echo "Installing the GRUB bootloader..."
+	cp -a /usr/lib/grub/i386-pc/* /boot/grub/
+	sync
+	# freeze xfs filesystems to enable grub installation on xfs filesystems
+	if [ -x /usr/sbin/xfs_freeze ]; then
+		/usr/sbin/xfs_freeze -f /boot > /dev/null 2>&1
+		/usr/sbin/xfs_freeze -f / > /dev/null 2>&1
+	fi
+	# look for a separately-mounted /boot partition
+	bootpart=$(mount | grep /boot | cut -d' ' -f 1)
+	if [ "$bootpart" = "" ]; then
+			bootpart=$PART_ROOT
+	fi
+	bootpart=$(mapdev $bootpart)
+	bootdev=$(mapdev $ROOTDEV)
+	if [ "$bootpart" = "" ]; then
+		echo "Error: Missing/Invalid root device: $bootpart"
+		exit 1
+	fi
+	/sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <<EOF
+root $bootpart
+setup $bootdev
+quit
+EOF
+cat /tmp/grub.log
+	# unfreeze xfs filesystems
+	if [ -x /usr/sbin/xfs_freeze ]; then
+		/usr/sbin/xfs_freeze -u /boot > /dev/null 2>&1
+		/usr/sbin/xfs_freeze -u / > /dev/null 2>&1
+	fi
+
+	if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then
+		echo "Error installing GRUB. (see /tmp/grub.log for output)"
+		exit 1
+	fi
+	echo "GRUB was successfully installed."
+
+rm -f /tmp/grub.log
+
+exit 0
+}
+
+dogrub
\ No newline at end of file


Property changes on: grub2/trunk/install-grub
___________________________________________________________________
Added: svn:executable
   + *




More information about the arch-commits mailing list