From a773620cca0122cf9dae166636ded643dddbb53c Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Fri, 17 Dec 2010 19:19:31 +0100 Subject: centralize interactive rollback code, ask for rollback when needed when aborting interactive install --- src/core/libs/lib-ui-interactive.sh | 39 ++++++++++++++++++++++++------------- src/core/procedures/interactive | 11 ++++++++++- 2 files changed, 35 insertions(+), 15 deletions(-) (limited to 'src/core') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 00592b7..a77a873 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -220,20 +220,7 @@ interactive_prepare_disks () interactive_filesystems && ret=0 && NEXTITEM=5 && DISK_CONFIG_TYPE=manual ;; "4") - if [ "$BLOCK_ROLLBACK_USELESS" = "1" ] - then - ask_yesno "It seems like you haven't partitioned/formatted/mounted anything yet (or rolled back already). This operation is useless (unless the installer is buggy), but it doesn't harm. Do you want to continue?" || NEXTITEM=5 - fi - if [ $? -eq 0 -o "$BLOCK_ROLLBACK_USELESS" = "0" ] - then - if rollback_filesystems - then - inform "Rollback succeeded" - else - show_warning "Rollback failed" "Rollback failed" - fi - fi - ;; + interactive_rollback_filesystems;; "5") DONE=1 ;; esac @@ -241,7 +228,31 @@ interactive_prepare_disks () return $ret } +maybe_interactive_rollback_filesystems () +{ + [ "$BLOCK_ROLLBACK_USELESS" = "1" ] && return 0 + if ask_yesno "Do you want to rollback your filesystem changes?" + then + interactive_rollback_filesystems || return $? + fi + return 0 +} +# it's up to the caller to decide if it's needed to call this function, so we warn user when he wants to do a useless rollback +interactive_rollback_filesystems () +{ + if [ "$BLOCK_ROLLBACK_USELESS" = "1" ] + then + ask_yesno "It seems like there is nothing rollback right now. This operation is useless, but it shouldn't harm. Do you want to continue?" || return + fi + if rollback_filesystems + then + inform "Rollback succeeded" + else + show_warning "Rollback failed" "Rollback failed" + return 1 + fi +} interactive_autoprepare() { diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive index 2f90563..0223763 100644 --- a/src/core/procedures/interactive +++ b/src/core/procedures/interactive @@ -87,7 +87,7 @@ mainmenu() "8") notify "If the install finished successfully, you can now type 'reboot' to restart the system." && stop_installer ;; *) - ask_yesno "Abort Installation?" && stop_installer ;; + execute worker abort_installer;; esac } @@ -188,3 +188,12 @@ worker_auto_network () return 1 fi } + +worker_abort_installer () +{ + ret=0 + ask_yesno "Abort Installation?" || return + maybe_interactive_rollback_filesystems || ret=$? + stop_installer || ret=$? + return $ret +} -- cgit v1.2.3-54-g00ecf