installer: replace dialog with whiptail

This modifies the installer to use whiptail instead of dialog. Line drawing does not work without a proper locale. Create en_US.UTF-8 locale as part of the installer.
This commit is contained in:
Olli Salonen 2016-10-19 01:33:39 +03:00
parent 4abfbdd940
commit ba4e620da8
5 changed files with 235 additions and 265 deletions

View File

@ -64,7 +64,7 @@ fi
NSS_CONF_DIR="$PKG_BUILD/nss" NSS_CONF_DIR="$PKG_BUILD/nss"
GLIBC_EXCLUDE_BIN="catchsegv gencat getconf iconv iconvconfig ldconfig" GLIBC_EXCLUDE_BIN="catchsegv gencat getconf iconv iconvconfig ldconfig"
GLIBC_EXCLUDE_BIN="$GLIBC_EXCLUDE_BIN localedef makedb mtrace pcprofiledump" GLIBC_EXCLUDE_BIN="$GLIBC_EXCLUDE_BIN makedb mtrace pcprofiledump"
GLIBC_EXCLUDE_BIN="$GLIBC_EXCLUDE_BIN pldd rpcgen sln sotruss sprof xtrace" GLIBC_EXCLUDE_BIN="$GLIBC_EXCLUDE_BIN pldd rpcgen sln sotruss sprof xtrace"
pre_build_target() { pre_build_target() {

View File

@ -1,44 +0,0 @@
################################################################################
# This file is part of OpenELEC - http://www.openelec.tv
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
#
# OpenELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# OpenELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
PKG_NAME="dialog"
PKG_VERSION="1.2-20150920"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE="http://invisible-island.net/dialog/"
PKG_URL="ftp://invisible-island.net/dialog/$PKG_NAME-$PKG_VERSION.tgz"
PKG_DEPENDS_TARGET="toolchain netbsd-curses"
PKG_SECTION="tools"
PKG_SHORTDESC="dialog: A utility for creating TTY dialog boxes"
PKG_LONGDESC="Dialog is a utility that allows you to show dialog boxes (containing questions or messages) in TTY (text mode) interfaces from shell scripts. Dialog is initally written by Savio Lam and various branches do exist (e.g. lxdialog which is used for a linux kernel make menuconfig). This is the branch maintained by Thomas Dickey."
PKG_IS_ADDON="no"
PKG_AUTORECONF="no"
PKG_CONFIGURE_OPTS_TARGET="--disable-nls \
--without-dbmalloc \
--without-dmalloc \
--with-ncurses \
--disable-widec \
--disable-rc-file \
--disable-Xdialog \
--disable-form \
--disable-mixedform \
--disable-tailbox"

View File

@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with OpenELEC. If not, see <http://www.gnu.org/licenses/>. # along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################ ################################################################################
# Disklabel for System an Storage partition # Disklabel for System and Storage partition
DISKLABEL_SYSTEM="System" DISKLABEL_SYSTEM="System"
DISKLABEL_STORAGE="Storage" DISKLABEL_STORAGE="Storage"
@ -36,3 +36,7 @@
# location for BIOS backup (with filename) # location for BIOS backup (with filename)
BIOS_BACKUP="" BIOS_BACKUP=""
# color scheme to use for Whiptail/Newt
# see http://askubuntu.com/questions/776831/whiptail-change-background-color-dynamically-from-magenta
WHIPTAIL_COLORS="root=,magenta;entry=,magenta;label=magenta,;actlistbox=,magenta;roottext=,magenta"

View File

@ -23,7 +23,7 @@ PKG_ARCH="any"
PKG_LICENSE="GPL" PKG_LICENSE="GPL"
PKG_SITE="http://www.openelec.tv/" PKG_SITE="http://www.openelec.tv/"
PKG_URL="" PKG_URL=""
PKG_DEPENDS_TARGET="toolchain busybox dialog parted e2fsprogs syslinux" PKG_DEPENDS_TARGET="toolchain busybox newt parted e2fsprogs syslinux"
PKG_SECTION="tools" PKG_SECTION="tools"
PKG_SHORTDESC="installer: LibreELEC.tv Install manager" PKG_SHORTDESC="installer: LibreELEC.tv Install manager"
PKG_LONGDESC="LibreELEC.tv Install manager to install the system on any disk" PKG_LONGDESC="LibreELEC.tv Install manager to install the system on any disk"

View File

@ -40,14 +40,6 @@
# exclude mounted partitions # exclude mounted partitions
# for i in `cat /proc/mounts | grep ^/dev/ | cut -f1 -d " " | sed "s/[0-9]//"`; do TEST="$TEST `echo "| grep -v $i"`"; done # for i in `cat /proc/mounts | grep ^/dev/ | cut -f1 -d " " | sed "s/[0-9]//"`; do TEST="$TEST `echo "| grep -v $i"`"; done
# Interpret embedded "\Z" sequences in the dialog text by the following
# character, which tells dialog to set colors or video attributes: 0 through 7
# are the ANSI used in curses: black, red, green, yellow, blue, magenta, cyan
# and white respectively. Bold is set by 'b', reset by 'B'. Reverse is set
# by 'r', reset by 'R'. Underline is set by 'u', reset by 'U'. The settings are
# cumulative, e.g., "\Zb\Z1" makes the following text bold (perhaps bright)
# red. Restore normal settings with "\Zn".
# disable Ctrl+C - can be very dangerous # disable Ctrl+C - can be very dangerous
trap '' 2 trap '' 2
@ -57,9 +49,9 @@ dbglg() {
# Acts just like echo cmd, with automatic redirection # Acts just like echo cmd, with automatic redirection
echo "" >> $LOGFILE echo "" >> $LOGFILE
echo "###################################################################" >> $LOGFILE echo "#################################################################" >> $LOGFILE
echo "# $@" >> $LOGFILE echo "# $@" >> $LOGFILE
echo "###################################################################" >> $LOGFILE echo "#################################################################" >> $LOGFILE
echo "" >> $LOGFILE echo "" >> $LOGFILE
} }
@ -145,13 +137,13 @@ create_partition_list() {
do_install_mbr() { do_install_mbr() {
# show menu # show menu
MSG_TITLE="\Z4[ (RE)INSTALL MBR ]\Zn" MSG_TITLE="(RE)INSTALL MBR"
MSG_MENU="\n Please select where to install MBR.\n\n Please select a device:" MSG_MENU="Please select where to install MBR.\n\n Please select a device:"
MSG_CANCEL="Back" MSG_CANCEL="Back"
create_device_list create_device_list
dialog --colors --backtitle "$BACKTITLE" --cancel-label "$MSG_CANCEL" \ whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
--title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \ --title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \
$DEVICE_LIST 2> $TMPDIR/device_for_install $DEVICE_LIST 2> $TMPDIR/device_for_install
@ -181,14 +173,14 @@ do_install_mbr() {
do_install_quick() { do_install_quick() {
# show menu # show menu
MSG_TITLE="\Z4[ QUICK INSTALL MENU ]\Zn" MSG_TITLE="QUICK INSTALL MENU"
MSG_MENU="\nUse the up/down arrows to select the correct device.\n\n Please select a device:" MSG_MENU="\nUse the up/down arrows to select the correct device.\n\n Please select a device:"
MSG_CANCEL="Back" MSG_CANCEL="Back"
DIALOG_OPTIONS="--defaultno" DIALOG_OPTIONS="--defaultno"
create_device_list create_device_list
dialog --colors --backtitle "$BACKTITLE" --cancel-label "$MSG_CANCEL" \ whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
$DIALOG_OPTIONS --title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \ $DIALOG_OPTIONS --title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \
$DEVICE_LIST 2> $TMPDIR/device_for_install $DEVICE_LIST 2> $TMPDIR/device_for_install
@ -213,40 +205,42 @@ do_install_quick() {
prompt_backup_unpack prompt_backup_unpack
# check for confirmation (twice!) # check for confirmation (twice!)
MSG_TITLE="\Z1[ Confirmation before installing ]\Zn" MSG_TITLE="Confirmation before installing"
MSG_DETAIL="\nIf you continue the target disk will be wiped out:\n\n$INSTALL_DEVICE_FULL\n\n" MSG_DETAIL="\nIf you continue the target disk will be wiped out:\n\n$INSTALL_DEVICE_FULL\n\n"
DIALOG_OPTIONS="--defaultno" DIALOG_OPTIONS="--defaultno"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" \ whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0 $DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
menu_main menu_main
fi fi
MSG_TITLE="\Z1[ Confirmation before installing ]\Zn" MSG_TITLE="Confirmation before installing"
MSG_DETAIL="\nThis is last chance to abort the installation!\n\nIf you continue the target disk will be wiped out:\n\n$INSTALL_DEVICE_FULL\n\n\n" MSG_DETAIL="\nThis is last chance to abort the installation!\n\nIf you continue the target disk will be wiped out:\n\n$INSTALL_DEVICE_FULL\n\n\n"
DIALOG_OPTIONS="--defaultno" DIALOG_OPTIONS="--defaultno"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" \ whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0 $DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
menu_main menu_main
fi fi
# start the progress bar (whiptail --gauge)
{
# remove all partitions # remove all partitions
msg_progress_install "1" "get all partitions $INSTALL_DEVICE" msg_progress_install "1" "Get all partitions $INSTALL_DEVICE"
get_partition $INSTALL_DEVICE get_partition $INSTALL_DEVICE
msg_progress_install "5" "wiping disk $INSTALL_DEVICE" msg_progress_install "5" "Wiping disk $INSTALL_DEVICE"
dd if=/dev/zero of=$INSTALL_DEVICE bs=4096 count=1024 dd if=/dev/zero of=$INSTALL_DEVICE bs=4096 count=1024 2>>$LOGFILE
# create 2 new partitions (first $PARTSIZE_SYSTEM, second rest) # create 2 new partitions (first $PARTSIZE_SYSTEM, second rest)
msg_progress_install "7" "creating label on $INSTALL_DEVICE" msg_progress_install "7" "Creating label on $INSTALL_DEVICE"
if [ "$GPT" = "1" ]; then if [ "$GPT" = "1" ]; then
parted -s $INSTALL_DEVICE mklabel gpt >> $LOGFILE 2>&1 parted -s $INSTALL_DEVICE mklabel gpt >> $LOGFILE 2>&1
else else
parted -s $INSTALL_DEVICE mklabel msdos >> $LOGFILE 2>&1 parted -s $INSTALL_DEVICE mklabel msdos >> $LOGFILE 2>&1
fi fi
msg_progress_install "9" "writing Master Boot Record on $INSTALL_DEVICE" msg_progress_install "9" "Writing Master Boot Record on $INSTALL_DEVICE"
if [ "$GPT" = "1" ]; then if [ "$GPT" = "1" ]; then
cat /usr/share/syslinux/gptmbr.bin > $INSTALL_DEVICE cat /usr/share/syslinux/gptmbr.bin > $INSTALL_DEVICE
else else
@ -258,51 +252,51 @@ do_install_quick() {
partsize_storage_start=$((partsize_system_end + 2048)) partsize_storage_start=$((partsize_system_end + 2048))
partsize_storage_end=-1024 partsize_storage_end=-1024
msg_progress_install "10" "creating partition on $INSTALL_DEVICE" msg_progress_install "10" "Creating partition on $INSTALL_DEVICE"
if [ "$UEFI" = "1" ]; then if [ "$UEFI" = "1" ]; then
parted -s $INSTALL_DEVICE unit s mkpart primary fat32 -- $partsize_system_start $partsize_system_end >> $LOGFILE 2>&1 parted -s $INSTALL_DEVICE unit s mkpart primary fat32 -- $partsize_system_start $partsize_system_end >> $LOGFILE 2>&1
else else
parted -s $INSTALL_DEVICE unit s mkpart primary ext2 -- $partsize_system_start $partsize_system_end >> $LOGFILE 2>&1 parted -s $INSTALL_DEVICE unit s mkpart primary ext2 -- $partsize_system_start $partsize_system_end >> $LOGFILE 2>&1
fi fi
msg_progress_install "13" "creating partition on $INSTALL_DEVICE" msg_progress_install "13" "Creating partition on $INSTALL_DEVICE"
parted -s $INSTALL_DEVICE unit s mkpart primary ext2 -- $partsize_storage_start $partsize_storage_end >> $LOGFILE 2>&1 parted -s $INSTALL_DEVICE unit s mkpart primary ext2 -- $partsize_storage_start $partsize_storage_end >> $LOGFILE 2>&1
msg_progress_install "16" "setup bootflag on partition 1 of $INSTALL_DEVICE" msg_progress_install "16" "Setup bootflag on partition 1 of $INSTALL_DEVICE"
parted -s $INSTALL_DEVICE set 1 boot on >> $LOGFILE 2>&1 parted -s $INSTALL_DEVICE set 1 boot on >> $LOGFILE 2>&1
if [ "$GPT" = "1" ]; then if [ "$GPT" = "1" ]; then
parted -s $INSTALL_DEVICE set 1 legacy_boot on >> $LOGFILE 2>&1 parted -s $INSTALL_DEVICE set 1 legacy_boot on >> $LOGFILE 2>&1
fi fi
msg_progress_install "20" "tell the kernel we have a new partitiontable on $INSTALL_DEVICE" msg_progress_install "20" "Tell the kernel we have a new partitiontable on $INSTALL_DEVICE"
partprobe $INSTALL_DEVICE >> $LOGFILE 2>&1 partprobe $INSTALL_DEVICE >> $LOGFILE 2>&1
# create filesystem # create filesystem
msg_progress_install "23" "creating filesystem on ${INSTALL_DEVICE}1" msg_progress_install "23" "Creating filesystem on ${INSTALL_DEVICE}1"
if [ "$UEFI" = "1" ]; then if [ "$UEFI" = "1" ]; then
mkfs.vfat ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1 mkfs.vfat ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1
else else
mke2fs -t ext4 -m 0 ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1 mke2fs -t ext4 -m 0 ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1
fi fi
msg_progress_install "25" "set uuid and disklabel $DISKLABEL_SYSTEM on ${INSTALL_DEVICE}${PART1}" msg_progress_install "25" "Set uuid and disklabel $DISKLABEL_SYSTEM on ${INSTALL_DEVICE}${PART1}"
if [ "$UEFI" = "1" ]; then if [ "$UEFI" = "1" ]; then
dosfslabel ${INSTALL_DEVICE}${PART1} $DISKLABEL_SYSTEM >> $LOGFILE 2>&1 dosfslabel ${INSTALL_DEVICE}${PART1} $DISKLABEL_SYSTEM >> $LOGFILE 2>&1
else else
tune2fs -U random -L $DISKLABEL_SYSTEM ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1 tune2fs -U random -L $DISKLABEL_SYSTEM ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1
fi fi
msg_progress_install "28" "creating filesystem on ${INSTALL_DEVICE}${PART2}" msg_progress_install "28" "Creating filesystem on ${INSTALL_DEVICE}${PART2}"
mke2fs -t ext4 -m 0 ${INSTALL_DEVICE}${PART2} >> $LOGFILE 2>&1 mke2fs -t ext4 -m 0 ${INSTALL_DEVICE}${PART2} >> $LOGFILE 2>&1
msg_progress_install "30" "set uuid and disklabel $DISKLABEL_STORAGE on ${INSTALL_DEVICE}${PART2}" msg_progress_install "30" "Set uuid and disklabel $DISKLABEL_STORAGE on ${INSTALL_DEVICE}${PART2}"
tune2fs -U random -L $DISKLABEL_STORAGE ${INSTALL_DEVICE}${PART2} >> $LOGFILE 2>&1 tune2fs -U random -L $DISKLABEL_STORAGE ${INSTALL_DEVICE}${PART2} >> $LOGFILE 2>&1
# mount system partition # mount system partition
msg_progress_install "35" "creating $TMPDIR/part1" msg_progress_install "35" "Creating $TMPDIR/part1"
mkdir -p $TMPDIR/part1 >> $LOGFILE 2>&1 mkdir -p $TMPDIR/part1 >> $LOGFILE 2>&1
msg_progress_install "40" "mounting ${INSTALL_DEVICE}${PART1} to $TMPDIR/part1" msg_progress_install "40" "Mounting ${INSTALL_DEVICE}${PART1} to $TMPDIR/part1"
if [ "$UEFI" = "1" ]; then if [ "$UEFI" = "1" ]; then
mount -t vfat ${INSTALL_DEVICE}${PART1} $TMPDIR/part1 >> $LOGFILE 2>&1 mount -t vfat ${INSTALL_DEVICE}${PART1} $TMPDIR/part1 >> $LOGFILE 2>&1
else else
@ -310,23 +304,24 @@ do_install_quick() {
fi fi
# installing extlinux # installing extlinux
msg_progress_install "50" "installing extlinux to $TMPDIR/part1"
if [ "$UEFI" = "1" ]; then if [ "$UEFI" = "1" ]; then
msg_progress_install "50" "Installing syslinux to $TMPDIR/part1"
syslinux -i ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1 syslinux -i ${INSTALL_DEVICE}${PART1} >> $LOGFILE 2>&1
else else
msg_progress_install "50" "Installing extlinux to $TMPDIR/part1"
extlinux -i $TMPDIR/part1 >> $LOGFILE 2>&1 extlinux -i $TMPDIR/part1 >> $LOGFILE 2>&1
fi fi
# install system files # install system files
msg_progress_install "60" "installing Kernel" msg_progress_install "60" "Installing Kernel"
cp /flash/KERNEL $TMPDIR/part1 >> $LOGFILE 2>&1 cp /flash/KERNEL $TMPDIR/part1 >> $LOGFILE 2>&1
msg_progress_install "65" "installing System" msg_progress_install "65" "Installing System"
cp /flash/SYSTEM $TMPDIR/part1 >> $LOGFILE 2>&1 cp /flash/SYSTEM $TMPDIR/part1 >> $LOGFILE 2>&1
sync sync
# configuring bootloader # configuring bootloader
msg_progress_install "80" "setup bootloader with boot label = $DISKLABEL_SYSTEM and disk label = $DISKLABEL_STORAGE" msg_progress_install "80" "Setup bootloader with boot label = $DISKLABEL_SYSTEM and disk label = $DISKLABEL_STORAGE"
echo "DEFAULT linux" > $TMPDIR/part1/extlinux.conf echo "DEFAULT linux" > $TMPDIR/part1/extlinux.conf
echo "PROMPT 0" >> $TMPDIR/part1/extlinux.conf echo "PROMPT 0" >> $TMPDIR/part1/extlinux.conf
echo " " >> $TMPDIR/part1/extlinux.conf echo " " >> $TMPDIR/part1/extlinux.conf
@ -344,37 +339,38 @@ do_install_quick() {
sync sync
# umount system partition, remove mountpoint # umount system partition, remove mountpoint
msg_progress_install "85" "unmount $TMPDIR/part1" msg_progress_install "85" "Unmount $TMPDIR/part1"
umount $TMPDIR/part1 >> $LOGFILE 2>&1 umount $TMPDIR/part1 >> $LOGFILE 2>&1
msg_progress_install "87" "remove $TMPDIR/part1" msg_progress_install "87" "Remove $TMPDIR/part1"
rmdir $TMPDIR/part1 >> $LOGFILE 2>&1 rmdir $TMPDIR/part1 >> $LOGFILE 2>&1
if [ "$BACKUP_UNPACK" = "1" ]; then if [ "$BACKUP_UNPACK" = "1" ]; then
# mount storage partition # mount storage partition
msg_progress_install "89" "creating $TMPDIR/part2" msg_progress_install "89" "Creating $TMPDIR/part2"
mkdir -p $TMPDIR/part2 >> $LOGFILE 2>&1 mkdir -p $TMPDIR/part2 >> $LOGFILE 2>&1
msg_progress_install "90" "mounting ${INSTALL_DEVICE}${PART2} to $TMPDIR/part2" msg_progress_install "90" "Mounting ${INSTALL_DEVICE}${PART2} to $TMPDIR/part2"
mount -t ext4 ${INSTALL_DEVICE}${PART2} $TMPDIR/part2 >> $LOGFILE 2>&1 mount -t ext4 ${INSTALL_DEVICE}${PART2} $TMPDIR/part2 >> $LOGFILE 2>&1
msg_progress_install "92" "restoring backup" msg_progress_install "92" "Restoring backup"
[ -f /flash/backup.tar.bz2 ] && tar -xjf /flash/backup.tar.bz2 -C $TMPDIR/part2 >> $LOGFILE 2>&1 [ -f /flash/backup.tar.bz2 ] && tar -xjf /flash/backup.tar.bz2 -C $TMPDIR/part2 >> $LOGFILE 2>&1
[ -f /flash/backup.zip ] && unzip -qq /flash/backup.zip -d $TMPDIR/part2 >> $LOGFILE 2>&1 [ -f /flash/backup.zip ] && unzip -qq /flash/backup.zip -d $TMPDIR/part2 >> $LOGFILE 2>&1
sync sync
# umount system partition, remove mountpoint # umount system partition, remove mountpoint
msg_progress_install "97" "unmount $TMPDIR/part2" msg_progress_install "97" " bbUnmount $TMPDIR/part2"
umount $TMPDIR/part2 >> $LOGFILE 2>&1 umount $TMPDIR/part2 >> $LOGFILE 2>&1
msg_progress_install "100" "remove $TMPDIR/part2" msg_progress_install "100" "Remove $TMPDIR/part2"
rmdir $TMPDIR/part2 >> $LOGFILE 2>&1 rmdir $TMPDIR/part2 >> $LOGFILE 2>&1
fi fi
} | whiptail --gauge "Please wait while your system is being setup ..." 6 70 0
# install complete # install complete
MSG_TITLE="\Z1[ @DISTRONAME@ Install Complete ]\Zn" MSG_TITLE="@DISTRONAME@ Install Complete"
MSG_DETAIL="\nYou may now remove the install media and reboot\n" MSG_DETAIL="You may now remove the install media and reboot\n"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 6 52 whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 7 52
menu_main menu_main
;; ;;
@ -389,7 +385,7 @@ do_install_quick() {
do_install_custom() { do_install_custom() {
# show menu # show menu
MSG_TITLE="\Z4[ REPAIR/UPGRADE MENU ]\Zn" MSG_TITLE="REPAIR/UPGRADE MENU"
MSG_MENU="\nUse the up/down arrows to select the correct partition where you want to overwrite KERNEL and SYSTEM files.\n\n Please select a partition:" MSG_MENU="\nUse the up/down arrows to select the correct partition where you want to overwrite KERNEL and SYSTEM files.\n\n Please select a partition:"
MSG_CANCEL="Back" MSG_CANCEL="Back"
DIALOG_OPTIONS="--defaultno" DIALOG_OPTIONS="--defaultno"
@ -418,7 +414,7 @@ do_install_custom() {
msg_no_device msg_no_device
fi fi
dialog --colors --backtitle "$BACKTITLE" --cancel-label "$MSG_CANCEL" \ whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
$DIALOG_OPTIONS --title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \ $DIALOG_OPTIONS --title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \
$PARTITION_LIST 2> $TMPDIR/device_for_install $PARTITION_LIST 2> $TMPDIR/device_for_install
@ -429,24 +425,25 @@ do_install_custom() {
INSTALL_PARTITION_FULL=$(echo $PARTITION_LIST | sed "s|.*$INSTALL_PARTITION \([^ ]*\).*|$INSTALL_PARTITION \1|") INSTALL_PARTITION_FULL=$(echo $PARTITION_LIST | sed "s|.*$INSTALL_PARTITION \([^ ]*\).*|$INSTALL_PARTITION \1|")
# check for confirmation (twice!) # check for confirmation (twice!)
MSG_TITLE="\Z1[ Confirmation before copying ]\Zn" MSG_TITLE="Confirmation before copying"
MSG_DETAIL="\nIf you continue the target partition will be\noverwritten with new KERNEL and SYSTEM files:\n\n$INSTALL_PARTITION_FULL\n\n" MSG_DETAIL="\nIf you continue the target partition will be\noverwritten with new KERNEL and SYSTEM files:\n\n$INSTALL_PARTITION_FULL\n\n"
DIALOG_OPTIONS="--defaultno" DIALOG_OPTIONS="--defaultno"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" \ whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0 $DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
menu_main menu_main
fi fi
MSG_TITLE="\Z1[ Confirmation before copying ]\Zn" MSG_TITLE="Confirmation before copying"
MSG_DETAIL="\nThis is last chance to abort the copying!\n\nIf you continue the target partition will be\noverwritten with new KERNEL and SYSTEM files:\n\n$INSTALL_PARTITION_FULL\n\n\n" MSG_DETAIL="\nThis is last chance to abort the copying!\n\nIf you continue the target partition will be\noverwritten with new KERNEL and SYSTEM files:\n\n$INSTALL_PARTITION_FULL\n\n\n"
DIALOG_OPTIONS="--defaultno" DIALOG_OPTIONS="--defaultno"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" \ whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0 $DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
menu_main menu_main
fi fi
{
# mount system partition # mount system partition
msg_progress_install "5" "creating $TMPDIR/part1" msg_progress_install "5" "creating $TMPDIR/part1"
mkdir -p $TMPDIR/part1 >> $LOGFILE 2>&1 mkdir -p $TMPDIR/part1 >> $LOGFILE 2>&1
@ -493,11 +490,12 @@ do_install_custom() {
msg_progress_install "100" "remove $TMPDIR/part1" msg_progress_install "100" "remove $TMPDIR/part1"
rmdir $TMPDIR/part1 >> $LOGFILE 2>&1 rmdir $TMPDIR/part1 >> $LOGFILE 2>&1
} | whiptail --gauge "Please wait while your system is being setup ..." 6 70 0
# install complete # install complete
MSG_TITLE="\Z1[ @DISTRONAME@ Install Complete ]\Zn" MSG_TITLE="@DISTRONAME@ Install Complete"
MSG_DETAIL="\nYou may now remove the install media and reboot\n" MSG_DETAIL="\nYou may now remove the install media and reboot\n"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 6 52 whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 6 52
menu_main menu_main
;; ;;
@ -512,39 +510,42 @@ do_install_custom() {
msg_no_device() { msg_no_device() {
# show a warning dialog if we dont find not mounted devices for install and return to main menu # show a warning dialog if we dont find not mounted devices for install and return to main menu
MSG_TITLE="\Z1[ WARNING ]\Zn" MSG_TITLE="WARNING"
MSG_INFOBOX=" No devices were found. " MSG_INFOBOX=" No devices were found. "
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 9 70 whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 9 70
menu_main menu_main
} }
msg_target_space() { msg_target_space() {
# show an error dialog for missing space # show an error dialog for missing space
MSG_TITLE="\Z1[ TARGET SPACE ]\Zn" MSG_TITLE="TARGET SPACE"
MSG_INFOBOX="\nNot enough target space!\nCopying aborted.\n" MSG_INFOBOX="Not enough target space!\nCopying aborted.\n"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 8 70 whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 8 70
menu_main
}
msg_install_ready() {
# show a dialog that we have installed
MSG_TITLE="\Z1[ INFORMATION ]\Zn"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox " $1" 7 70
menu_main menu_main
} }
msg_progress_install() { msg_progress_install() {
# show the progress dialog # update the whiptail gauge window
MSG_TITLE="\Z1[ INSTALLING ]\Zn"
dbglg "$2" dbglg "$2"
dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" --gauge "$2 ..." 6 70 $1 & sleep .3
echo XXX
echo $1
echo "$2 ..."
echo XXX
}
msg_install_ready() {
# show a dialog that we have installed
MSG_TITLE="INFORMATION"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox " $1" 7 70
menu_main
} }
prompt_gpt() { prompt_gpt() {
@ -569,10 +570,10 @@ prompt_backup_unpack() {
# provides: BACKUP_UNPACK # provides: BACKUP_UNPACK
BACKUP_UNPACK="0" BACKUP_UNPACK="0"
if [ -f /flash/backup.tar.bz2 -o -f /flash/backup.zip ]; then if [ -f /flash/backup.tar.bz2 -o -f /flash/backup.zip ]; then
MSG_TITLE="\Z1[ Restore backup files ]\Zn" MSG_TITLE="Restore backup files"
MSG_DETAIL="Restore backup files to storage partition.\nFile backup.tar.bz2 or/and backup.zip exist on\ninstallation USB stick." MSG_DETAIL="Restore backup files to storage partition.\nFile backup.tar.bz2 or/and backup.zip exist on\ninstallation USB stick."
DIALOG_OPTIONS="--defaultno" DIALOG_OPTIONS="--defaultno"
if dialog --colors --backtitle "$BACKTITLE" --title "$MSG_TITLE" $DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0; then if whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" $DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0; then
BACKUP_UNPACK="1" BACKUP_UNPACK="1"
fi fi
fi fi
@ -580,16 +581,16 @@ prompt_backup_unpack() {
menu_main() { menu_main() {
# show the mainmenu # show the mainmenu
MSG_TITLE="\Z4[ MAIN MENU ]\Zn" MSG_TITLE="MAIN MENU"
MSG_MENU="\n\ZbQuick Install:\Zn do a default installation on a specific device \ MSG_MENU="\nQuick Install: do a default installation on a specific device \
\Z1\Zb(this will delete ALL data on this device!)\Zn \ (this will delete ALL data on this device!) \
\n\ZbRepair / Upgrade:\Zn do repair / upgrade \ \nRepair / Upgrade: do repair / upgrade \
\n\ZbShow logfile:\Zn show and save the logfile \ \nShow logfile: show and save the logfile \
\n \ \n \
\nPlease select:" \nPlease select:"
MSG_CANCEL="Reboot" MSG_CANCEL="Reboot"
dialog --colors --backtitle "$BACKTITLE" --cancel-label "$MSG_CANCEL" \ whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
--title "$MSG_TITLE" --menu "$MSG_MENU" 20 70 5 \ --title "$MSG_TITLE" --menu "$MSG_MENU" 20 70 5 \
1 "Quick Install of @DISTRONAME@" \ 1 "Quick Install of @DISTRONAME@" \
2 "Repair / Upgrade" \ 2 "Repair / Upgrade" \
@ -614,7 +615,7 @@ menu_main() {
} }
logfile_show() { logfile_show() {
dialog --textbox "$LOGFILE" 20 70 whiptail --textbox "$LOGFILE" 20 70 --scrolltext
clear clear
menu_main menu_main
} }
@ -634,13 +635,16 @@ do_poweroff() {
} }
# setup needed variables # setup needed variables
INSTALLER_VERSION="0.2.8" INSTALLER_VERSION="0.3.0"
OS_VERSION=$(lsb_release) OS_VERSION=$(lsb_release)
BACKTITLE="@DISTRONAME@ Installer $INSTALLER_VERSION - $OS_VERSION" BACKTITLE="@DISTRONAME@ Installer $INSTALLER_VERSION - $OS_VERSION"
TMPDIR="/tmp/installer" TMPDIR="/tmp/installer"
LOGFILE="$TMPDIR/install.log" LOGFILE="$TMPDIR/install.log"
export COLORTERM="1"
export NEWT_COLORS="$WHIPTAIL_COLORS"
# prepare temporary directory # prepare temporary directory
rm -rf $TMPDIR rm -rf $TMPDIR
mkdir -p $TMPDIR mkdir -p $TMPDIR
@ -648,6 +652,12 @@ mkdir -p $TMPDIR
#create log file #create log file
touch "$LOGFILE" touch "$LOGFILE"
# generate the en_US.UTF-8 locale to enable line drawing
mkdir -p $TMPDIR/locale
localedef -i en_US -f UTF-8 $TMPDIR/locale/en_US.UTF-8
export LOCPATH=$TMPDIR/locale
export LC_ALL=en_US.UTF-8
# main # main
while true; do while true; do