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

Reply via email to