summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2008-11-03 17:43:26 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2008-11-03 17:43:26 +0100
commita407cdfcde2d5d9058c15296ecce35814ffd38a1 (patch)
tree60efe59cc5777d84e3dee769515e847df28eac57 /src
parent69489c9c5c78a2b3c4fbdf4306d18584eeeb12ef (diff)
added infofy function that wraps around dialog --infobox + various cleanups in UI stuff
Diffstat (limited to 'src')
-rw-r--r--src/core/libs/lib-ui-interactive.sh92
-rw-r--r--src/core/libs/lib-ui.sh14
-rw-r--r--src/core/procedures/interactive24
3 files changed, 68 insertions, 62 deletions
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index f638c0e..d35b6a4 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -7,7 +7,7 @@ interactive_partition() {
# Select disk to partition
DISCS=$(finddisks _)
DISCS="$DISCS OTHER - DONE +"
- _dia_DIALOG --msgbox "Available Disks:\n\n$(_getavaildisks)\n" 0 0
+ notify "Available Disks:\n\n$(_getavaildisks)\n" 0 0
DISC=""
while true; do
# Prompt the user with a list of known disks
@@ -121,7 +121,7 @@ interactive_autoprepare()
{
DISCS=$(finddisks)
if [ $(echo $DISCS | wc -w) -gt 1 ]; then
- _dia_DIALOG --msgbox "Available Disks:\n\n$(_getavaildisks)\n" 0 0
+ notify "Available Disks:\n\n$(_getavaildisks)\n" 0 0
_dia_DIALOG --menu "Select the hard drive to use" 14 55 7 $(finddisks _) 2>$ANSWER || return 1
DISC=$(cat $ANSWER)
else
@@ -143,10 +143,10 @@ interactive_autoprepare()
_dia_DIALOG --inputbox "Enter the size (MB) of your /boot partition. Minimum value is 16.\n\nDisk space left: $DISC_SIZE MB" 8 65 "32" 2>$ANSWER || return 1
BOOT_PART_SIZE="$(cat $ANSWER)"
if [ "$BOOT_PART_SIZE" = "" ]; then
- _dia_DIALOG --msgbox "ERROR: You have entered an invalid size, please enter again." 0 0
+ notify "ERROR: You have entered an invalid size, please enter again." 0 0
else
if [ "$BOOT_PART_SIZE" -ge "$DISC_SIZE" -o "$BOOT_PART_SIZE" -lt "16" -o "$SBOOT_PART_SIZE" = "$DISC_SIZE" ]; then
- _dia_DIALOG --msgbox "ERROR: You have entered a too large size, please enter again." 0 0
+ notify "ERROR: You have entered a too large size, please enter again." 0 0
else
BOOT_PART_SET=1
fi
@@ -157,10 +157,10 @@ interactive_autoprepare()
_dia_DIALOG --inputbox "Enter the size (MB) of your swap partition. Minimum value is > 0.\n\nDisk space left: $DISC_SIZE MB" 8 65 "256" 2>$ANSWER || return 1
SWAP_PART_SIZE=$(cat $ANSWER)
if [ "$SWAP_PART_SIZE" = "" -o "$SWAP_PART_SIZE" -le "0" ]; then
- _dia_DIALOG --msgbox "ERROR: You have entered an invalid size, please enter again." 0 0
+ notify "ERROR: You have entered an invalid size, please enter again." 0 0
else
if [ "$SWAP_PART_SIZE" -ge "$DISC_SIZE" ]; then
- _dia_DIALOG --msgbox "ERROR: You have entered a too large size, please enter again." 0 0
+ notify "ERROR: You have entered a too large size, please enter again." 0 0
else
SWAP_PART_SET=1
fi
@@ -171,19 +171,19 @@ interactive_autoprepare()
_dia_DIALOG --inputbox "Enter the size (MB) of your / partition. The /home partition will use the remaining space.\n\nDisk space left: $DISC_SIZE MB" 8 65 "7500" 2>$ANSWER || return 1
ROOT_PART_SIZE=$(cat $ANSWER)
if [ "$ROOT_PART_SIZE" = "" -o "$ROOT_PART_SIZE" -le "0" ]; then
- _dia_DIALOG --msgbox "ERROR: You have entered an invalid size, please enter again." 0 0
+ notify "ERROR: You have entered an invalid size, please enter again." 0 0
else
if [ "$ROOT_PART_SIZE" -ge "$DISC_SIZE" ]; then
- _dia_DIALOG --msgbox "ERROR: You have entered a too large size, please enter again." 0 0
+ notify "ERROR: You have entered a too large size, please enter again." 0 0
else
- _dia_DIALOG --yesno "$(($DISC_SIZE-$ROOT_PART_SIZE)) MB will be used for your /home partition. Is this OK?" 0 0 && ROOT_PART_SET=1
+ ask_yesno "$(($DISC_SIZE-$ROOT_PART_SIZE)) MB will be used for your /home partition. Is this OK?" 0 0 && ROOT_PART_SET=1
fi
fi
done
while [ "$CHOSEN_FS" = "" ]; do
_dia_DIALOG --menu "Select a filesystem for / and /home:" 13 45 6 $FSOPTS 2>$ANSWER || return 1
FSTYPE=$(cat $ANSWER)
- _dia_DIALOG --yesno "$FSTYPE will be used for / and /home. Is this OK?" 0 0 && CHOSEN_FS=1
+ ask_yesno "$FSTYPE will be used for / and /home. Is this OK?" 0 0 && CHOSEN_FS=1
done
SET_DEFAULTFS=1
done
@@ -199,25 +199,25 @@ interactive_autoprepare()
PART_ROOT="${DEVICE}3"
if [ "$S_MKFS" = "1" ]; then
- _dia_DIALOG --msgbox "You have already prepared your filesystems manually" 0 0
+ notify "You have already prepared your filesystems manually" 0 0
return 0
fi
# validate DEVICE
if [ ! -b "$DEVICE" ]; then
- _dia_DIALOG --msgbox "Device '$DEVICE' is not valid" 0 0
+ notify "Device '$DEVICE' is not valid" 0 0
return 1
fi
# validate DEST
if [ ! -d "$TARGET_DIR" ]; then
- _dia_DIALOG --msgbox "Destination directory '$TARGET_DIR' is not valid" 0 0
+ notify "Destination directory '$TARGET_DIR' is not valid" 0 0
return 1
fi
# / required
if [ $(echo $FSSPECS | grep '/:' | wc -l) -ne 1 ]; then
- _dia_DIALOG --msgbox "Need exactly one root partition" 0 0
+ notify "Need exactly one root partition" 0 0
return 1
fi
@@ -251,12 +251,12 @@ interactive_autoprepare()
# invoke sfdisk
printk off
- _dia_DIALOG --infobox "Partitioning $DEVICE" 0 0
+ infofy "Partitioning $DEVICE" 0 0
sfdisk $DEVICE -uM >$LOG 2>&1 <<EOF
$sfdisk_input
EOF
if [ $? -gt 0 ]; then
- _dia_DIALOG --msgbox "Error partitioning $DEVICE (see $LOG for details)" 0 0
+ notify "Error partitioning $DEVICE (see $LOG for details)" 0 0
printk on
return 1
fi
@@ -284,7 +284,7 @@ EOF
part=$(($part + 1))
done
- _dia_DIALOG --msgbox "Auto-prepare was successful" 0 0
+ notify "Auto-prepare was successful" 0 0
return 0
}
@@ -302,14 +302,14 @@ interactive_mountpoints() {
[ "$(which mkfs.vfat 2>/dev/null)" ] && FSOPTS="$FSOPTS vfat VFAT"
# Select mountpoints
- _dia_DIALOG --msgbox "Available Disks:\n\n$(_getavaildisks)\n" 0 0
+ notify "Available Disks:\n\n$(_getavaildisks)\n" 0 0
PARTS=$(findpartitions _)
_dia_DIALOG --menu "Select the partition to use as swap" 21 50 13 NONE - $PARTS 2>$ANSWER || return 1
PART=$(cat $ANSWER)
PARTS="$(echo $PARTS | sed -e "s#${PART}\ _##g")"
if [ "$PART" != "NONE" ]; then
DOMKFS="no"
- _dia_DIALOG --yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
+ ask_yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
echo "$PART:swap:swap:$DOMKFS" >>/tmp/.parts
fi
@@ -321,7 +321,7 @@ interactive_mountpoints() {
_dia_DIALOG --menu "Select a filesystem for $PART" 13 45 6 $FSOPTS 2>$ANSWER || return 1
FSTYPE=$(cat $ANSWER)
DOMKFS="no"
- _dia_DIALOG --yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
+ ask_yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
echo "$PART:$FSTYPE:/:$DOMKFS" >>/tmp/.parts
#
@@ -339,17 +339,17 @@ interactive_mountpoints() {
_dia_DIALOG --inputbox "Enter the mountpoint for $PART" 8 65 "/boot" 2>$ANSWER || return 1
MP=$(cat $ANSWER)
if grep ":$MP:" /tmp/.parts; then
- _dia_DIALOG --msgbox "ERROR: You have defined 2 identical mountpoints! Please select another mountpoint." 8 65
+ notify "ERROR: You have defined 2 identical mountpoints! Please select another mountpoint." 8 65
MP=""
fi
done
DOMKFS="no"
- _dia_DIALOG --yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
+ ask_yesno "Would you like to create a filesystem on $PART?\n\n(This will overwrite existing data!)" 0 0 && DOMKFS="yes"
echo "$PART:$FSTYPE:$MP:$DOMKFS" >>/tmp/.parts
_dia_DIALOG --menu "Select any additional partitions to mount under your new root" 21 50 13 $PARTS DONE _ 2>$ANSWER || return 1
PART=$(cat $ANSWER)
done
- _dia_DIALOG --yesno "Would you like to create and mount the filesytems like this?\n\nSyntax\n------\nDEVICE:TYPE:MOUNTPOINT:FORMAT\n\n$(for i in $(cat /tmp/.parts); do echo "$i\n";done)" 18 0 && PARTFINISH="DONE"
+ ask_yesno "Would you like to create and mount the filesytems like this?\n\nSyntax\n------\nDEVICE:TYPE:MOUNTPOINT:FORMAT\n\n$(for i in $(cat /tmp/.parts); do echo "$i\n";done)" 18 0 && PARTFINISH="DONE"
done
_umountall
@@ -362,16 +362,16 @@ interactive_mountpoints() {
umount ${TARGET_DIR}${MP}
if [ "$DOMKFS" = "yes" ]; then
if [ "$FSTYPE" = "swap" ]; then
- _dia_DIALOG --infobox "Creating and activating swapspace on $PART" 0 0
+ infofy "Creating and activating swapspace on $PART" 0 0
else
- _dia_DIALOG --infobox "Creating $FSTYPE on $PART, mounting to ${TARGET_DIR}${MP}" 0 0
+ infofy "Creating $FSTYPE on $PART, mounting to ${TARGET_DIR}${MP}" 0 0
fi
_mkfs yes $PART $FSTYPE $TARGET_DIR $MP || return 1
else
if [ "$FSTYPE" = "swap" ]; then
- _dia_DIALOG --infobox "Activating swapspace on $PART" 0 0
+ infofy "Activating swapspace on $PART" 0 0
else
- _dia_DIALOG --infobox "Mounting $PART to ${TARGET_DIR}${MP}" 0 0
+ infofy "Mounting $PART to ${TARGET_DIR}${MP}" 0 0
fi
_mkfs no $PART $FSTYPE $TARGET_DIR $MP || return 1
fi
@@ -389,13 +389,13 @@ interactive_mountpoints() {
# returns: 1 on error
interactive_select_packages() {
- _dia_DIALOG --msgbox "Package selection is split into two stages. First you will select package categories that contain packages you may be interested in. Then you will be presented with a full list of packages for each category, allowing you to fine-tune.\n\n" 15 70
+ notify "Package selection is split into two stages. First you will select package categories that contain packages you may be interested in. Then you will be presented with a full list of packages for each category, allowing you to fine-tune.\n\n" 15 70
# set up our install location if necessary and sync up
# so we can get package lists
- prepare_pacman
+ target_prepare_pacman
if [ $? -ne 0 ]; then
- _dia_DIALOG --msgbox "Pacman preparation failed! Check $LOG for errors." 6 60
+ notify "Pacman preparation failed! Check $LOG for errors." 6 60
return 1
fi
@@ -445,7 +445,7 @@ interactive_runtime_network() {
ifaces=$(ifconfig -a |grep "Link encap:Ethernet"|sed 's/ \+Link encap:Ethernet \+HWaddr \+/ /g')
if [ "$ifaces" = "" ]; then
- _dia_DIALOG --msgbox "Cannot find any ethernet interfaces. This usually means udev was\nunable to load the module and you must do it yourself. Switch to\nanother VT, load the appropriate module, and run this step again." 18 70
+ notify "Cannot find any ethernet interfaces. This usually means udev was\nunable to load the module and you must do it yourself. Switch to\nanother VT, load the appropriate module, and run this step again." 18 70
return 1
fi
@@ -455,16 +455,16 @@ interactive_runtime_network() {
*) return 1 ;;
esac
- _dia_DIALOG --yesno "Do you want to use DHCP?" 0 0
+ ask_yesno "Do you want to use DHCP?" 0 0
if [ $? -eq 0 ]; then
- _dia_DIALOG --infobox "Please wait. Polling for DHCP server on $INTERFACE..." 0 0
+ infofy "Please wait. Polling for DHCP server on $INTERFACE..." 0 0
dhcpcd $INTERFACE >$LOG 2>&1
if [ $? -ne 0 ]; then
- _dia_DIALOG --msgbox "Failed to run dhcpcd. See $LOG for details." 0 0
+ notify "Failed to run dhcpcd. See $LOG for details." 0 0
return 1
fi
if [ ! $(ifconfig $INTERFACE | grep 'inet addr:') ]; then
- _dia_DIALOG --msgbox "DHCP request failed." 0 0 || return 1
+ notify "DHCP request failed." 0 0 || return 1
fi
S_DHCP=1
else
@@ -484,16 +484,16 @@ interactive_runtime_network() {
PROXY_HTTP=$(cat $ANSWER)
_dia_DIALOG --inputbox "Enter your FTP proxy server, for example:\nhttp://name:port\nhttp://ip:port\nhttp://username:password@ip:port\n\n Leave the field empty if no proxy is needed to install." 16 65 "" 2>$ANSWER || return 1
PROXY_FTP=$(cat $ANSWER)
- _dia_DIALOG --yesno "Are these settings correct?\n\nIP address: $IPADDR\nNetmask: $SUBNET\nGateway (optional): $GW\nDNS server: $DNS\nHTTP proxy server: $PROXY_HTTP\nFTP proxy server: $PROXY_FTP" 0 0
+ ask_yesno "Are these settings correct?\n\nIP address: $IPADDR\nNetmask: $SUBNET\nGateway (optional): $GW\nDNS server: $DNS\nHTTP proxy server: $PROXY_HTTP\nFTP proxy server: $PROXY_FTP" 0 0
case $? in
1) ;;
0) NETPARAMETERS="1" ;;
esac
done
echo "running: ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up" >$LOG
- ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up >$LOG 2>&1 || _dia_DIALOG --msgbox "Failed to setup $INTERFACE interface." 0 0 || return 1
+ ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up >$LOG 2>&1 || notify "Failed to setup $INTERFACE interface." 0 0 || return 1
if [ "$GW" != "" ]; then
- route add default gw $GW >$LOG 2>&1 || _dia_DIALOG --msgbox "Failed to setup your gateway." 0 0 || return 1
+ route add default gw $GW >$LOG 2>&1 || notify "Failed to setup your gateway." 0 0 || return 1
fi
if [ "$PROXY_HTTP" = "" ]; then
unset http_proxy
@@ -516,7 +516,7 @@ interactive_install_grub() {
get_grub_map
local grubmenu="$TARGET_DIR/boot/grub/menu.lst"
if [ ! -f $grubmenu ]; then
- _dia_DIALOG --msgbox "Error: Couldn't find $grubmenu. Is GRUB installed?" 0 0
+ notify "Error: Couldn't find $grubmenu. Is GRUB installed?" 0 0
return 1
fi
# try to auto-configure GRUB...
@@ -539,7 +539,7 @@ interactive_install_grub() {
fi
# keep the file from being completely bogus
if [ "$grubdev" = "DEVICE NOT FOUND" ]; then
- _dia_DIALOG --msgbox "Your root boot device could not be autodetected by setup. Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly." 0 0
+ notify "Your root boot device could not be autodetected by setup. Ensure you adjust the 'root (hd0,0)' line in your GRUB config accordingly." 0 0
grubdev="(hd0,0)"
fi
# remove default entries by truncating file at our little tag (#-*)
@@ -567,19 +567,19 @@ EOF
fi
fi
- _dia_DIALOG --msgbox "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." 0 0
+ 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." 0 0
[ "$EDITOR" ] || geteditor
$EDITOR $grubmenu
DEVS=$(finddisks _)
DEVS="$DEVS $(findpartitions _)"
if [ "$DEVS" = "" ]; then
- _dia_DIALOG --msgbox "No hard drives were found" 0 0
+ notify "No hard drives were found" 0 0
return 1
fi
_dia_DIALOG --menu "Select the boot device where the GRUB bootloader will be installed (usually the MBR and not a partition)." 14 55 7 $DEVS 2>$ANSWER || return 1
ROOTDEV=$(cat $ANSWER)
- _dia_DIALOG --infobox "Installing the GRUB bootloader..." 0 0
+ infofy "Installing the GRUB bootloader..." 0 0
cp -a $TARGET_DIR/usr/lib/grub/i386-pc/* $TARGET_DIR/boot/grub/
sync
# freeze xfs filesystems to enable grub installation on xfs filesystems
@@ -605,11 +605,11 @@ EOF
bootpart=$(mapdev $bootpart)
bootdev=$(mapdev $ROOTDEV)
if [ "$bootpart" = "" ]; then
- _dia_DIALOG --msgbox "Error: Missing/Invalid root device: $bootpart" 0 0
+ notify "Error: Missing/Invalid root device: $bootpart" 0 0
return 1
fi
if [ "$bootpart" = "DEVICE NOT FOUND" -o "$bootdev" = "DEVICE NOT FOUND" ]; then
- _dia_DIALOG --msgbox "GRUB root and setup devices could not be auto-located. You will need to manually run the GRUB shell to install a bootloader." 0 0
+ notify "GRUB root and setup devices could not be auto-located. You will need to manually run the GRUB shell to install a bootloader." 0 0
return 1
fi
$TARGET_DIR/sbin/grub --no-floppy --batch >/tmp/grub.log 2>&1 <<EOF
@@ -625,7 +625,7 @@ EOF
fi
if grep "Error [0-9]*: " /tmp/grub.log >/dev/null; then
- _dia_DIALOG --msgbox "Error installing GRUB. (see $LOG for output)" 0 0
+ notify "Error installing GRUB. (see $LOG for output)" 0 0
return 1
fi
notify "GRUB was successfully installed."
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh
index bc32aaf..91cfca9 100644
--- a/src/core/libs/lib-ui.sh
+++ b/src/core/libs/lib-ui.sh
@@ -50,6 +50,17 @@ notify ()
}
+infofy ()
+{
+ if [ "$var_UI_TYPE" = dia ]
+ then
+ _dia_DIALOG --infobox "$@" 20 50
+ else
+ echo -e "$@"
+ fi
+}
+
+
# logging of stuff
log ()
{
@@ -173,7 +184,7 @@ _dia_ask_option ()
DIA_MENU_TITLE=$2
shift 2
- _dia_DIALOG $DEFAULT --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT" 16 55 8 "$@" 2>$ANSWER
+ _dia_DIALOG $DEFAULT --colors --title " $DIA_MENU_TITLE " --menu "$DIA_MENU_TEXT" 16 55 8 "$@" 2>$ANSWER
ANSWER_OPTION=`cat $ANSWER`
echo $ANSWER_OPTION
}
@@ -181,6 +192,7 @@ _dia_ask_option ()
_cli_ask_option ()
{
+ #TODO: strip out color codes
DEFAULT=""
[ "$1" != 'no' ] && DEFAULT=$1
[ -z "$2" ] && die_error "ask_option \$2 must be the title"
diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive
index 2c646bc..fa8ba6c 100644
--- a/src/core/procedures/interactive
+++ b/src/core/procedures/interactive
@@ -75,22 +75,16 @@ mainmenu()
"7" "Exit Install"
NEXTITEM="$ANSWER_OPTION"
case $ANSWER_OPTION in
- "0")
- execute worker select_source; ret=$?
+ "0")
+ execute worker select_source; ret=$?
if [ $ret -eq 0 -a "$var_PKG_SOURCE_TYPE" = "ftp" ]; then
while true; do
- _dia_DIALOG --menu "FTP Installation" 10 35 3 \
+ ask_option no "FTP Installation" \
"0" "Setup Network (Make sure the network is ok before continuing" \
"1" "Choose Mirror" \
- "2" "Return to Main Menu" 2>$ANSWER
- case "$(cat $ANSWER)" in
- "0")
- execute worker runtime_network && S_NET=1;;
- "1")
- execute worker select_mirror ;;
- *)
- break ;;
- esac
+ "2" "Return to Main Menu"
+ [ "$ANSWER_OPTION" = 0 ] && execute worker runtime_network && S_NET=1
+ [ "$ANSWER_OPTION" = 1 ] && execute worker select_mirror ;;
done
fi
[ $ret -eq 0 ] && S_SRC=1 && execute worker runtime_packages ;;
@@ -105,10 +99,10 @@ mainmenu()
"5")
execute worker configure_system && S_CONFIG=1 && { execute worker mkinitcpio; execute worker locales; } ;;
"6")
- _dia_DIALOG --colors --menu "Which bootloader would you like to use? Grub is the Arch default.\n\n" 10 65 2 \
+ ask_option no "Which bootloader would you like to use? Grub is the Arch default." \
"GRUB" "Use the GRUB bootloader (default)" \
- "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" 2>$ANSWER
- execute worker install_bootloader "`cat $ANSWER`";;
+ "None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!"
+ execute worker install_bootloader "$ANSWER_OPTION";;
"7")
notify "If the install finished successfully, you can now type 'reboot' to restart the system."
stop_installer ;;