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 ++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/core/libs') 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() { -- cgit v1.2.3-54-g00ecf