mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
installer: remove unused functions, pointless case, recursive calls and faulty breaks
I suspect the recursive calls were to work around the error caused by break being called in a case statement which itself is within a while loop - the break causes the while loop to terminate, bringing the installer to a grinding halt... whoops. Now, menu_main() is called only from the main process loop, which we don't exit accidentally. I've removed an entire case statement from do_install_quick() as this function either performs an installation, or it doesn't - the case statement is pointless. Due to the removal of whitespace, add ?w=1 in github.com when reviewing.
This commit is contained in:
parent
c1167e0bcb
commit
d2ab6680a7
@ -103,6 +103,7 @@ create_device_list() {
|
||||
|
||||
if [ "$DEVICES" = "" ]; then
|
||||
msg_no_device
|
||||
return 1
|
||||
fi
|
||||
|
||||
for i in $DEVICES; do
|
||||
@ -111,6 +112,7 @@ create_device_list() {
|
||||
DEVICE_NAME=$(echo $DEVICE_MODEL ${DEVICE_SIZE} | sed 's/ /_/g')
|
||||
DEVICE_LIST="$DEVICE_LIST $i $DEVICE_NAME"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
do_install_quick() {
|
||||
@ -119,15 +121,14 @@ do_install_quick() {
|
||||
MSG_MENU="\nUse the up/down arrows to select the device you wish to install to.\n\nPlease select a device:"
|
||||
MSG_CANCEL="Back"
|
||||
|
||||
create_device_list
|
||||
create_device_list || return
|
||||
|
||||
whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
|
||||
$DIALOG_OPTIONS --title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \
|
||||
$DEVICE_LIST 2> $TMPDIR/device_for_install
|
||||
[ $? -ne 0 ] && return
|
||||
|
||||
# now we must do everything
|
||||
case $? in
|
||||
0)
|
||||
INSTALL_DEVICE=$(cat "$TMPDIR/device_for_install")
|
||||
INSTALL_DEVICE_FULL=$(echo $DEVICE_LIST | sed "s|.*$INSTALL_DEVICE \([^ ]*\).*|$INSTALL_DEVICE \1|")
|
||||
|
||||
@ -151,18 +152,14 @@ do_install_quick() {
|
||||
DIALOG_OPTIONS="--defaultno"
|
||||
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
|
||||
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
|
||||
if [ $? -ne 0 ]; then
|
||||
menu_main
|
||||
fi
|
||||
[ $? -ne 0 ] && return
|
||||
|
||||
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"
|
||||
DIALOG_OPTIONS="--defaultno"
|
||||
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
|
||||
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
|
||||
if [ $? -ne 0 ]; then
|
||||
menu_main
|
||||
fi
|
||||
[ $? -ne 0 ] && return
|
||||
|
||||
# start the progress bar (whiptail --gauge)
|
||||
{
|
||||
@ -257,6 +254,7 @@ LABEL linux
|
||||
KERNEL /KERNEL
|
||||
APPEND boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE $SYSLINUX_PARAMETERS quiet
|
||||
EOF
|
||||
|
||||
cat << EOF > $TMPDIR/part1/EFI/BOOT/grub.cfg
|
||||
set timeout="0"
|
||||
set default="LibreELEC"
|
||||
@ -266,6 +264,7 @@ menuentry "LibreELEC" {
|
||||
linux /KERNEL boot=UUID=$UUID_SYSTEM disk=UUID=$UUID_STORAGE quiet
|
||||
}
|
||||
EOF
|
||||
|
||||
# uefi boot / hybrid mode
|
||||
cp /usr/share/syslinux/bootx64.efi $TMPDIR/part1/EFI/BOOT
|
||||
cp /usr/share/syslinux/ldlinux.e64 $TMPDIR/part1/EFI/BOOT
|
||||
@ -305,16 +304,6 @@ EOF
|
||||
MSG_TITLE="@DISTRONAME@ Install Complete"
|
||||
MSG_DETAIL="You may now remove the install media and reboot.\n"
|
||||
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 7 52
|
||||
|
||||
menu_main
|
||||
;;
|
||||
1)
|
||||
menu_main
|
||||
;;
|
||||
255)
|
||||
do_poweroff
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
msg_no_device() {
|
||||
@ -323,18 +312,6 @@ msg_no_device() {
|
||||
MSG_INFOBOX=" No devices were found. "
|
||||
|
||||
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 9 73
|
||||
|
||||
menu_main
|
||||
}
|
||||
|
||||
msg_target_space() {
|
||||
# show an error dialog for missing space
|
||||
MSG_TITLE="TARGET SPACE"
|
||||
MSG_INFOBOX="Not enough target space!\nInstallation aborted.\n"
|
||||
|
||||
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 9 73
|
||||
|
||||
menu_main
|
||||
}
|
||||
|
||||
msg_progress_install() {
|
||||
@ -348,15 +325,6 @@ msg_progress_install() {
|
||||
echo XXX
|
||||
}
|
||||
|
||||
msg_install_ready() {
|
||||
# show a dialog that we have installed
|
||||
MSG_TITLE="INFORMATION"
|
||||
|
||||
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox " $1" 7 73
|
||||
|
||||
menu_main
|
||||
}
|
||||
|
||||
prompt_gpt() {
|
||||
GPT="0"
|
||||
UEFI="0"
|
||||
@ -403,16 +371,16 @@ out during the installation. \
|
||||
whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
|
||||
--title "$MSG_TITLE" --menu "$MSG_MENU" 18 73 3 \
|
||||
1 "Install @DISTRONAME@" \
|
||||
2 "Installation log" \
|
||||
2 "View installation log" \
|
||||
3 "Reboot" 2> $TMPDIR/mainmenu
|
||||
|
||||
case $? in
|
||||
0)
|
||||
ITEM_MAINMENU=$(cat "$TMPDIR/mainmenu")
|
||||
case $ITEM_MAINMENU in
|
||||
1) do_install_quick; break;;
|
||||
2) logfile_show; break;;
|
||||
3) do_reboot;
|
||||
1) do_install_quick;;
|
||||
2) logfile_show;;
|
||||
3) do_reboot;;
|
||||
esac
|
||||
;;
|
||||
1)
|
||||
@ -426,8 +394,6 @@ out during the installation. \
|
||||
|
||||
logfile_show() {
|
||||
whiptail --textbox "$LOGFILE" 20 73 --scrolltext --backtitle "$BACKTITLE"
|
||||
clear
|
||||
menu_main
|
||||
}
|
||||
|
||||
do_reboot() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user