[arch-releng] Syslinux Patches - Review
Here are the Syslinux patches that I have been working on for the last month or so. TODO: * Update Documentation accordingly The syslinux installation process relies on a script I wrote, syslinux-install_update, which will be included in the Syslinux arch package. Thomas is going to try to push a new syslinux package, with the script, to testing in the coming days. If there are no problems the package, then it will be moved to core. # Patch 3 - Prompt user to pick a bootloader in interactive_select_packages As per my discussion with Dieter, we now ask the user what bootloader they want to use during package selection. We then select the appropriate package for installation. The bootloader that the user picked gets stored in a variable (bootloader) and referenced at "Install Bootloader" where it triggers either interactive_grub or interactive_syslinux. Without this new functionality, if the user did not manually select a bootloader in "Select Packages" they would have to go back, select a bootloader, reinstall the packages, etc...
Function was updated to be flexible with the use of multiple bootloaders --- src/core/libs/lib-ui-interactive.sh | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index b244a6e..85a3a5f 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -883,7 +883,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 @@ -1070,15 +1070,6 @@ initrd $subdir/kernel26-fallback.img EOF } -interactive_grub_menulst () { - generate_grub_menulst - local 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_grub_install () { debug FS "interactive_grub_install called. P1 = $1, P2 = $2, P3 = $3" # $1 = bootpart @@ -1120,6 +1111,22 @@ EOF fi } +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" + + seteditor || return 1 + + $EDITOR $2 +} + get_kernel_parameters() { get_device_with_mount '/' || return 1 local rootpart="$ANSWER_DEVICE" -- 1.7.4.1
On Sun, 20 Feb 2011 23:09:35 -0500 pyther@pyther.net wrote:
Function was updated to be flexible with the use of multiple bootloaders Update function to ... --- src/core/libs/lib-ui-interactive.sh | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index b244a6e..85a3a5f 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -883,7 +883,7 @@ interactive_grub() { fi fi # Create and edit the grub menu.lst - interactive_grub_menulst + interactive_bootloader_menu "GRUB" $grubmenu
why 'GRUB' and not just 'grub' ? I really dislike needless capitalizing.
+interactive_bootloader_menu() { + # $1 - Bootloader Name + # $2 - Bootloader Configuration Files
put the comments *above* the function name.
On 02/21/2011 03:53 PM, Dieter Plaetinck wrote:
On Sun, 20 Feb 2011 23:09:35 -0500 pyther@pyther.net wrote:
Function was updated to be flexible with the use of multiple bootloaders Update function to ... --- src/core/libs/lib-ui-interactive.sh | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index b244a6e..85a3a5f 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -883,7 +883,7 @@ interactive_grub() { fi fi # Create and edit the grub menu.lst - interactive_grub_menulst + interactive_bootloader_menu "GRUB" $grubmenu why 'GRUB' and not just 'grub' ? I really dislike needless capitalizing.
+interactive_bootloader_menu() { + # $1 - Bootloader Name + # $2 - Bootloader Configuration Files put the comments *above* the function name.
You told me to do this in chat and I did. I'm not sure why the patches I submitted didn't reflect this. :( Anyways this is fixed
On 02/21/2011 07:06 PM, Matthew Gyurgyik wrote:
You told me to do this in chat and I did. I'm not sure why the patches I submitted didn't reflect this. :( Anyways this is fixed And this is a perfect example of what happens when I don merge/rebase correctly. The changes were in patch 2 :-/
Sorry!
interactive_syslinux depends on the syslinux-install_update script that is in the Arch Syslinux package. --- src/core/libs/lib-blockdevices-filesystems.sh | 1 + src/core/libs/lib-ui-interactive.sh | 159 +++++++++++++++++++++++-- src/core/procedures/base | 1 + 3 files changed, 153 insertions(+), 8 deletions(-) diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index ac749a3..0ba2070 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -76,6 +76,7 @@ fs_on[dm_crypt]=${fs_on_dm_crypt[@]} fs_mountable=(ext2 ext3 ext4 nilfs2 xfs jfs vfat reiserfs) fs_label_mandatory=('lvm-vg' 'lvm-lv' 'dm_crypt') fs_label_optional=('swap' 'ext2' 'ext3' 'ext4' 'reiserfs' 'nilfs2' 'xfs' 'jfs' 'vfat') +syslinux_supported_fs=('ext2' 'ext3' 'ext4' 'btrfs' 'vfat') # list needed packages per filesystem declare -A filesystem_pkg=(["lvm-pv"]="lvm2" ["xfs"]="xfsprogs" ["jfs"]="jfsutils" ["reiserfs"]="reiserfsprogs" ["nilfs2"]="nilfs-utils" ["vfat"]="dosfstools" ["dm_crypt"]="cryptsetup" ["btrfs"]=btrfs-progs-unstable) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 85a3a5f..16a9600 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -3,6 +3,7 @@ # Global Variables grubmenu="/boot/grub/menu.lst" # be sure to override this if you have it somewhere else +syslinuxmenu="/boot/syslinux/syslinux.cfg" # check if a worker has completed successfully. if not -> tell user he must do it + return 1 # if ok -> don't warn anything and return 0 @@ -845,12 +846,16 @@ 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)" \ + "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ "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 - interactive_grub + if [[ $bl == grub ]]; then + GRUB_OK=0 + interactive_grub + elif [[ $bl == syslinux ]]; then + interactive_syslinux + fi } interactive_grub() { @@ -883,7 +888,7 @@ interactive_grub() { fi fi # Create and edit the grub menu.lst - interactive_bootloader_menu "GRUB" $grubmenu + interactive_bootloader_menu "grub" $grubmenu DEVS="$(findblockdevices '_ ')" if [ "$DEVS" = " " ]; then @@ -1111,12 +1116,150 @@ EOF fi } -interactive_bootloader_menu() { - # $1 - Bootloader Name - # $2 - Bootloader Configuration Files +interactive_syslinux() { + # Check if Syslinux in installed + [[ ! -f "$var_TARGET_DIR/sbin/extlinux" ]] && show_warning "No Syslinux?" "Error: Couldn't find $var_TARGET_DIR/sbin/extlinux. Is SYSLINUX installed?" && return 1 + + debug FS "starting interactive_syslinux" + + # Find and Store the device that has the root filesystem + get_device_with_mount '/' || return 1 + PART_ROOT="$ANSWER_DEVICE" + + # Gets booot device + get_device_with_mount '/boot' + bootdev="$ANSWER_DEVICE" + + # Check to see if /boot or / (root) has a valid FS type and set bootpart + # bootpart == device with /boot dir + if [[ $bootdev ]]; then + filesystem="$(awk '/ \/boot /{print $4}' $TMP_FILESYSTEMS)" + debug FS "$bootdev - FS type: $filesystem" + + local bootpart="$bootdev" + else + filesystem="$(awk '/ \/ /{print $4}' $TMP_FILESYSTEMS)" + debug FS "$PART_ROOT - FS type: $filesystem" + + local bootpart="$PART_ROOT" + fi - if [[ $1 = GRUB ]]; then + if ! check_is_in "$filesystem" "${syslinux_supported_fs[@]}"; then + show_warning "Invalid FS" "Error: Syslinux only supports EXT2/3/4, BTRFS, and VFAT" + return 1 + fi + + # remove default entries by truncating file at our little tag (#-*) + sed -i -e '/#-\*/q' "$syslinuxmenu" + + # Generate menu and prompt user to edit it + interactive_bootloader_menu "syslinux" "$syslinuxmenu" + + if device_is_raid "$bootpart"; then + debug FS "Software RAID detected" + local onraid=true + # Notify the user or trust the scripts? + fi + + debug FS "Installing Syslinux ($var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update)" + inform "Installing Syslinux..." + if ! "$var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update" -i -c /mnt; then + debug FS "FAILED: syslinux-install_update -i -c /mnt failed" + show_warning "FAILED" "syslinux-install_update -i -c /mnt failed" + return 1 + fi + + if ask_yesno "Set boot flag(s) and install the Syslinux MBR?" yes; then + inform "Setting Boot Flag(s)...\nThis could take a while. Please be patient.\n\n" syslinuxprog + "$var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update" -a -c /mnt + rt=$? + case "$rt" in + 0) + debug FS "Successfully set boot flag(s)" + ;; + 1) + debug FS "Failed to set boot flag. Function in syslinux-install_update exited with status $rt" + notify "Failed to set boot flag. MBR not installed!" && return 1 + ;; + 3) + debug FS "Failed to set boot flag(s). syslinux-install_update -a exited with status $rt" + notify "Failed to set boot flag(s)! MBR not installed!" && return 1 + ;; + *) + debug FS "Failde to set boot flag(s). syslinux-install_update -a failed with an unkown Error Code - $rt" + notify "Failed to set boot flag(s). MBR not installed" && return 1 + ;; + esac + + inform "Installing Syslinux MBR..." syslinuxprog + "$var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update" -m -c /mnt + rt=$? + case "$rt" in + 0) + debug FS "Successfully installed MBR(s)" + ;; + 1) + debug FS "Failed install MBR. Function in syslinux-install_update -m exited with status $rt" + notify "Failed to install the MBR!." && return 1 + ;; + 4) + debug FS "Failed to install MBR. syslinux-install_update -m exited with status $rt" + notify "Failed to install MBR!" && return 1 + ;; + *) + debug FS "Failed to install MBR. syslinux-install_update -m failed with an unkown Error Code - $rt" + notify "Failed to install the MBR!" && return 1 + ;; + esac + fi + notify "Syslinux Installation Successful" +} + +generate_syslinux_menu () { + get_kernel_parameters + + cat >>$syslinuxmenu <<EOF + +# (0) Arch Linux +LABEL arch + MENU LABEL Arch Linux + LINUX ../vmlinuz26 + APPEND $kernel_parameters + INITRD ../kernel26.img + +# (1) Arch Linux Fallback +LABEL archfallback + MENU LABEL Arch Linux Fallback + LINUX ../vmlinuz26 + APPEND $kernel_parameters + INITRD ../kernel26-fallback.img + +# (2) Windows +#LABEL windows +#COM32 chain.c32 +#APPEND hd0 0 + +LABEL hdt + MENU LABEL HDT (Hardware Detection Tool) + COM32 hdt.c32 + +LABEL reboot + MENU LABEL Reboot + COM32 reboot.c32 + +LABEL off + MENU LABEL Power Off + COMBOOT poweroff.com +EOF +} + +# $1 - Bootloader Name +# $2 - Bootloader Configuration Files +interactive_bootloader_menu() { + if [[ $1 = grub ]]; then generate_grub_menulst + elif [[ $1 = syslinux ]]; then + generate_syslinux_menu fi grep -q '^/dev/mapper' $TMP_FSTAB && local helptext=" /dev/mapper/ users: Pay attention to the kernel line!" diff --git a/src/core/procedures/base b/src/core/procedures/base index 3ff66b4..bab079b 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -11,6 +11,7 @@ var_UI_TYPE="cli" # set to cli or dia for dialog var_ARCH=`uname -m` #i686 or x86_64. NOTE: this assumes you want to install the same arch as the installation environment you're using. maybe we could decouple those someday.. [ -z "$var_ARCH" ] && die_error "Could not determine your architecture" grubmenu="$var_TARGET_DIR$grubmenu" +syslinuxmenu="$var_TARGET_DIR$syslinuxmenu" ###### Phases ( can be overridden by more specific procedures) ###### phase_preparation=(\ -- 1.7.4.1
Provide. Not provides. btw something is messed up. some of my complaints on your patch 3 are taken care of in patch 2 so you fixed them in patch 2 but redid the issues in patch 3? maybe you should merge patch 2 and 3 On Sun, 20 Feb 2011 23:09:36 -0500 pyther@pyther.net wrote:
interactive_syslinux depends on the syslinux-install_update script that is in the Arch Syslinux package. --- src/core/libs/lib-blockdevices-filesystems.sh | 1 + src/core/libs/lib-ui-interactive.sh | 159 +++++++++++++++++++++++-- src/core/procedures/base | 1 + 3 files changed, 153 insertions(+), 8 deletions(-)
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh index ac749a3..0ba2070 100644 --- a/src/core/libs/lib-blockdevices-filesystems.sh +++ b/src/core/libs/lib-blockdevices-filesystems.sh @@ -76,6 +76,7 @@ fs_on[dm_crypt]=${fs_on_dm_crypt[@]} fs_mountable=(ext2 ext3 ext4 nilfs2 xfs jfs vfat reiserfs) fs_label_mandatory=('lvm-vg' 'lvm-lv' 'dm_crypt') fs_label_optional=('swap' 'ext2' 'ext3' 'ext4' 'reiserfs' 'nilfs2' 'xfs' 'jfs' 'vfat') +syslinux_supported_fs=('ext2' 'ext3' 'ext4' 'btrfs' 'vfat')
# list needed packages per filesystem declare -A filesystem_pkg=(["lvm-pv"]="lvm2" ["xfs"]="xfsprogs" ["jfs"]="jfsutils" ["reiserfs"]="reiserfsprogs" ["nilfs2"]="nilfs-utils" ["vfat"]="dosfstools" ["dm_crypt"]="cryptsetup" ["btrfs"]=btrfs-progs-unstable) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 85a3a5f..16a9600 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -3,6 +3,7 @@
# Global Variables grubmenu="/boot/grub/menu.lst" # be sure to override this if you have it somewhere else +syslinuxmenu="/boot/syslinux/syslinux.cfg"
the comment on the grubmenu lines applies to both variables.
DEVS="$(findblockdevices '_ ')" if [ "$DEVS" = " " ]; then @@ -1111,12 +1116,150 @@ EOF fi }
-interactive_bootloader_menu() { - # $1 - Bootloader Name - # $2 - Bootloader Configuration Files +interactive_syslinux() { + # Check if Syslinux in installed + [[ ! -f "$var_TARGET_DIR/sbin/extlinux" ]] && show_warning "No Syslinux?" "Error: Couldn't find $var_TARGET_DIR/sbin/extlinux. Is SYSLINUX installed?" && return 1 + + debug FS "starting interactive_syslinux" + + # Find and Store the device that has the root filesystem + get_device_with_mount '/' || return 1 + PART_ROOT="$ANSWER_DEVICE" + + # Gets booot device + get_device_with_mount '/boot' + bootdev="$ANSWER_DEVICE" + + # Check to see if /boot or / (root) has a valid FS type and set bootpart + # bootpart == device with /boot dir + if [[ $bootdev ]]; then + filesystem="$(awk '/ \/boot /{print $4}' $TMP_FILESYSTEMS)" + debug FS "$bootdev - FS type: $filesystem" + + local bootpart="$bootdev" + else + filesystem="$(awk '/ \/ /{print $4}' $TMP_FILESYSTEMS)" + debug FS "$PART_ROOT - FS type: $filesystem" + + local bootpart="$PART_ROOT" + fi
- if [[ $1 = GRUB ]]; then + if ! check_is_in "$filesystem" "${syslinux_supported_fs[@]}"; then + show_warning "Invalid FS" "Error: Syslinux only supports EXT2/3/4, BTRFS, and VFAT"
leverage ${syslinux_supported_fs[@]} in the warning
+ return 1 + fi + + # remove default entries by truncating file at our little tag (#-*) + sed -i -e '/#-\*/q' "$syslinuxmenu" + + # Generate menu and prompt user to edit it + interactive_bootloader_menu "syslinux" "$syslinuxmenu" + + if device_is_raid "$bootpart"; then + debug FS "Software RAID detected" + local onraid=true + # Notify the user or trust the scripts? + fi + + debug FS "Installing Syslinux ($var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update)" + inform "Installing Syslinux..." + if ! "$var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update" -i -c /mnt; then + debug FS "FAILED: syslinux-install_update -i -c /mnt failed" + show_warning "FAILED" "syslinux-install_update -i -c /mnt failed" + return 1 + fi + + if ask_yesno "Set boot flag(s) and install the Syslinux MBR?" yes; then + inform "Setting Boot Flag(s)...\nThis could take a while. Please be patient.\n\n" syslinuxprog + "$var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update" -a -c /mnt + rt=$? + case "$rt" in + 0) + debug FS "Successfully set boot flag(s)" + ;; + 1) + debug FS "Failed to set boot flag. Function in syslinux-install_update exited with status $rt" + notify "Failed to set boot flag. MBR not installed!" && return 1 + ;; + 3) + debug FS "Failed to set boot flag(s). syslinux-install_update -a exited with status $rt" + notify "Failed to set boot flag(s)! MBR not installed!" && return 1 + ;; + *) + debug FS "Failde to set boot flag(s). syslinux-install_update -a failed with an unkown Error Code - $rt" + notify "Failed to set boot flag(s). MBR not installed" && return 1 + ;; + esac + + inform "Installing Syslinux MBR..." syslinuxprog + "$var_TARGET_DIR/usr/lib/syslinux/syslinux-install_update" -m -c /mnt + rt=$? + case "$rt" in + 0) + debug FS "Successfully installed MBR(s)" + ;; + 1) + debug FS "Failed install MBR. Function in syslinux-install_update -m exited with status $rt" + notify "Failed to install the MBR!." && return 1 + ;; + 4) + debug FS "Failed to install MBR. syslinux-install_update -m exited with status $rt" + notify "Failed to install MBR!" && return 1 + ;; + *) + debug FS "Failed to install MBR. syslinux-install_update -m failed with an unkown Error Code - $rt" + notify "Failed to install the MBR!" && return 1 + ;; + esac + fi + notify "Syslinux Installation Successful" +} + +generate_syslinux_menu () { + get_kernel_parameters + + cat >>$syslinuxmenu <<EOF + +# (0) Arch Linux +LABEL arch + MENU LABEL Arch Linux + LINUX ../vmlinuz26 + APPEND $kernel_parameters + INITRD ../kernel26.img + +# (1) Arch Linux Fallback +LABEL archfallback + MENU LABEL Arch Linux Fallback + LINUX ../vmlinuz26 + APPEND $kernel_parameters + INITRD ../kernel26-fallback.img + +# (2) Windows +#LABEL windows +#COM32 chain.c32 +#APPEND hd0 0 + +LABEL hdt + MENU LABEL HDT (Hardware Detection Tool) + COM32 hdt.c32 + +LABEL reboot + MENU LABEL Reboot + COM32 reboot.c32 + +LABEL off + MENU LABEL Power Off + COMBOOT poweroff.com +EOF +} + +# $1 - Bootloader Name +# $2 - Bootloader Configuration Files +interactive_bootloader_menu() { + if [[ $1 = grub ]]; then generate_grub_menulst + elif [[ $1 = syslinux ]]; then + generate_syslinux_menu fi
--- src/core/libs/lib-ui-interactive.sh | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 16a9600..3cbbc00 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -715,7 +715,7 @@ interactive_select_packages() { target_prepare_pacman || { show_warning 'Pacman preparation failure' "Pacman preparation failed! Check $LOG for errors."; return 1; } repos=`list_pacman_repos target` - notify "Package selection is split into two stages. First you will select package groups that contain packages you may be interested in. Then you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n + notify "Package selection is split into three stages. First, you will select a bootloader. Then, you will select package groups that contain packages that you may be interested in. Lastly, you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n Note that right now the packages (and groups) selection is limited to the repos available at this time ($repos). Once you have your Arch system up and running, you have access to more repositories and packages.\n\n If any previous configuration you've done until now (like fancy filesystems) require extra packages, we've already preselected them for your convenience" @@ -725,6 +725,20 @@ If any previous configuration you've done until now (like fancy filesystems) req grouplist+=(${i} - OFF) done + ask_option Grub "Choose bootloader" "Which bootloader would you like to use?" required \ + "Grub" "Use the GRUB bootloader" \ + "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ + "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 + + # Convert to lower case + bootloader=${ANSWER_OPTION,,} + + if [[ $bootloader = grub ]]; then + local needed_pkg_bootloader=grub + elif [[ $bootloader = syslinux ]]; then + local needed_pkg_bootloader=syslinux + fi + ask_checklist "Select Package groups\nDo not deselect base unless you know what you're doing!" 0 "${grouplist[@]}" || return 1 grouplist=("${ANSWER_CHECKLIST[@]}") @@ -735,6 +749,7 @@ If any previous configuration you've done until now (like fancy filesystems) req # build the list of options, sorted primarily by group, then by packagename (this is already). marking where appropriate local pkglist=() needed_pkgs=("${needed_pkgs_fs[@]}") + needed_pkgs+=("$needed_pkg_bootloader") while read pkgname pkgver pkggroup pkgdesc; do mark=OFF if check_is_in "$pkggroup" "${grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"; then @@ -843,18 +858,15 @@ interactive_runtime_network() { return 0 } +# bootloader is global variable that gets set in interactive_select_packages 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)" \ - "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ - "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 - - bl=`tr '[:upper:]' '[:lower:]' <<< "$ANSWER_OPTION"` - if [[ $bl == grub ]]; then + if [[ $bootloader = grub ]]; then GRUB_OK=0 interactive_grub - elif [[ $bl == syslinux ]]; then + elif [[ $bootloader = syslinux ]]; then interactive_syslinux + else + show_warning 'No Bootloader' 'You did not select a bootloader. No bootloader will be installed.' && return 1 fi } -- 1.7.4.1
On Sun, 20 Feb 2011 23:09:37 -0500 pyther@pyther.net wrote:
--- src/core/libs/lib-ui-interactive.sh | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 16a9600..3cbbc00 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -715,7 +715,7 @@ interactive_select_packages() { target_prepare_pacman || { show_warning 'Pacman preparation failure' "Pacman preparation failed! Check $LOG for errors."; return 1; }
repos=`list_pacman_repos target` - notify "Package selection is split into two stages. First you will select package groups that contain packages you may be interested in. Then you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n + notify "Package selection is split into three stages. First, you will select a bootloader. Then, you will select package groups that contain packages that you may be interested in. Lastly, you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n Note that right now the packages (and groups) selection is limited to the repos available at this time ($repos). Once you have your Arch system up and running, you have access to more repositories and packages.\n\n If any previous configuration you've done until now (like fancy filesystems) require extra packages, we've already preselected them for your convenience"
@@ -725,6 +725,20 @@ If any previous configuration you've done until now (like fancy filesystems) req grouplist+=(${i} - OFF) done
+ ask_option Grub "Choose bootloader" "Which bootloader would you like to use?" required \ + "Grub" "Use the GRUB bootloader" \ + "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ + "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 + + # Convert to lower case + bootloader=${ANSWER_OPTION,,}
make the options lowercase in the first place. like we discussed on IRC, it would be beneficial to: * in lib-blockdevices-filesystems.sh put something like: supported_bootloaders=(syslinux grub) # must be packagenames, first one will be default * leverage that array, also leverage syslinux_supported_fs for the menu
+ + if [[ $bootloader = grub ]]; then + local needed_pkg_bootloader=grub + elif [[ $bootloader = syslinux ]]; then + local needed_pkg_bootloader=syslinux + fi how about something like: check_is_in $ANSWER_OPTION ('grub' 'syslinux') || return 1 local needed_pkg_bootloader=$ANSWER_OPTION
+ ask_checklist "Select Package groups\nDo not deselect base unless you know what you're doing!" 0 "${grouplist[@]}" || return 1 grouplist=("${ANSWER_CHECKLIST[@]}")
@@ -735,6 +749,7 @@ If any previous configuration you've done until now (like fancy filesystems) req # build the list of options, sorted primarily by group, then by packagename (this is already). marking where appropriate local pkglist=() needed_pkgs=("${needed_pkgs_fs[@]}") + needed_pkgs+=("$needed_pkg_bootloader") while read pkgname pkgver pkggroup pkgdesc; do mark=OFF if check_is_in "$pkggroup" "${grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"; then @@ -843,18 +858,15 @@ interactive_runtime_network() { return 0 }
+# bootloader is global variable that gets set in interactive_select_packages 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)" \ - "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ - "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 - - bl=`tr '[:upper:]' '[:lower:]' <<< "$ANSWER_OPTION"` - if [[ $bl == grub ]]; then + if [[ $bootloader = grub ]]; then GRUB_OK=0 interactive_grub - elif [[ $bl == syslinux ]]; then + elif [[ $bootloader = syslinux ]]; then interactive_syslinux + else + show_warning 'No Bootloader' 'You did not select a bootloader. No bootloader will be installed.' && return 1
"no bootloader" is an accepted solution -> return 0, not 1 ! otherwise the step will register as failed.
On 02/21/2011 03:50 PM, Dieter Plaetinck wrote: > On Sun, 20 Feb 2011 23:09:37 -0500 > pyther@pyther.net wrote: > >> --- >> src/core/libs/lib-ui-interactive.sh | 30 +++++++++++++++++++++--------- >> 1 files changed, 21 insertions(+), 9 deletions(-) >> >> diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh >> index 16a9600..3cbbc00 100644 >> --- a/src/core/libs/lib-ui-interactive.sh >> +++ b/src/core/libs/lib-ui-interactive.sh >> @@ -715,7 +715,7 @@ interactive_select_packages() { >> target_prepare_pacman || { show_warning 'Pacman preparation failure' "Pacman preparation failed! Check $LOG for errors."; return 1; } >> >> repos=`list_pacman_repos target` >> - notify "Package selection is split into two stages. First you will select package groups that contain packages you may be interested in. Then you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n >> + notify "Package selection is split into three stages. First, you will select a bootloader. Then, you will select package groups that contain packages that you may be interested in. Lastly, you will be presented with a full list of packages for each group, allowing you to fine-tune.\n\n >> Note that right now the packages (and groups) selection is limited to the repos available at this time ($repos). Once you have your Arch system up and running, you have access to more repositories and packages.\n\n >> If any previous configuration you've done until now (like fancy filesystems) require extra packages, we've already preselected them for your convenience" >> >> @@ -725,6 +725,20 @@ If any previous configuration you've done until now (like fancy filesystems) req >> grouplist+=(${i} - OFF) >> done >> >> + ask_option Grub "Choose bootloader" "Which bootloader would you like to use?" required \ >> + "Grub" "Use the GRUB bootloader" \ >> + "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ >> + "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 >> + >> + # Convert to lower case >> + bootloader=${ANSWER_OPTION,,} > make the options lowercase in the first place. > like we discussed on IRC, it would be beneficial to: > * in lib-blockdevices-filesystems.sh put something like: > supported_bootloaders=(syslinux grub) # must be packagenames, first one will > be default > * leverage that array, also leverage syslinux_supported_fs for the menu > > >> + >> + if [[ $bootloader = grub ]]; then >> + local needed_pkg_bootloader=grub >> + elif [[ $bootloader = syslinux ]]; then >> + local needed_pkg_bootloader=syslinux >> + fi > how about something like: > check_is_in $ANSWER_OPTION ('grub' 'syslinux') || return 1 > local needed_pkg_bootloader=$ANSWER_OPTION > >> + >> ask_checklist "Select Package groups\nDo not deselect base unless you know what you're doing!" 0 "${grouplist[@]}" || return 1 >> grouplist=("${ANSWER_CHECKLIST[@]}") >> >> @@ -735,6 +749,7 @@ If any previous configuration you've done until now (like fancy filesystems) req >> # build the list of options, sorted primarily by group, then by packagename (this is already). marking where appropriate >> local pkglist=() >> needed_pkgs=("${needed_pkgs_fs[@]}") >> + needed_pkgs+=("$needed_pkg_bootloader") >> while read pkgname pkgver pkggroup pkgdesc; do >> mark=OFF >> if check_is_in "$pkggroup" "${grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"; then >> @@ -843,18 +858,15 @@ interactive_runtime_network() { >> return 0 >> } >> >> +# bootloader is global variable that gets set in interactive_select_packages >> 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)" \ >> - "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ >> - "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 >> - >> - bl=`tr '[:upper:]' '[:lower:]'<<< "$ANSWER_OPTION"` >> - if [[ $bl == grub ]]; then >> + if [[ $bootloader = grub ]]; then >> GRUB_OK=0 >> interactive_grub >> - elif [[ $bl == syslinux ]]; then >> + elif [[ $bootloader = syslinux ]]; then >> interactive_syslinux >> + else >> + show_warning 'No Bootloader' 'You did not select a bootloader. No bootloader will be installed.'&& return 1 > "no bootloader" is an accepted solution -> return 0, not 1 ! otherwise the step will register as failed. > > I know we (Dieter and I) chatted about using $supported_bootloaders for ask_option but I couldn't figure out any useful way to provide additional information next to the bootloader without creating an array like this. supported_bootloaders=(syslinux "some info" grub "some more info") which would seem to defeat the purpose of supported_bootloader. Here is a DIFF of the changes I made: --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -711,6 +711,7 @@ device type label size type create? mountpoint options label params" required "$ # params: none # returns: 1 on error interactive_select_packages() { + local needed_pkgs=() # set up our install location if necessary and sync up so we can get package lists target_prepare_pacman || { show_warning 'Pacman preparation failure' "Pacman preparation failed! Check $LOG for errors."; return 1; } @@ -726,19 +727,12 @@ If any previous configuration you've done until now (like fancy filesystems) req grouplist+=(${i} - OFF) done - ask_option Grub "Choose bootloader" "Which bootloader would you like to use?" required \ - "Grub" "Use the GRUB bootloader" \ - "Syslinux" "Use the Syslinux bootloader (ext2/3/4, btrfs, and vfat)" \ - "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" || return 1 + ask_option no "Choose bootloader" "Which bootloader would you like to use?" optional \ + "grub" "GRUB bootloader" \ + "syslinux" "Syslinux bootloader (${syslinux_supported_fs[@]})" - # Convert to lower case - bootloader=${ANSWER_OPTION,,} - - if [[ $bootloader = grub ]]; then - local needed_pkg_bootloader=grub - elif [[ $bootloader = syslinux ]]; then - local needed_pkg_bootloader=syslinux - fi + # Make sure selected bootloader is a supported_bootloader and mark bootloader for installation + check_is_in $ANSWER_OPTION "${supported_bootloaders[@]}" && needed_pkgs+=("$ANSWER_OPTION") ask_checklist "Select Package groups\nDo not deselect base unless you know what you're doing!" 0 "${grouplist[@]}" || return 1 grouplist=("${ANSWER_CHECKLIST[@]}") @@ -747,10 +741,11 @@ If any previous configuration you've done until now (like fancy filesystems) req local pkgall=($(list_packages repo core | cut -d ' ' -f2)) pkginfo "${pkgall[@]}" + # packages that should be marked for installation + needed_pkgs=("${needed_pkgs_fs[@]}") + # build the list of options, sorted primarily by group, then by packagename (this is already). marking where appropriate local pkglist=() - needed_pkgs=("${needed_pkgs_fs[@]}") - needed_pkgs+=("$needed_pkg_bootloader") while read pkgname pkgver pkggroup pkgdesc; do mark=OFF if check_is_in "$pkggroup" "${grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"; then @@ -867,7 +862,7 @@ interactive_install_bootloader () { elif [[ $bootloader = syslinux ]]; then interactive_syslinux else - show_warning 'No Bootloader' 'You did not select a bootloader. No bootloader will be installed.' && return 1 + show_warning 'No Bootloader' 'You did not select a bootloader. No bootloader will be installed.' && return 0 fi }
On Mon, Feb 21, 2011 at 7:59 PM, Matthew Gyurgyik <pyther@pyther.net> wrote:
I know we (Dieter and I) chatted about using $supported_bootloaders for ask_option but I couldn't figure out any useful way to provide additional information next to the bootloader without creating an array like this. supported_bootloaders=(syslinux "some info" grub "some more info") which would seem to defeat the purpose of supported_bootloader.
i'm not sure 100% what all you have going on here, but i use a lot of heredocs in these bash "data table" situations: ----------------------------------------------------------------------- #!/bin/bash key=none val=none echo -e "START\n[key] $key" "[val] $val\n" process_opts () { while IFS="=" read k v; do # can't use key/val directly because # last loop (EOF) will reset them! key="$k" val="$v" echo "[key] $key" "[val] $val" done } process_opts <<EOF grub=A nice long explantaion about grub :-) syslinux=And that's why we are teh awesome! insert_here=I'm just along for the ride EOF echo -e "\nEND\n[key] $key" "[val] $val" ----------------------------------------------------------------------- you feed the heredoc into a function, which then processes the data as stdin. as IFS controls word splitting, and rather then setting/restoring it, we augment it for the specific calls we need. in this case i chose an `=`, but it could be anything. but default it uses spaces/tabs so you'll prob want to change it. another approach with the same effect, but possibly more useful in your case as the table is persistent via variable: ----------------------------------------------------------------------- #!/bin/bash key=none val=none opts="grub=A nice long explantaion about grub :-) syslinux=And that's why we are teh awesome! insert_here=I'm just along for the ride" echo -e "START\n[key] $key" "[val] $val\n" while IFS="=" read k v; do key="$k" val="$v" echo "[key] $key" "[val] $val" done <<<"$opts" echo -e "\nEND\n[key] $key" "[val] $val" ----------------------------------------------------------------------- the only downside to the above is that `" ... "` means you have to worry about more escaping. also note the quotes -- `<<<"$opts"` -- they are critical! else the newlines become spaces. personally i like heredocs because they are made for exactly this use, and look clean. some other info ... store heredoc in variable (best of both examples, at cost of `cat` call and subshell): opts=$(cat <<EOF ... EOF) EVERYTHING in a heredoc is literal (variables/slashes/etc) [note the preceding `\`; quotes work too] process_opts <<\EOF ... EOF suppress leading tabs (so you can indent for readability) [note the preceding `-`] process_opts <<-EOF ... EOF EOF is just what i use; it can be any string. http://tldp.org/LDP/abs/html/here-docs.html C Anthony
On Mon, Feb 21, 2011 at 9:34 PM, C Anthony Risinger <anthony@extof.me> wrote:
store heredoc in variable (best of both examples, at cost of `cat` call and subshell):
opts=$(cat <<EOF ... EOF)
... and something else just for grins :-) as i didn't think of it until right after i sent my msg ... --------------------------------- read -rd $'\0' opts <<EOF grub=A nice long explantaion about grub :-) syslinux=And that's why we are teh awesome! insert_here=I'm just along for the ride EOF echo "$opts" --------------------------------- that will store the entire heredoc into $opts (remember to use quotes for output of course); since null is used as a delimiter, and bash variables/strings are not capable of storing null, this guarantees the entire doc will be in `$opts`. it really is ridiculous what bash is capable of ... anyways, carry on, nothing to see here. C Anthony
Matthew, how about making supported bootloaders an associative array, key being the package name, and value the description? (in the description for syslinux you can then reference syslinux_supported_fs) there are some examples of associative arrays in lib-blockdevices-filesystems.sh you can as easily collect the keys (IIRC use [@] instead of [*] or something) as the values themselves, I do this in some places in aif, but google can tell you aswell. Dieter
participants (4)
-
C Anthony Risinger
-
Dieter Plaetinck
-
Matthew Gyurgyik
-
pyther@pyther.net