diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2011-02-08 22:25:03 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2011-02-08 22:25:03 +0100 |
commit | ba840a69a5618e0c6b5f21d4a3e9c3239abf2763 (patch) | |
tree | 57df3e80e65eb5c5c7840b17b5859fea1342a950 /src/core | |
parent | adfa636f228aea89341ddcfd7cd9c927d8dd2242 (diff) |
simplify mapdev() API a bit, fix indentation
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/libs/lib-blockdevices-filesystems.sh | 68 | ||||
-rw-r--r-- | src/core/libs/lib-ui-interactive.sh | 8 |
2 files changed, 37 insertions, 39 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index 03f6a95..c232ac4 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -315,40 +315,40 @@ EOF # TODO: $1 is what?? ASKDEV # taken from setup. slightly edited. mapdev() { - partition_flag=0 - device_found=0 - devs=$( grep -v fd $TMP_DEV_MAP | 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} - grubdevice_stringlen=$(($grubdevice_stringlen - 1)) - grubdevice=$(echo $grubdevice | cut -b1-$grubdevice_stringlen) - echo "$grubdevice,$pnum)" - fi - else - echo "DEVICE NOT FOUND" >&2 - return 2 - fi + partition_flag=0 + device_found=0 + devs=$( grep -v fd $TMP_DEV_MAP | 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} + grubdevice_stringlen=$(($grubdevice_stringlen - 1)) + grubdevice=$(echo $grubdevice | cut -b1-$grubdevice_stringlen) + echo "$grubdevice,$pnum)" + fi + return 0 + else + return 1 + fi } diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index f3ed2e1..45d3282 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -1040,9 +1040,7 @@ generate_grub_menulst() { debug FS "onraid with sep boot grubdev: $grubdev" fi fi - # Now that we have our grub-legacy root device (grubdev). - # keep the file from being completely bogus - [ "$grubdev" = "DEVICE NOT FOUND" ] && grubdev= + if [ -z "$grubdev" ]; then notify "Your root boot device could not be autodetected by setup. Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly." grubdev="(hd0,0)" @@ -1099,11 +1097,11 @@ interactive_grub_install () { # Convert to grub-legacy notation local bootpart=$(mapdev $1) if [ -z "$bootpart" ]; then - notify "Error: Missing/Invalid root device: $bootpart" + notify "Error: Missing/Invalid root device for $1" return 1 fi local bootdev=$(mapdev $2) - if [ "$bootpart" = "DEVICE NOT FOUND" -o "$bootdev" = "DEVICE NOT FOUND" ]; then + if [ -z "$bootdev" ]; then notify "GRUB root and setup devices could not be auto-located. You will need to manually run the GRUB shell to install a bootloader." return 1 fi |