compile fixes; handle new naming scheme in install-grub script

This commit is contained in:
Ronald van Haren 2011-08-03 18:23:55 +00:00
parent 7975e1d6c0
commit cc8fa17168
2 changed files with 190 additions and 159 deletions

View File

@ -2,7 +2,7 @@
pkgname=grub pkgname=grub
pkgver=0.97 pkgver=0.97
pkgrel=17 pkgrel=18
pkgdesc="A GNU multiboot boot loader" pkgdesc="A GNU multiboot boot loader"
arch=('i686' 'x86_64') arch=('i686' 'x86_64')
license=('GPL') license=('GPL')
@ -19,20 +19,22 @@ source=(ftp://alpha.gnu.org/gnu/grub/grub-$pkgver.tar.gz
more-raid.patch more-raid.patch
intelmac.patch intelmac.patch
grub-inode-size.patch grub-inode-size.patch
ext4.patch) ext4.patch
grub-0.97-ldflags-objcopy-remove-build-id.patch)
backup=('boot/grub/menu.lst') backup=('boot/grub/menu.lst')
install=grub.install install=grub.install
md5sums=('cd3f3eb54446be6003156158d51f4884' sha1sums=('2580626c4579bd99336d3af4482c346c95dac4fb'
'a2098dc41fc3cb13e53179de2979d088' '734fa37ebe1657bf1f8f74ee4866953ff96f2604'
'3182c4ae4963a16930bc772bba89dacf' '5479f098c71817ac86d0059cf1c77ca169a6fd93'
'eb9d69c46af3a0667c1f651817d7f075' '157b81dbad3576536b08642242accfa1aeb093a9'
'ccd2d757e79e3a03dc19ede7391ed328' 'adbb4685c98797ffb4dc83561ec75698991dddbd'
'826fdbf446067f9861baf9f6a69a4583' 'f2e0dff29a7c8a45e90aa07298a1b2a9a9d29afc'
'49f6d4bcced0bc8bbcff273f3254bbfa' 'c5e2c94ed0e759590b9eb38c9d979f075d19d7c0'
'f41f702014a064918d7afc6fc23baa6e' '45fe668a3779664fb292591f426976b6c784d6c8'
'175dc6b9f4ab94e8056c3afb3e34460a' '066d7ab1ae442f88e94c9e4f1867ac6682965d06'
'69c648d2b8d0965df70a74014424f31c' '0436aa6fa0b6f768289172f983a3f4b69384629e'
'39e0f9a05b7e04aceb24fc7bc4893e3d') 'a36f34e51efed540f1ddafd78e9c9f6d83e4c8d4'
'61c4b58d2eaa3c1561d8e9d8fc41341ce8882869')
build() { build() {
cd $srcdir/$pkgname-$pkgver cd $srcdir/$pkgname-$pkgver
@ -42,26 +44,38 @@ build() {
DESTARCH="x86_64" DESTARCH="x86_64"
# optimizations break the build -- disable them # optimizations break the build -- disable them
# adding special devices to grub, patches are from fedora # adding special devices to grub, patches are from fedora
patch -Np1 -i ../special-devices.patch || return 1 patch -Np1 -i ../special-devices.patch
patch -Np1 -i ../i2o.patch || return 1 patch -Np1 -i ../i2o.patch
patch -Np1 -i ../more-raid.patch || return 1 patch -Np1 -i ../more-raid.patch
patch -Np1 -i ../intelmac.patch || return 1 patch -Np1 -i ../intelmac.patch
# Add support for bigger inode size to e2fs_stage1_5 # Add support for bigger inode size to e2fs_stage1_5
patch -Np1 -i ../grub-inode-size.patch || return 1 patch -Np1 -i ../grub-inode-size.patch
# Add ext4 support # Add ext4 support
# http://www.mail-archive.com/bug-grub@gnu.org/msg11458.html # http://www.mail-archive.com/bug-grub@gnu.org/msg11458.html
patch -Np1 -i ../ext4.patch || return 1 patch -Np1 -i ../ext4.patch
# binutils fix
patch -Np1 -i ../grub-0.97-ldflags-objcopy-remove-build-id.patch
sed -e'/^AC_PROG_CC/ a\AM_PROG_CC_C_O\ ' -i "${srcdir}/${pkgname}-${pkgver}/configure.ac"
sed -e'/^AC_PROG_CC/ a\AM_PROG_AS\ ' -i "${srcdir}/${pkgname}-${pkgver}/configure.ac"
## recreate ./configure script with the required changes in LDFLAGS and objcopy
aclocal
autoconf
autoreconf
automake
#arch64 fixes for static build #arch64 fixes for static build
if [ "$CARCH" = "x86_64" ]; then if [ "$CARCH" = "x86_64" ]; then ## correcting problems for new wersion of autotools
echo "this package has to be built on i686, won't compile on x86_64" echo "this package has to be built on i686, won't compile on x86_64"
sleep 5 sleep 5
else else
if [ "$DESTARCH" = "x86_64" ]; then if [ "$DESTARCH" = "x86_64" ]; then
# patch from gentoo for fixing a segfault # patch from gentoo for fixing a segfault
patch -Np1 -i ../040_all_grub-0.96-nxstack.patch || return 1 patch -Np1 -i ../040_all_grub-0.96-nxstack.patch
# patch from frugalware to make it boot when more than 2GB ram installed # patch from frugalware to make it boot when more than 2GB ram installed
patch -Np1 -i ../05-grub-0.97-initrdaddr.diff || return 1 patch -Np1 -i ../05-grub-0.97-initrdaddr.diff
CFLAGS="-static" ./configure --prefix=/usr --bindir=/bin --sbindir=/sbin \ CFLAGS="-static" ./configure --prefix=/usr --bindir=/bin --sbindir=/sbin \
--mandir=/usr/share/man --infodir=/usr/share/info --mandir=/usr/share/man --infodir=/usr/share/info
else else
@ -70,8 +84,8 @@ build() {
fi fi
fi fi
CFLAGS= make || return 1 CFLAGS= make
make DESTDIR=$pkgdir install || return 1 make DESTDIR=$pkgdir install
install -D -m644 ../menu.lst $pkgdir/boot/grub/menu.lst install -D -m644 ../menu.lst $pkgdir/boot/grub/menu.lst
install -D -m755 ../install-grub $pkgdir/sbin/install-grub install -D -m755 ../install-grub $pkgdir/sbin/install-grub

View File

@ -12,8 +12,8 @@
# #
# Then start up the 'grub' shell and run something like the following: # Then start up the 'grub' shell and run something like the following:
# #
# grub> root(hd0,0) # grub> root (hd0,0)
# grub> setup(hd0) # grub> setup (hd0)
# #
# The "root" line should point to the partition your kernel is located on, # The "root" line should point to the partition your kernel is located on,
# /boot if you have a separate boot partition, otherwise your root (/). # /boot if you have a separate boot partition, otherwise your root (/).
@ -37,20 +37,19 @@ usage() {
} }
## new install-grub, code was taken from setup script ## new install-grub, code was taken from setup script
ROOTDEV=$1 ROOTDEV=${1}
PART_ROOT=$2 PART_ROOT=${2}
VMLINUZ=vmlinuz26
if [ "$ROOTDEV" = "" ]; then if [ "${ROOTDEV}" = "" ]; then
usage usage
fi fi
if [ "$PART_ROOT" = "" ]; then if [ "${PART_ROOT}" = "" ]; then
PART_ROOT=$(mount | grep "on /boot type" | cut -d' ' -f 1) PART_ROOT=$(mount | grep "on /boot type" | cut -d' ' -f 1)
fi fi
if [ "$PART_ROOT" = "" ]; then if [ "$PART_ROOT" = "" ]; then
PART_ROOT=$(mount | grep "on / type" | cut -d' ' -f 1) PART_ROOT=$(mount | grep "on / type" | cut -d' ' -f 1)
fi fi
if [ "$PART_ROOT" = "" ]; then if [ "${PART_ROOT}" = "" ]; then
echo "error: could not determine BOOT_DEVICE, please specify manually" >&2 echo "error: could not determine BOOT_DEVICE, please specify manually" >&2
exit 1 exit 1
fi fi
@ -68,31 +67,30 @@ mapdev() {
device_found=0 device_found=0
devs=$(cat /tmp/dev.map | grep -v fd | sed 's/ *\t/ /' | sed ':a;$!N;$!ba;s/\n/ /g') devs=$(cat /tmp/dev.map | grep -v fd | sed 's/ *\t/ /' | sed ':a;$!N;$!ba;s/\n/ /g')
linuxdevice=$(echo $1 | cut -b1-8) linuxdevice=$(echo $1 | cut -b1-8)
if [ "$(echo $1 | egrep '[0-9]$')" ]; then if [ "$(echo ${1} | egrep '[0-9]$')" ]; then
# /dev/hdXY # /dev/hdXY
pnum=$(echo $1 | cut -b9-) pnum=$(echo ${1} | cut -b9-)
pnum=$(($pnum-1)) pnum=$((${pnum}-1))
partition_flag=1 partition_flag=1
fi fi
for dev in $devs for dev in ${devs}; do
do if [ "(" = $(echo ${dev} | cut -b1) ]; then
if [ "(" = $(echo $dev | cut -b1) ]; then grubdevice="${dev}"
grubdevice="$dev"
else else
if [ "$dev" = "$linuxdevice" ]; then if [ "${dev}" = "${linuxdevice}" ]; then
device_found=1 device_found=1
break break
fi fi
fi fi
done done
if [ "$device_found" = "1" ]; then if [ "${device_found}" = "1" ]; then
if [ "$partition_flag" = "0" ]; then if [ "${partition_flag}" = "0" ]; then
echo "$grubdevice" echo "${grubdevice}"
else else
grubdevice_stringlen=${#grubdevice} grubdevice_stringlen=${#grubdevice}
let grubdevice_stringlen-- let grubdevice_stringlen--
grubdevice=$(echo $grubdevice | cut -b1-$grubdevice_stringlen) grubdevice=$(echo $grubdevice | cut -b1-$grubdevice_stringlen)
echo "$grubdevice,$pnum)" echo "${grubdevice},${pnum})"
fi fi
else else
echo " DEVICE NOT FOUND" echo " DEVICE NOT FOUND"
@ -106,82 +104,101 @@ dogrub() {
exit 1 exit 1
fi fi
# try to auto-configure GRUB... # try to auto-configure GRUB...
if [ "$PART_ROOT" != "" -a "$S_GRUB" != "1" ]; then if [ "${PART_ROOT}" != "" -a "$S_GRUB" != "1" ]; then
grubdev=$(mapdev $PART_ROOT) grubdev=$(mapdev ${PART_ROOT})
# look for a separately-mounted /boot partition # look for a separately-mounted /boot partition
bootdev=$(mount | grep /boot | cut -d' ' -f 1) bootdev=$(mount | grep /boot | cut -d' ' -f 1)
if [ "$grubdev" != "" -o "$bootdev" != "" ]; then if [ "${grubdev}" != "" -o "${bootdev}" != "" ]; then
cp /boot/grub/menu.lst /tmp/.menu.lst cp /boot/grub/menu.lst /tmp/.menu.lst
# remove the default entries by truncating the file at our little tag (#-*) # 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 head -n $(cat /tmp/.menu.lst | grep -n '#-\*' | cut -d: -f 1) /tmp/.menu.lst >/boot/grub/menu.lst
rm -f /tmp/.menu.lst rm -f /tmp/.menu.lst
for kernel in /boot/vmlinuz-linux* /boot/vmlinuz26*; do
if [ ${kernel} == "/boot/vmlinuz-linux*" ] || [ ${kernel} == "/boot/vmlinuz26*" ] ; then
echo > /dev/null
else
VMLINUZ=$( echo ${kernel} | cut -c 7- )
if [ "$( echo ${VMLINUZ} | cut -c -13 )" = vmlinuz-linux ]; then # new naming scheme for linux > 3.0
extension=$( echo ${VMLINUZ} | cut -c 14- )
INITRAMFS_BASENAME = initramfs-linux${extension}
else # old naming scheme for lts kernel
extension=$( echo ${VMLINUZ} | cut -c 10- )
INITRAMFS_BASENAME=kernel26${extension}
fi
echo "" >>/boot/grub/menu.lst echo "" >>/boot/grub/menu.lst
echo "# (0) Arch Linux" >>/boot/grub/menu.lst echo "# (0) Arch Linux" >>/boot/grub/menu.lst
echo "title Arch Linux" >>/boot/grub/menu.lst echo "title Arch Linux" >>/boot/grub/menu.lst
subdir= subdir=
if [ "$bootdev" != "" ]; then if [ "${bootdev}" != "" ]; then
grubdev=$(mapdev $bootdev) grubdev=$(mapdev ${bootdev})
else else
subdir="/boot" subdir="/boot"
fi fi
echo "root $grubdev" >>/boot/grub/menu.lst echo "root ${grubdev}" >>/boot/grub/menu.lst
echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>/boot/grub/menu.lst echo "kernel ${subdir}/${VMLINUZ} root=${PART_ROOT} ro" >>/boot/grub/menu.lst
if [ "$VMLINUZ" = "vmlinuz26" ]; then echo "initrd ${subdir}/${INITRAMFS_BASENAME}.img" >>/boot/grub/menu.lst
echo "initrd $subdir/kernel26.img" >>/boot/grub/menu.lst
fi
echo "" >>/boot/grub/menu.lst echo "" >>/boot/grub/menu.lst
# adding fallback/full image # adding fallback/full image
echo "# (1) Arch Linux" >>/boot/grub/menu.lst echo "# (1) Arch Linux" >>/boot/grub/menu.lst
echo "title Arch Linux Fallback" >>/boot/grub/menu.lst echo "title Arch Linux Fallback" >>/boot/grub/menu.lst
echo "root $grubdev" >>/boot/grub/menu.lst echo "root ${grubdev}" >>/boot/grub/menu.lst
echo "kernel $subdir/$VMLINUZ root=$PART_ROOT ro" >>/boot/grub/menu.lst echo "kernel ${subdir}/${VMLINUZ} root=${PART_ROOT} ro" >>/boot/grub/menu.lst
if [ "$VMLINUZ" = "vmlinuz26" ]; then echo "initrd ${subdir}/${INITRAMFS_BASENAME}-fallback.img" >>/boot/grub/menu.lst
echo "initrd $subdir/kernel26-fallback.img" >>/boot/grub/menu.lst
fi
echo "" >>/boot/grub/menu.lst echo "" >>/boot/grub/menu.lst
fi fi
done
fi
fi fi
echo "Installing the GRUB bootloader..." echo "Installing the GRUB bootloader..."
cp -a /usr/lib/grub/i386-pc/* /boot/grub/ cp -a /usr/lib/grub/i386-pc/* /boot/grub/
sync sync
# freeze xfs filesystems to enable grub installation on xfs filesystems # freeze xfs filesystems to enable grub installation on xfs filesystems
if [ -x /usr/sbin/xfs_freeze ]; then if [ -x /usr/sbin/xfs_freeze ]; then
/usr/sbin/xfs_freeze -f /boot > /dev/null 2>&1 /usr/sbin/xfs_freeze -f /boot > /dev/null 2>&1
/usr/sbin/xfs_freeze -f / > /dev/null 2>&1 /usr/sbin/xfs_freeze -f / > /dev/null 2>&1
fi fi
# look for a separately-mounted /boot partition # look for a separately-mounted /boot partition
bootpart=$(mount | grep /boot | cut -d' ' -f 1) bootpart=$(mount | grep /boot | cut -d' ' -f 1)
if [ "$bootpart" = "" ]; then if [ "${bootpart}" = "" ]; then
bootpart=$PART_ROOT bootpart=${PART_ROOT}
fi fi
bootpart=$(mapdev $bootpart) bootpart=$(mapdev ${bootpart})
bootdev=$(mapdev $ROOTDEV) bootdev=$(mapdev ${ROOTDEV})
if [ "$bootpart" = "" ]; then if [ "${bootpart}" = "" ]; then
echo "Error: Missing/Invalid root device: $bootpart" echo "Error: Missing/Invalid root device: ${bootpart}"
exit 1 exit 1
fi fi
echo ${bootpart}
echo ${bootdev}
/sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <<EOF /sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <<EOF
root $bootpart root ${bootpart}
setup $bootdev setup ${bootdev}
quit quit
EOF EOF
cat /tmp/grub.log cat /tmp/grub.log
# unfreeze xfs filesystems # unfreeze xfs filesystems
if [ -x /usr/sbin/xfs_freeze ]; then if [ -x /usr/sbin/xfs_freeze ]; then
/usr/sbin/xfs_freeze -u /boot > /dev/null 2>&1 /usr/sbin/xfs_freeze -u /boot > /dev/null 2>&1
/usr/sbin/xfs_freeze -u / > /dev/null 2>&1 /usr/sbin/xfs_freeze -u / > /dev/null 2>&1
fi fi
if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then
echo "Error installing GRUB. (see /tmp/grub.log for output)" echo "Error installing GRUB. (see /tmp/grub.log for output)"
exit 1 exit 1
fi fi
echo "GRUB was successfully installed." echo "GRUB was successfully installed."
rm -f /tmp/grub.log rm -f /tmp/grub.log
exit 0 exit 0
} }
dogrub dogrub