bootdisk: installer-boot (HEAD) [malekith]

PLD CVS pld-cvs-commit w pld.org.pl
Pon, 29 Lip 2002, 13:04:05 CEST


Module name:	bootdisk
Changes by:	malekith	02/07/29 13:04:03

Modified files:
	installer-boot

Log message:
- use $boot_loader_device
- set first partition active if none is active (fixes problems with some
  buggy bioses)
- use parse_boot_loader_entry()

Index: installer-boot
===================================================================
RCS file: /cvsroot/bootdisk/batch-installer/installer-boot,v
diff -d -u -r1.30 -r1.31
--- installer-boot	2002/03/25 09:16:36	1.30
+++ installer-boot	2002/07/29 11:04:03	1.31
@@ -18,20 +18,46 @@
 
 is_dest_mounted
 
-dest_root_partition=`grep ' /dest ' /proc/mounts | sed 's/ .*$//' || : `
-dest_boot_partition=`grep ' /dest/boot ' /proc/mounts | sed 's/ .*$//' || : `
-test "$dest_boot_partition" || dest_boot_partition=$dest_root_partition || :
+# given a partition name return its disk
+strip_partition_number () {
+    case "$1" in
+      /dev/*/c[0-7]d[0-9]* )
+        # hardware raid
+        echo $1 | sed -e 's/p[0-9]*$//' || :
+       ;;
+      *) 
+        echo $1 | sed -e 's/[0-9]*$//' || :
+        ;;
+    esac
+}
 
-case "$dest_boot_partition" in
-  /dev/rd/c[0-7]d[0-9]* | /dev/ida/c[0-2]d[0-9]* | /dev/cciss/c[0-2]d[0-9]* )
-    # hardware raid
-    dest_boot_device=`echo $dest_boot_partition | sed -e 's/p[0-9]*$//' || :` 
-   ;;
-  *) 
-    dest_boot_device=`echo $dest_boot_partition | sed -e 's/[0-9]*$//' || :` 
+case "$boot_loader_device" in
+  auto )
+    dest_root_partition=`grep ' /dest ' /proc/mounts | sed 's/ .*$//' || : `
+    dest_boot_partition=`grep ' /dest/boot ' /proc/mounts | sed 's/ .*$//' || : `
+    test "$dest_boot_partition" || dest_boot_partition=$dest_root_partition || :
+ 
+    dest_boot_partition=$(strip_partition_number $dest_boot_partition)
+    ;;
+  /dev/* )
+    dest_boot_device="$boot_loader_device"
     ;;
+  * )
+    die "$(nls "bad boot_loader_device: '%s'" "$boot_loader_device")"
+    ;;
 esac
 
+boot_disk=$(strip_partition_number $dest_boot_partition)
+if test -x /bin/parted ; then
+  # hmm.. what if we havn't got parted?
+  if parted -s $boot_disk print | grep -q "[ 	]boot" ; then
+    : ok
+  else
+    log warn "$(nls "No partition is active on %s. Making 1st partition active" "$boot_disk")"
+    parted -s $boot_disk set 1 boot on || :
+  fi
+fi
+
 case "$boot_loader" in
   "" | none )
     # user do not want bootloader
@@ -57,32 +83,12 @@
     set_var $imageconfig INITRD /boot/initrd
 
     for img in $boot_loader_other ; do
-      id=1
-      for f in $(echo $img | tr ":" " ") ; do
-        eval f${id}=$f
-	id=$(($id+1))
-      done
-      type=$f1
-      label=$f2
-      root=$f3
-      kernel=
-      initrd=
-      case $img in
-        linux:*:*:*:* )
-	  kernel=$f3
-	  initrd=$f4
-	  root=$f5
-	  ;;
-        linux:*:*:* )
-	  kernel=$f3
-	  root=$f4
-	  ;;
-      esac
-      imageconfig=sysconfig/rc-boot/images/$label
-      set_var $imageconfig TYPE $type
-      set_var $imageconfig ROOT $root
-      set_var $imageconfig KERNEL "$kernel"
-      set_var $imageconfig INITRD "$root"
+      eval $(parse_boot_loader_entry $img)
+      imageconfig=sysconfig/rc-boot/images/$img_label
+      set_var $imageconfig TYPE $img_os
+      set_var $imageconfig ROOT $img_root
+      set_var $imageconfig KERNEL "$img_kernel"
+      set_var $imageconfig INITRD "$img_initrd"
     done
     
     #kernel_ver=$(chroot /dest rpm -q kernel --queryformat '%{VERSION}-%{RELEASE}')
@@ -95,62 +101,44 @@
     ;;
 
   lilo )
-    cat <<EOF >/dest/etc/lilo.conf
+    cat >/dest/etc/lilo.conf <<EOF
 lba32
-boot=$dest_boot_device
-map=/boot/map
-install=/boot/boot.b
-image=/boot/vmlinuz
-	initrd=/boot/initrd
-	label=pld
-	root=$dest_root_partition
+boot = $dest_boot_device
+map = /boot/map
+install = /boot/boot.b
+image = /boot/vmlinuz
+	initrd = /boot/initrd
+	label = pld
+	root = $dest_root_partition
 	read-only
 	
 EOF
 
     for img in $boot_loader_other ; do
-      id=1
-      for f in $(echo $img | tr ":" " ") ; do
-        eval f${id}=$f
-	id=$(($id+1))
-      done
-      type=$f1
-      label=$f2
-      root=$f3
-      kernel=
-      initrd=
-      case $img in
-        linux:*:*:*:* )
-	  kernel=$f3
-	  initrd=$f4
-	  root=$f5
-	  cat >> /dest/etc/lilo.conf <<EOF
-image=$kernel
-	initrd=$initrd
-	label=$label
-	root=$root
-	read-only
-	
-EOF
-	  ;;
-        linux:*:*:* )
-	  kernel=$f3
-	  root=$f4
+      eval $(parse_boot_loader_entry $img)
+      case $img_os in
+      linux )
+      	echo "image = $img_kernel" >> /dest/etc/lilo.conf
+	if [ "$img_initrd" ] ; then
+	  echo "	initrd = $img_initrd" >> /dest/etc/lilo.conf
+	fi
 	  cat >> /dest/etc/lilo.conf <<EOF
-image=$kernel
-	label=$label
-	root=$root
+	label=$img_label
+	root=$img_root
 	read-only
 	
 EOF
 	  ;;
-	* )
+      dos | bsd )
 	  cat >> /dest/etc/lilo.conf <<EOF
-other=$root
-	label=$label
+other=$img_root
+	label=$img_label
 	
 EOF
 	  ;;
+      evil )
+        die "evil bootloader entry"
+	;;
 	 
       esac
     done



Więcej informacji o liście dyskusyjnej pld-installer