[arch-releng] [PATCH 1/3] Rename interactive_grub_menulst to interactive_bootloader_menu
In addition to the rename, the function was updated to be flexible with the use of multiple bootloaders. --- src/core/libs/lib-ui-interactive.sh | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 45d3282..a2d5759 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -886,7 +886,7 @@ interactive_grub() { fi fi # Create and edit the grub menu.lst - interactive_grub_menulst + interactive_bootloader_menu "GRUB" $grubmenu DEVS="$(findblockdevices '_ ')" if [ "$DEVS" = " " ]; then @@ -1073,13 +1073,22 @@ initrd $subdir/kernel26-fallback.img EOF } -interactive_grub_menulst () { - generate_grub_menulst - helptext= - grep -q '^/dev/mapper' $TMP_FSTAB && helptext=" /dev/mapper/ users: Pay attention to the kernel line!" - notify "Before installing GRUB, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install GRUB.$helptext" - seteditor || return 1 - $EDITOR $grubmenu +interactive_bootloader_menu() { + # $1 - Bootloader Name + # $2 - Bootloader Configuration Files + + if [[ $1 = GRUB ]]; then + generate_grub_menulst + fi + + grep -q '^/dev/mapper' $TMP_FSTAB && local helptext=" /dev/mapper/ users: Pay attention to the kernel line!" + notify "Before installing $1, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install $1.$helptext" + + if [[ -z $EDITOR ]]; then + seteditor || return 1 + fi + + $EDITOR $2 } interactive_grub_install () { -- 1.7.4
--- src/core/libs/lib-ui-interactive.sh | 253 +++++++++++++++++------------------ 1 files changed, 126 insertions(+), 127 deletions(-) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index a2d5759..144749a 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -847,12 +847,12 @@ interactive_runtime_network() { interactive_install_bootloader () { ask_option Grub "Choose bootloader" "Which bootloader would you like to use? Grub is the Arch default." required \ - "Grub" "Use the GRUB bootloader (default)" \ - "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 + "Grub" "Use the GRUB bootloader (default)" \ + "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 bl=`tr '[:upper:]' '[:lower:]' <<< "$ANSWER_OPTION"` [ "$bl" != grub ] && return 0 - GRUB_OK=0 + GRUB_OK=0 interactive_grub } @@ -860,140 +860,140 @@ interactive_grub() { get_grub_map [ ! -f $grubmenu ] && show_warning "No grub?" "Error: Couldn't find $grubmenu. Is GRUB installed?" && return 1 - debug FS "starting interactive_grub" - # try to auto-configure GRUB... - debug 'UI-INTERACTIVE' "install_grub \$PART_ROOT $PART_ROOT \$GRUB_OK $GRUB_OK" + debug FS "starting interactive_grub" + # try to auto-configure GRUB... + debug 'UI-INTERACTIVE' "install_grub \$PART_ROOT $PART_ROOT \$GRUB_OK $GRUB_OK" if get_device_with_mount '/' && [ "$GRUB_OK" != '1' ] ; then GRUB_OK=0 PART_ROOT=$ANSWER_DEVICE # look for a separately-mounted /boot partition - # This could be used better, maybe we use a better variable name cause - # we use this later in many things in workflow. - # Currently we have bootdev as a device if we have a seperate /boot or empty - # if no seperate /boot. Where our /boot realy lives is important later - # to build the grub: root (hdx,y) part. - # So maybe we set a flag variable like: sepboot=true|false and set bootdev to either - # the partition with seperate /boot or to $PART_ROOT. - # So that bootdev is always our real partition with /boot.... - bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1) + # This could be used better, maybe we use a better variable name cause + # we use this later in many things in workflow. + # Currently we have bootdev as a device if we have a seperate /boot or empty + # if no seperate /boot. Where our /boot realy lives is important later + # to build the grub: root (hdx,y) part. + # So maybe we set a flag variable like: sepboot=true|false and set bootdev to either + # the partition with seperate /boot or to $PART_ROOT. + # So that bootdev is always our real partition with /boot.... + bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1) # check if bootdev or PART_ROOT is on a md raid array - # This dialog is only shown when we detect / or /boot on a raid device. + # This dialog is only shown when we detect / or /boot on a raid device. if device_is_raid $bootdev || device_is_raid $PART_ROOT; then ask_yesno "Do you have your system installed on software raid?\nAnswer 'YES' to install grub to another hard disk." no if [ $? -eq 0 ]; then onraid=true - debug FS "onraid is selected" + debug FS "onraid is selected" fi fi - # Create and edit the grub menu.lst - interactive_bootloader_menu "GRUB" $grubmenu + # Create and edit the grub menu.lst + interactive_bootloader_menu "GRUB" $grubmenu DEVS="$(findblockdevices '_ ')" - if [ "$DEVS" = " " ]; then - notify "No hard drives were found" - return 1 - fi - # copy initial grub files into installed system - cp -a $var_TARGET_DIR/usr/lib/grub/i386-pc/* $var_TARGET_DIR/boot/grub/ - sync - # freeze xfs filesystems to enable grub installation on xfs filesystems - for xfsdev in $(blkid -t TYPE=xfs -o device); do - mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) - if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then - /usr/sbin/xfs_freeze -f $mnt > /dev/null 2>&1 - fi - done - - if [ ! $onraid ]; then - # Set boot partition to the device where our /boot lives. - [ -z $bootdev ] && bootpart=$PART_ROOT || bootpart=$bootdev - ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed (usually the MBR and not a partition)." required $DEVS || return 1 - bootdev=$ANSWER_OPTION - boothd=$(echo $bootdev | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - else - # Raid special - # The bootpart and bootdev should not be changed when setup grub on all raid array members. - # Instead the device is mapped via grub parameter device - # So a grub setup on MBR sda/sdb with /boot on sda1/sdb1 should always be done like: - # device (hd0) /dev/sd(a|b) - # root (hd0,0) - # setup (hd0) - - # get md device either if we use separate /boot or not. - [ -z $bootdev ] && local md=$PART_ROOT || local md=$bootdev - - local ask_str="Do you want to install grub to the MBR of each harddisk from your BOOT array "$md" ? (recommended)" - ask_yesno "$ask_str" yes - if [ $? -eq 0 ]; then + if [ "$DEVS" = " " ]; then + notify "No hard drives were found" + return 1 + fi + # copy initial grub files into installed system + cp -a $var_TARGET_DIR/usr/lib/grub/i386-pc/* $var_TARGET_DIR/boot/grub/ + sync + # freeze xfs filesystems to enable grub installation on xfs filesystems + for xfsdev in $(blkid -t TYPE=xfs -o device); do + mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) + if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then + /usr/sbin/xfs_freeze -f $mnt > /dev/null 2>&1 + fi + done + + if [ ! $onraid ]; then + # Set boot partition to the device where our /boot lives. + [ -z $bootdev ] && bootpart=$PART_ROOT || bootpart=$bootdev + ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed (usually the MBR and not a partition)." required $DEVS || return 1 + bootdev=$ANSWER_OPTION + boothd=$(echo $bootdev | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + else + # Raid special + # The bootpart and bootdev should not be changed when setup grub on all raid array members. + # Instead the device is mapped via grub parameter device + # So a grub setup on MBR sda/sdb with /boot on sda1/sdb1 should always be done like: + # device (hd0) /dev/sd(a|b) + # root (hd0,0) + # setup (hd0) + + # get md device either if we use separate /boot or not. + [ -z $bootdev ] && local md=$PART_ROOT || local md=$bootdev + + local ask_str="Do you want to install grub to the MBR of each harddisk from your BOOT array "$md" ? (recommended)" + ask_yesno "$ask_str" yes + if [ $? -eq 0 ]; then slaves=$(mdraid_all_slaves $md) - for slave in $slaves; do - boothd=$(echo $slave | cut -c -8) - bootpart=$(mdraid_slave0 $md) - bootdev=$(echo $bootpart | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - done - else - # This part needs more attention... User could select here only - # a other blockdevice to install grub into... But our grub rootdevice - # is not selectable, cause it is determined either from PART_ROOT or - # bootdev. - # Maybe better we leave the user alone and poke him to use a grub - # shell if he want do something unusefull and not install grub in - # aech MBR of affected HD in raid array.... - local USERHAPPY=0 - while [ "$USERHAPPY" = 0 ] - do - ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed." required $DEVS DONE _ - [ $? -gt 0 ] && USERHAPPY=1 && break - [ "$ANSWER_OPTION" == DONE ] && USERHAPPY=1 && break - bootdev=$ANSWER_OPTION - boothd=$(echo $bootdev | cut -c -8) - bootpart=$(mdraid_slave0 $md) - bootdev=$(echo $bootpart | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - done + for slave in $slaves; do + boothd=$(echo $slave | cut -c -8) + bootpart=$(mdraid_slave0 $md) + bootdev=$(echo $bootpart | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + done + else + # This part needs more attention... User could select here only + # a other blockdevice to install grub into... But our grub rootdevice + # is not selectable, cause it is determined either from PART_ROOT or + # bootdev. + # Maybe better we leave the user alone and poke him to use a grub + # shell if he want do something unusefull and not install grub in + # aech MBR of affected HD in raid array.... + local USERHAPPY=0 + while [ "$USERHAPPY" = 0 ] + do + ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed." required $DEVS DONE _ + [ $? -gt 0 ] && USERHAPPY=1 && break + [ "$ANSWER_OPTION" == DONE ] && USERHAPPY=1 && break + bootdev=$ANSWER_OPTION + boothd=$(echo $bootdev | cut -c -8) + bootpart=$(mdraid_slave0 $md) + bootdev=$(echo $bootpart | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + done fi - if [ "$bootpart" = "" ]; then - if [ "$PART_ROOT" = "" ]; then - ask_string "Enter the full path to your root device" "/dev/sda3" || return 1 - bootpart=$ANSWER_STRING - else - bootpart=$PART_ROOT - fi - boothd=$(echo $bootpart | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - fi - fi - # unfreeze xfs filesystems - for xfsdev in $(blkid -t TYPE=xfs -o device); do - mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) - if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then - /usr/sbin/xfs_freeze -u $mnt > /dev/null 2>&1 - fi - done - - if [ "$GRUB_OK" == "1" ]; then - notify "GRUB was successfully installed." - else - show_warning "Grub installation failure" "GRUB was NOT successfully installed." - return 1 - fi - return 0 - fi + if [ "$bootpart" = "" ]; then + if [ "$PART_ROOT" = "" ]; then + ask_string "Enter the full path to your root device" "/dev/sda3" || return 1 + bootpart=$ANSWER_STRING + else + bootpart=$PART_ROOT + fi + boothd=$(echo $bootpart | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + fi + fi + # unfreeze xfs filesystems + for xfsdev in $(blkid -t TYPE=xfs -o device); do + mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) + if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then + /usr/sbin/xfs_freeze -u $mnt > /dev/null 2>&1 + fi + done + + if [ "$GRUB_OK" == "1" ]; then + notify "GRUB was successfully installed." + else + show_warning "Grub installation failure" "GRUB was NOT successfully installed." + return 1 + fi + return 0 + fi } generate_grub_menulst() { @@ -1080,14 +1080,14 @@ interactive_bootloader_menu() { if [[ $1 = GRUB ]]; then generate_grub_menulst fi - + grep -q '^/dev/mapper' $TMP_FSTAB && local helptext=" /dev/mapper/ users: Pay attention to the kernel line!" notify "Before installing $1, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install $1.$helptext" - + if [[ -z $EDITOR ]]; then seteditor || return 1 fi - + $EDITOR $2 } @@ -1102,7 +1102,7 @@ interactive_grub_install () { # The boothd - Only on md raid setups this differs from bootdev # These values get parsed either from values we have already or from # user input. Later they will converted to grub-legacy notation. - + # Convert to grub-legacy notation local bootpart=$(mapdev $1) if [ -z "$bootpart" ]; then @@ -1118,7 +1118,7 @@ interactive_grub_install () { debug FS "bootpart: $bootpart" debug FS "bootdev: $bootdev" debug FS "boothd: $boothd" - + $var_TARGET_DIR/sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <<EOF device $bootdev $boothd root $bootpart @@ -1220,7 +1220,6 @@ interactive_select_source() { return 0 } - # Prompt user for preferred mirror and set $var_SYNC_URL # args: none # returns: nothing -- 1.7.4
Gross; are other files tabs? 4 spaces is pretty common thing; it's not difficult to tell your editor to insert spaces for tabs, and to behave in a tab-like manner, eg softtab/tabstop/etc in vim. C Anthony [mobile] On Feb 8, 2011 7:53 PM, <pyther@pyther.net> wrote:
--- src/core/libs/lib-ui-interactive.sh | 253 +++++++++++++++++------------------ 1 files changed, 126 insertions(+), 127 deletions(-)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index a2d5759..144749a 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -847,12 +847,12 @@ interactive_runtime_network() {
interactive_install_bootloader () { ask_option Grub "Choose bootloader" "Which bootloader would you like to use? Grub is the Arch default." required \ - "Grub" "Use the GRUB bootloader (default)" \ - "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 + "Grub" "Use the GRUB bootloader (default)" \ + "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1
bl=`tr '[:upper:]' '[:lower:]' <<< "$ANSWER_OPTION"` [ "$bl" != grub ] && return 0 - GRUB_OK=0 + GRUB_OK=0 interactive_grub }
@@ -860,140 +860,140 @@ interactive_grub() { get_grub_map [ ! -f $grubmenu ] && show_warning "No grub?" "Error: Couldn't find $grubmenu. Is GRUB installed?" && return 1
- debug FS "starting interactive_grub" - # try to auto-configure GRUB... - debug 'UI-INTERACTIVE' "install_grub \$PART_ROOT $PART_ROOT \$GRUB_OK $GRUB_OK" + debug FS "starting interactive_grub" + # try to auto-configure GRUB... + debug 'UI-INTERACTIVE' "install_grub \$PART_ROOT $PART_ROOT \$GRUB_OK $GRUB_OK" if get_device_with_mount '/' && [ "$GRUB_OK" != '1' ] ; then GRUB_OK=0 PART_ROOT=$ANSWER_DEVICE # look for a separately-mounted /boot partition - # This could be used better, maybe we use a better variable name cause - # we use this later in many things in workflow. - # Currently we have bootdev as a device if we have a seperate /boot or empty - # if no seperate /boot. Where our /boot realy lives is important later - # to build the grub: root (hdx,y) part. - # So maybe we set a flag variable like: sepboot=true|false and set bootdev to either - # the partition with seperate /boot or to $PART_ROOT. - # So that bootdev is always our real partition with /boot.... - bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1) + # This could be used better, maybe we use a better variable name cause + # we use this later in many things in workflow. + # Currently we have bootdev as a device if we have a seperate /boot or empty + # if no seperate /boot. Where our /boot realy lives is important later + # to build the grub: root (hdx,y) part. + # So maybe we set a flag variable like: sepboot=true|false and set bootdev to either + # the partition with seperate /boot or to $PART_ROOT. + # So that bootdev is always our real partition with /boot.... + bootdev=$(mount | grep $var_TARGET_DIR/boot | cut -d' ' -f 1) # check if bootdev or PART_ROOT is on a md raid array - # This dialog is only shown when we detect / or /boot on a raid device. + # This dialog is only shown when we detect / or /boot on a raid device. if device_is_raid $bootdev || device_is_raid $PART_ROOT; then ask_yesno "Do you have your system installed on software raid?\nAnswer 'YES' to install grub to another hard disk." no if [ $? -eq 0 ]; then onraid=true - debug FS "onraid is selected" + debug FS "onraid is selected" fi fi - # Create and edit the grub menu.lst - interactive_bootloader_menu "GRUB" $grubmenu + # Create and edit the grub menu.lst + interactive_bootloader_menu "GRUB" $grubmenu
DEVS="$(findblockdevices '_ ')" - if [ "$DEVS" = " " ]; then - notify "No hard drives were found" - return 1 - fi - # copy initial grub files into installed system - cp -a $var_TARGET_DIR/usr/lib/grub/i386-pc/* $var_TARGET_DIR/boot/grub/ - sync - # freeze xfs filesystems to enable grub installation on xfs filesystems - for xfsdev in $(blkid -t TYPE=xfs -o device); do - mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) - if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then - /usr/sbin/xfs_freeze -f $mnt > /dev/null 2>&1 - fi - done - - if [ ! $onraid ]; then - # Set boot partition to the device where our /boot lives. - [ -z $bootdev ] && bootpart=$PART_ROOT || bootpart=$bootdev - ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed (usually the MBR and not a partition)." required $DEVS || return 1 - bootdev=$ANSWER_OPTION - boothd=$(echo $bootdev | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - else - # Raid special - # The bootpart and bootdev should not be changed when setup grub on all raid array members. - # Instead the device is mapped via grub parameter device - # So a grub setup on MBR sda/sdb with /boot on sda1/sdb1 should always be done like: - # device (hd0) /dev/sd(a|b) - # root (hd0,0) - # setup (hd0) - - # get md device either if we use separate /boot or not. - [ -z $bootdev ] && local md=$PART_ROOT || local md=$bootdev - - local ask_str="Do you want to install grub to the MBR of each harddisk from your BOOT array "$md" ? (recommended)" - ask_yesno "$ask_str" yes - if [ $? -eq 0 ]; then + if [ "$DEVS" = " " ]; then + notify "No hard drives were found" + return 1 + fi + # copy initial grub files into installed system + cp -a $var_TARGET_DIR/usr/lib/grub/i386-pc/* $var_TARGET_DIR/boot/grub/ + sync + # freeze xfs filesystems to enable grub installation on xfs filesystems + for xfsdev in $(blkid -t TYPE=xfs -o device); do + mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) + if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then + /usr/sbin/xfs_freeze -f $mnt > /dev/null 2>&1 + fi + done + + if [ ! $onraid ]; then + # Set boot partition to the device where our /boot lives. + [ -z $bootdev ] && bootpart=$PART_ROOT || bootpart=$bootdev + ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed (usually the MBR and not a partition)." required $DEVS || return 1 + bootdev=$ANSWER_OPTION + boothd=$(echo $bootdev | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + else + # Raid special + # The bootpart and bootdev should not be changed when setup grub on all raid array members. + # Instead the device is mapped via grub parameter device + # So a grub setup on MBR sda/sdb with /boot on sda1/sdb1 should always be done like: + # device (hd0) /dev/sd(a|b) + # root (hd0,0) + # setup (hd0) + + # get md device either if we use separate /boot or not. + [ -z $bootdev ] && local md=$PART_ROOT || local md=$bootdev + + local ask_str="Do you want to install grub to the MBR of each harddisk from your BOOT array "$md" ? (recommended)" + ask_yesno "$ask_str" yes + if [ $? -eq 0 ]; then slaves=$(mdraid_all_slaves $md) - for slave in $slaves; do - boothd=$(echo $slave | cut -c -8) - bootpart=$(mdraid_slave0 $md) - bootdev=$(echo $bootpart | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - done - else - # This part needs more attention... User could select here only - # a other blockdevice to install grub into... But our grub rootdevice - # is not selectable, cause it is determined either from PART_ROOT or - # bootdev. - # Maybe better we leave the user alone and poke him to use a grub - # shell if he want do something unusefull and not install grub in - # aech MBR of affected HD in raid array.... - local USERHAPPY=0 - while [ "$USERHAPPY" = 0 ] - do - ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed." required $DEVS DONE _ - [ $? -gt 0 ] && USERHAPPY=1 && break - [ "$ANSWER_OPTION" == DONE ] && USERHAPPY=1 && break - bootdev=$ANSWER_OPTION - boothd=$(echo $bootdev | cut -c -8) - bootpart=$(mdraid_slave0 $md) - bootdev=$(echo $bootpart | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - done + for slave in $slaves; do + boothd=$(echo $slave | cut -c -8) + bootpart=$(mdraid_slave0 $md) + bootdev=$(echo $bootpart | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + done + else + # This part needs more attention... User could select here only + # a other blockdevice to install grub into... But our grub rootdevice + # is not selectable, cause it is determined either from PART_ROOT or + # bootdev. + # Maybe better we leave the user alone and poke him to use a grub + # shell if he want do something unusefull and not install grub in + # aech MBR of affected HD in raid array.... + local USERHAPPY=0 + while [ "$USERHAPPY" = 0 ] + do + ask_option no "Boot device selection" "Select the boot device where the GRUB bootloader will be installed." required $DEVS DONE _ + [ $? -gt 0 ] && USERHAPPY=1 && break + [ "$ANSWER_OPTION" == DONE ] && USERHAPPY=1 && break + bootdev=$ANSWER_OPTION + boothd=$(echo $bootdev | cut -c -8) + bootpart=$(mdraid_slave0 $md) + bootdev=$(echo $bootpart | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + done fi
- if [ "$bootpart" = "" ]; then - if [ "$PART_ROOT" = "" ]; then - ask_string "Enter the full path to your root device" "/dev/sda3" || return 1 - bootpart=$ANSWER_STRING - else - bootpart=$PART_ROOT - fi - boothd=$(echo $bootpart | cut -c -8) - interactive_grub_install $bootpart $bootdev $boothd - if [ $? -eq 0 ]; then - GRUB_OK=1 - fi - fi - fi - # unfreeze xfs filesystems - for xfsdev in $(blkid -t TYPE=xfs -o device); do - mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) - if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then - /usr/sbin/xfs_freeze -u $mnt > /dev/null 2>&1 - fi - done - - if [ "$GRUB_OK" == "1" ]; then - notify "GRUB was successfully installed." - else - show_warning "Grub installation failure" "GRUB was NOT successfully installed." - return 1 - fi - return 0 - fi + if [ "$bootpart" = "" ]; then + if [ "$PART_ROOT" = "" ]; then + ask_string "Enter the full path to your root device" "/dev/sda3" || return 1 + bootpart=$ANSWER_STRING + else + bootpart=$PART_ROOT + fi + boothd=$(echo $bootpart | cut -c -8) + interactive_grub_install $bootpart $bootdev $boothd + if [ $? -eq 0 ]; then + GRUB_OK=1 + fi + fi + fi + # unfreeze xfs filesystems + for xfsdev in $(blkid -t TYPE=xfs -o device); do + mnt=$(mount | grep $xfsdev | cut -d' ' -f 3) + if [ $mnt = "$var_TARGET_DIR/boot" -o $mnt = "$var_TARGET_DIR/" ]; then + /usr/sbin/xfs_freeze -u $mnt > /dev/null 2>&1 + fi + done + + if [ "$GRUB_OK" == "1" ]; then + notify "GRUB was successfully installed." + else + show_warning "Grub installation failure" "GRUB was NOT successfully installed." + return 1 + fi + return 0 + fi }
generate_grub_menulst() { @@ -1080,14 +1080,14 @@ interactive_bootloader_menu() { if [[ $1 = GRUB ]]; then generate_grub_menulst fi - + grep -q '^/dev/mapper' $TMP_FSTAB && local helptext=" /dev/mapper/ users: Pay attention to the kernel line!" notify "Before installing $1, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install $1.$helptext" - + if [[ -z $EDITOR ]]; then seteditor || return 1 fi - + $EDITOR $2 }
@@ -1102,7 +1102,7 @@ interactive_grub_install () { # The boothd - Only on md raid setups this differs from bootdev # These values get parsed either from values we have already or from # user input. Later they will converted to grub-legacy notation. - + # Convert to grub-legacy notation local bootpart=$(mapdev $1) if [ -z "$bootpart" ]; then @@ -1118,7 +1118,7 @@ interactive_grub_install () { debug FS "bootpart: $bootpart" debug FS "bootdev: $bootdev" debug FS "boothd: $boothd" - + $var_TARGET_DIR/sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <<EOF device $bootdev $boothd root $bootpart @@ -1220,7 +1220,6 @@ interactive_select_source() { return 0 }
- # Prompt user for preferred mirror and set $var_SYNC_URL # args: none # returns: nothing -- 1.7.4
On 02/08/2011 09:07 PM, C Anthony Risinger wrote:
Gross; are other files tabs? 4 spaces is pretty common thing; it's not difficult to tell your editor to insert spaces for tabs, and to behave in a tab-like manner, eg softtab/tabstop/etc in vim.
C Anthony [mobile] On Feb 8, 2011 7:53 PM,<pyther@pyther.net> wrote:
Haha, I also prefer spaces. Most of lib-ui-interactive and lib-ui-blockdevice are using tabs. However, there are some functions that are using spaces for indentation. The boot loader code was one such section. Dieter has told me that he wants to use tabs instead of spaces. pyther
Applying: Bootloader Code - use tabs for indentations instead of spaces /home/dieter/workspaces/eclipse/aif/.git/rebase-apply/patch:71: trailing whitespace. interactive_bootloader_menu "GRUB" $grubmenu error: patch failed: src/core/libs/lib-ui-interactive.sh:860 error: src/core/libs/lib-ui-interactive.sh: patch does not apply Patch failed at 0001 Bootloader Code - use tabs for indentations instead of spaces you probably forgot to rebase on top of my changes from yesterday. Dieter
Solves issue where helptext was global and bleed into interactive_bootloader_menu --- src/core/libs/lib-ui-interactive.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 144749a..b4c9467 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -57,6 +57,7 @@ interactive_configure_system() fi local default=no + local helptext while true; do helptext="\nNote that if you want to change any file not listed here (unlikely) you can go to another tty and update ${var_TARGET_DIR}/etc/<filename> yourself" grep -q '^/dev/mapper' $TMP_FSTAB && helptext="$helptext\n/dev/mapper/ users: Pay attention to HOOKS in mkinitcpio.conf" -- 1.7.4
On Tue, 8 Feb 2011 20:52:51 -0500 pyther@pyther.net wrote:
Solves issue where helptext was global and bleed into interactive_bootloader_menu --- src/core/libs/lib-ui-interactive.sh | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 144749a..b4c9467 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -57,6 +57,7 @@ interactive_configure_system() fi
local default=no + local helptext while true; do helptext="\nNote that if you want to change any file not listed here (unlikely) you can go to another tty and update ${var_TARGET_DIR}/etc/<filename> yourself" grep -q '^/dev/mapper' $TMP_FSTAB && helptext="$helptext\n/dev/mapper/ users: Pay attention to HOOKS in mkinitcpio.conf"
this would only be needed because in your previous patch you removed the 'helptext=' line, but you have a point in that the helptext variable should be local, both here and in the interactive_grub_menulst() function. Dieter
On Tue, 8 Feb 2011 20:52:49 -0500 pyther@pyther.net wrote:
In addition to the rename, the function was updated to be flexible with the use of multiple bootloaders. --- src/core/libs/lib-ui-interactive.sh | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 45d3282..a2d5759 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -886,7 +886,7 @@ interactive_grub() { fi fi # Create and edit the grub menu.lst - interactive_grub_menulst + interactive_bootloader_menu "GRUB" $grubmenu
DEVS="$(findblockdevices '_ ')" if [ "$DEVS" = " " ]; then @@ -1073,13 +1073,22 @@ initrd $subdir/kernel26-fallback.img EOF }
-interactive_grub_menulst () { - generate_grub_menulst - helptext= - grep -q '^/dev/mapper' $TMP_FSTAB && helptext=" /dev/mapper/ users: Pay attention to the kernel line!" - notify "Before installing GRUB, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install GRUB.$helptext" - seteditor || return 1 - $EDITOR $grubmenu +interactive_bootloader_menu() { + # $1 - Bootloader Name + # $2 - Bootloader Configuration Files + + if [[ $1 = GRUB ]]; then + generate_grub_menulst + fi +
this all seems very premature. you're introducing all kinds of indirections which are unneeded (now). maybe you could do this when introducing syslinux support, but even then, having a separate function per bootloader will probably be preferable.
+ grep -q '^/dev/mapper' $TMP_FSTAB && local helptext=" /dev/mapper/ users: Pay attention to the kernel line!" + notify "Before installing $1, you must review the configuration file. You will now be put into the editor. After you save your changes and exit the editor, you can install $1.$helptext" + + if [[ -z $EDITOR ]]; then + seteditor || return 1 + fi
why?? the original seteditor call was fine, afaict.
+ + $EDITOR $2 }
interactive_grub_install () {
bottomline is: I don't see the usefulness of this patch and would leave it away entirely. when you introduce syslinux support, we can still see what's the best way of doing things. Dieter
participants (4)
-
C Anthony Risinger
-
Dieter Plaetinck
-
Matthew Gyurgyik
-
pyther@pyther.net