wok-current rev 13797

Create grub entry based on current root partition. Fix bug78
author border
date Sat Jan 05 12:34:10 2013 -0500 (2013-01-05)
parents 6b09507225ec
children 2aea23badb24
files linux/receipt
line diff
     1.1 --- a/linux/receipt	Sat Jan 05 14:44:51 2013 +0100
     1.2 +++ b/linux/receipt	Sat Jan 05 12:34:10 2013 -0500
     1.3 @@ -324,11 +324,21 @@
     1.4      chroot "$1/" depmod -a $KBASEVER-slitaz
     1.5      # GRUB stuff.
     1.6      if [ -f "$1/boot/grub/menu.lst" ]; then
     1.7 -    	root_dev=`cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1`
     1.8 -		grub_dev=`cat $1/boot/grub/menu.lst | grep "root (" | head -n 1`
     1.9 -		# Add new kernel entry in case of upgrade for installed system.
    1.10 -		if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
    1.11 -			cat >> $1/boot/grub/menu.lst << EOT
    1.12 +    	root_dev="/dev/`lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*'`" # current root device
    1.13 +    	grub_part="$(( `echo $root_dev | grep -o '[0-9]*$'`-1 ))"
    1.14 +    	grub_dev="`grep $(echo $root_dev | grep -o  '^/dev/.d.' ) $1/boot/grub/device.map |\
    1.15 +    	cut -f1 | sed "s/)$/.$grub_part)/g"`" # use device.map to find grub device number
    1.16 +    	
    1.17 +	# Add and clean kernel entrys in case of upgrade for installed system.
    1.18 +	if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
    1.19 +		
    1.20 +		#clean the old entry
    1.21 +		# TODO somewhere, the old vmlinuz file is removed.
    1.22 +		#      but the entry is still there. this cause a grub error:15 when selected
    1.23 +		# see http://bugs.slitaz.org/?id=74
    1.24 +
    1.25 +		#add the new
    1.26 +		cat >> $1/boot/grub/menu.lst << EOT
    1.27  
    1.28  title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
    1.29  $grub_dev