summaryrefslogtreecommitdiff
path: root/src/core/libs/lib-ui-interactive.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/libs/lib-ui-interactive.sh')
-rw-r--r--src/core/libs/lib-ui-interactive.sh157
1 files changed, 139 insertions, 18 deletions
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 9399e59..4caf4bc 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -2,7 +2,9 @@
# A library which allows you to do backend stuff by using user interfaces
# Global Variables
-grubmenu="/boot/grub/menu.lst" # be sure to override this if you have it somewhere else
+# Be sure to override these if you have the configuration file elsewhere
+grubmenu="/boot/grub/menu.lst"
+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
@@ -42,7 +44,7 @@ postconfigure_target () {
local failed=()
target_run_mkinitcpio || failed+=('mkinitcpio creation')
target_locale-gen || failed+=('locale generation')
- cp /etc/localtime ${var_TARGET_DIR}/etc/localtime || failed+=('localtime copying')
+ target_localtime || failed+=('localtime copying')
[ ${#failed[@]} -gt 0 ] && warn_failed 'Postconfigure' "${failed[@]}" && return 1
return 0
}
@@ -72,8 +74,6 @@ interactive_configure_system()
"/etc/modprobe.d/modprobe.conf" "Kernel Modules"
"/etc/resolv.conf" "DNS Servers"
"/etc/hosts" "Network Hosts"
- "/etc/hosts.deny" "Denied Network Services"
- "/etc/hosts.allow" "Allowed Network Services"
"/etc/locale.gen" "Glibc Locales"
"/etc/pacman.conf" "Pacman.conf"
"$var_MIRRORLIST" "Pacman Mirror List"
@@ -120,14 +120,23 @@ interactive_configure_system()
interactive_timezone () {
ask_timezone || return 1
TIMEZONE=$ANSWER_TIMEZONE
- inform "Setting Timezone to $TIMEZONE"
- if [ -n "$TIMEZONE" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]
+ return 0
+}
+
+# this should be executed, whether the user changed $TIMEZONE or not
+copy_timezone_file () {
+ if [ -z "$TIMEZONE" ]
then
- # This changes probably also the systemtime (UTC->$TIMEZONE)!
- # localtime users will have a false time after that!
- /bin/rm -f /etc/localtime || return 1
- /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime || return 1
+ debug UI-INTERACTIVE "\$TIMEZONE is empty, not creating/updating /etc/localtime"
+ return 0
fi
+ debug UI-INTERACTIVE "Setting Timezone to $TIMEZONE"
+ local file="/usr/share/zoneinfo/$TIMEZONE"
+ [ -e "$file" ] || die_error "No such timezone file: $file, did you choose a non-existing timezone?"
+ # This changes probably also the systemtime (UTC->$TIMEZONE)!
+ # localtime users will have a false time after that!
+ /bin/rm -f /etc/localtime || return 1
+ /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime || return 1
return 0
}
@@ -744,7 +753,8 @@ them for your convenience"
done
ask_option no "Choose bootloader" "Which bootloader would you like to use?" optional \
- "grub" "GRUB bootloader"
+ "grub" "GRUB bootloader" \
+ "syslinux" "Syslinux bootloader (${syslinux_supported_fs[*]})"
bootloader=$ANSWER_OPTION
@@ -761,7 +771,7 @@ them for your convenience"
# 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_pkgs_fs[@]}")
while read pkgname pkgver pkggroup pkgdesc; do
mark=OFF
if check_is_in "$pkggroup" "${grouplist[@]}" || check_is_in $pkgname "${needed_pkgs[@]}"; then
@@ -875,6 +885,8 @@ interactive_install_bootloader () {
if [[ $bootloader = grub ]]; then
GRUB_OK=0
interactive_grub || return 1
+ elif [[ $bootloader = syslinux ]]; then
+ interactive_syslinux || return 1
else
show_warning 'No Bootloader' 'You did not select a bootloader. No bootloader will be installed.'
fi
@@ -913,7 +925,7 @@ interactive_grub() {
# Create and edit the grub menu.lst
interactive_bootloader_menu "grub" $grubmenu
- DEVS="$(find_usable_blockdevices '_ ')"
+ DEVS="$(finddisks '_ ')"
if [ "$DEVS" = " " ]; then
notify "No hard drives were found"
return 1
@@ -1081,14 +1093,14 @@ generate_grub_menulst() {
# (0) Parabola GNU/Linux-Libre
title Parabola GNU/Linux-Libre
root $grubdev
-kernel $subdir/vmlinuz26 $kernel_parameters
-initrd $subdir/kernel26.img
+kernel $subdir/vmlinuz-linux $kernel_parameters
+initrd $subdir/initramfs-linux.img
# (1) Parabola GNU/Linux-Libre
title Parabola GNU/Linux-Libre Fallback
root $grubdev
-kernel $subdir/vmlinuz26 $kernel_parameters
-initrd $subdir/kernel26-fallback.img
+kernel $subdir/vmlinuz-linux $kernel_parameters
+initrd $subdir/initramfs-linux-fallback.img
EOF
}
@@ -1134,11 +1146,120 @@ EOF
fi
}
+interactive_syslinux() {
+ 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 boot 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 ! check_is_in "$filesystem" "${syslinux_supported_fs[@]}"; then
+ show_warning "Invalid FS" "Error: Syslinux does not support $filesystem.\n\nThe following filesystems are supported:\n ${syslinux_supported_fs[@]}"
+ 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
+ fi
+
+ debug FS "Installing Syslinux ($var_TARGET_DIR/usr/sbin/syslinux-install_update -i -c /mnt)"
+ inform "Installing Syslinux..."
+ if ! "$var_TARGET_DIR/usr/sbin/syslinux-install_update" -i -c /mnt >$LOG 2>&1; 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
+ if "$var_TARGET_DIR/usr/sbin/syslinux-install_update" -a -c /mnt >$LOG 2>&1; then
+ debug FS "Successfully set boot flag(s)"
+ else
+ debug FS "Failde to set boot flag(s). syslinux-install_update -a failed with Error Code - $?"
+ show_warning "FAILED" "Failed to set boot flag(s). MBR not installed" && return 1
+ fi
+
+ inform "Installing Syslinux MBR..." syslinuxprog
+ if "$var_TARGET_DIR/usr/sbin/syslinux-install_update" -m -c /mnt >$LOG 2>&1; then
+ debug FS "Successfully installed MBR(s)"
+ else
+ debug FS "Failed to install MBR. syslinux-install_update -m failed with Error Code - $?"
+ show_warning "FAILED" "Failed to install the MBR!" && return 1
+ fi
+ fi
+ notify "Syslinux Installation Successful"
+}
+
+generate_syslinux_menu () {
+ get_kernel_parameters || return
+
+ 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
+ generate_grub_menulst || return
+ elif [[ $1 = syslinux ]]; then
+ generate_syslinux_menu || return
fi
grep -q '^/dev/mapper' $TMP_FSTAB && local helptext=" /dev/mapper/ users: Pay attention to the kernel line!"