bootdisk/trunk/batch-installer/ui/ui-main

hawk cvs at pld-linux.org
Wed Mar 15 11:16:45 CET 2006


Author: hawk
Date: Wed Mar 15 11:16:41 2006
New Revision: 7166

Modified:
   bootdisk/trunk/batch-installer/ui/ui-main
Log:
- make sure that hostadapters_modules are set and loaded before
  selecting source devices (only for source type cdrom and disk)
- show more detailed list of CD-ROMs, mark detected ones
- with source type disk show only detected patitions in source
  partition selection dialog


Modified: bootdisk/trunk/batch-installer/ui/ui-main
==============================================================================
--- bootdisk/trunk/batch-installer/ui/ui-main	(original)
+++ bootdisk/trunk/batch-installer/ui/ui-main	Wed Mar 15 11:16:41 2006
@@ -81,79 +81,138 @@
 EOF
 }
 
+cd_det () {
+  if echo " $autocdrom " | grep -q " $1 " ; then
+    nls "(detected)"
+  fi
+}
+
 ui-source_device () {
-case "$source" in 
-    cdrom)
-	item1="/dev/hda"
-	item2="/dev/hdb"
-	item3="/dev/hdc"
-	item4="/dev/hdd"
-	item5="/dev/scd0"
-	item6="/dev/scd1"
-	item7="/dev/scd2"
-	item8="/dev/scd3"
-	item9="/dev/scd4"
-	dml <<EOF 
-	    <br>`nls "If you have single IDE cdrom, choose auto"`
-	    <br>
-	    <meta title="CDROM">
-	    <menu id=res_menu res=1>
-	    <item id=ui_custom>${custom_text}
-	    <item id=auto>${auto_text}
-	    <item id=$item1>$item1
-	    <item id=$item2>$item2
-	    <item id=$item3>$item3
-	    <item id=$item4>$item4
-	    <item id=$item5>$item5
-	    <item id=$item6>$item6
-	    <item id=$item7>$item7
-	    <item id=$item8>$item8
-	    <item id=$item9>$item9
-	    </menu>
-	    $@
-EOF
-	;;
-    nfs)
-	item1="192.168.0.1:/home/users/klakier/rpm"
-	item2="heaven.net:/pub/all/saints"
+local bailout scds cscd
+bailout=
+autocdrom=
+
+case "$source" in
+    cdrom|disk)
+    if test -z "$hostadapters_modules"; then
 	dml <<EOF
-	    <br>`nls "NFS device should be given in form machine:/directory."`
+	    <meta title="$(nls "Information")">
+	    <meta active=$act>
 	    <br>
-	    <meta title="$(nls "NFS server")">
-	    <menu id=res_menu res=1>
-	    <item id=ui_custom>${custom_text}
-	    <item id=$item1>$item1
-	    <item id=$item2>$item2
-	    </menu> 
-	    $@
+	    <br>`nls "hostadapters_modules must be set before selecting source devices."`
+	    <br><br>
+	    <button res=1>
 EOF
-	;;
-    net) 
-	dml <<EOF
-	    <br>`nls "Choose server or enter custom one"`
-	    <br>
-	    <meta title="$(nls "Remote server")">
-	    <menu id=res_menu res=1> 
-	    <item id=ui_custom>${custom_text}
-$(ui-mirror just-dump)
-	    </menu>
-	    $@
+	bailout="true"
+    else
+	# execute load_device_modules with output redirected to current console
+	load_device_modules "$hostadapters_modules" 1>/dev/tty 2>/dev/tty
+	if [ -d /proc/ide ] ; then
+	    for f in /proc/ide/hd* ; do
+		if [ -f $f/media ] && [ "$(cat $f/media)" = "cdrom" ] ; then
+		    autocdrom="$autocdrom /dev/`basename $f`"
+		fi
+	    done
+	fi
+	if [ -f /proc/scsi/scsi ] ; then
+	    scds=`cat /proc/scsi/scsi | grep "Type:.*CD-ROM" | wc -l`
+	    cscd=0
+	    while [ $cscd -lt $scds ]; do
+		autocdrom="$autocdrom /dev/scd$cscd"
+		cscd=$(($cscd+1))
+	    done
+	fi
+	autocdrom=$(echo "$autocdrom" | sed -e 's/^ //')
+    ;;
+esac
+
+if test -z "$bailout"; then
+    case "$source" in 
+        cdrom)
+	    dml <<EOF 
+		<br>`nls "Choose your CD-ROM device. If you have single CD drive, choose auto."`
+		<br>
+		<meta title='$(nls "CD-ROM device")'>
+		<menu id=res_menu res=1>
+		<item id=ui_custom>${custom_text}
+		<item id=auto>${auto_text}
+		<item id=/dev/hda>/dev/hda $(nls "(Primary Master)") $(cd_det /dev/hda)
+		<item id=/dev/hdb>/dev/hdb $(nls "(Primary Slave)") $(cd_det /dev/hdb)
+		<item id=/dev/hdc>/dev/hdc $(nls "(Secondary Master)") $(cd_det /dev/hdc)
+		<item id=/dev/hdd>/dev/hdd $(nls "(Secondary Slave)") $(cd_det /dev/hdd)
+		<item id=/dev/scd0>/dev/scd0 $(nls "(SCSI CD-ROM #0)") $(cd_det /dev/scd0)
+		<item id=/dev/scd1>/dev/scd1 $(nls "(SCSI CD-ROM #1)") $(cd_det /dev/scd1)
+		<item id=/dev/scd2>/dev/scd2 $(nls "(SCSI CD-ROM #2)") $(cd_det /dev/scd2)
+		<item id=/dev/scd3>/dev/scd3 $(nls "(SCSI CD-ROM #3)") $(cd_det /dev/scd3)
+		</menu>
+		$@
 EOF
 	;;
-    disk)
-	dml <<EOF 
-	<br>`nls "Choose partition or enter custom one"`
+	disk)
+	    dml <<EOF 
+	<br>`nls "Choose partition or enter custom one."`
 	<br>
 	<meta title="$(nls "Disk partition with source")">
 	<menu id=res_menu res=1> 
 	<item id=ui_custom>${custom_text}
-	<item id=/dev/hda1>/dev/hda1
-	<item id=/dev/hda2>/dev/hda2
+	$(
+	    avail_dest_devices=`awk '
+	    {
+		if (match($4, /hd[a-h][0-9]$/) ||
+		match($4, /sd[a-h][0-9]$/) ||
+		match($4, /rd\/c[0-9]d[0-9]p[0-9]*$/) ||
+		match($4, /ida\/c[0-9]d[0-9]p[0-9]*$/) ||
+		match($4, /cciss\/c[0-9]d[0-9]p[0-9]*$/) ||
+		match($4, /ataraid\/d[0-9]p[0-9]*$/) ||
+		match($4, /i2o\/hd[a-h][0-9]$/))
+		print "/dev/" $4
+	    }
+	    ' /proc/partitions | sort`
+	    for dev in $avail_dest_devices; do
+		# filter out IDE CD-ROMs
+		media=`echo "/proc/ide/$dev/media" | sed -e 's|/dev/||g'`
+		if [ -f $media ] ; then
+		    if [ "$(cat $media)" != "cdrom" ] ; then
+			echo "<item id=$dev>$dev $(disk_name $dev)"
+		    fi
+		else
+		    echo "<item id=$dev>$dev $(disk_name $dev)"
+		fi
+	    done
+	)
 	</menu>
 	$@
 EOF
 	;;
-esac
+        nfs)
+	    item1="192.168.0.1:/home/users/klakier/rpm"
+	    item2="heaven.net:/pub/all/saints"
+	    dml <<EOF
+		<br>`nls "NFS device should be given in form machine:/directory."`
+		<br>
+		<meta title="$(nls "NFS server")">
+		<menu id=res_menu res=1>
+		<item id=ui_custom>${custom_text}
+		<item id=$item1>$item1
+		<item id=$item2>$item2
+		</menu> 
+		$@
+EOF
+        ;;
+	net) 
+	    dml <<EOF
+		<br>`nls "Choose server or enter custom one."`
+		<br>
+		<meta title="$(nls "Remote server")">
+		<menu id=res_menu res=1> 
+		<item id=ui_custom>${custom_text}
+$(ui-mirror just-dump)
+		</menu>
+		$@
+EOF
+	;;
+    esac
+fi
 }
 
 
@@ -208,6 +267,7 @@
 
 
 ui-dest_devices () {
+local avail_dest_devices
 if test -z "$hostadapters_modules"; then
   dml <<EOF
     <meta title="$(nls "Information")">


More information about the pld-cvs-commit mailing list