From 392e855ceae3fc17584761c79a8d0e5616ed088f Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Tue, 11 Nov 2008 21:31:00 +0100 Subject: first version of new "dependency" checking and tracking (flow control) in core/interactive + better nextitem setting + tmp_fstab fix --- src/core/libs/lib-ui-interactive.sh | 17 ++++++++++++++++- src/core/procedures/base | 4 +--- src/core/procedures/interactive | 22 +++++++++++++--------- 3 files changed, 30 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 123415a..9dc9a93 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -1,6 +1,21 @@ #!/bin/sh #TODO: get backend code out of here!! + +# check if a worker has completed successfully. if not -> tell user he must do it + return 1 +# if ok -> don't warn anything and return 0 +check_depend () +{ + [ -z "$1" -o -z "$2" ] && die_error "Use the check_depend function like this: check_depend with type=phase/worker" + [ "$1" != phase -a "$1" != worker ] && die_error "check_depend's first argument must be a valid type (phase/worker)" + + object=$1_$2 + exit_var=exit_$object + [ "${!exit_var}" = '0' ] && return 0 + show_warning "Cannot Continue. Going back to $2" "You must do $2 first before going here!." && return 1 +} + + interactive_partition() { target_umountall @@ -289,7 +304,7 @@ EOF interactive_mountpoints() { while [ "$PARTFINISH" != "DONE" ]; do - : >/$TMP_FSTAB + : >$TMP_FSTAB : >/tmp/.parts # Determine which filesystems are available diff --git a/src/core/procedures/base b/src/core/procedures/base index 09c8bd8..9d31441 100644 --- a/src/core/procedures/base +++ b/src/core/procedures/base @@ -99,9 +99,7 @@ worker_install_packages () worker_auto_fstab () { - if [ "$S_MKFS" = "1" -o "$S_MKFSAUTO" = "1" ]; then - target_configure_fstab - fi + target_configure_fstab } diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive index 93aade4..b71049b 100644 --- a/src/core/procedures/interactive +++ b/src/core/procedures/interactive @@ -27,7 +27,10 @@ start_process () ##################### ## begin execution ## - # install stages #TODO: now that exit states of all workers are maintained by the execute function, we can probably simplify this + #TODO: implement check_depend everywhere + #TODO: now that exit states of all workers are maintained by the execute function, we can get rid of this special flow control + + # install stages S_SRC=0 # choose install medium S_NET=0 # network configuration S_CLOCK=0 # clock and timezone @@ -90,19 +93,19 @@ mainmenu() fi [ $ret -eq 0 ] && S_SRC=1 && execute worker runtime_packages ;; "1") - execute worker set_clock && S_CLOCK=1 ;; + execute worker set_clock && S_CLOCK=1 && NEXTITEM=2;; "2") - execute worker prepare_disks ;; # stage set vars set in the worker #TODO: when this is done, default next item is clock? + execute worker prepare_disks && NEXTITEM=3;; # stage set vars set in the worker "3") - execute worker package_list && S_SELECT=1 ;; + check_depend worker prepare_disks && execute worker package_list && S_SELECT=1 && NEXTITEM=4 ;; "4") - execute worker install_packages && S_INSTALL=1 && { execute worker auto_fstab; execute worker auto_network; execute worker auto_locale; } ;; #TODO: next item is again install packages + check_depend worker package_list && execute worker install_packages && S_INSTALL=1 && { execute worker auto_fstab; execute worker auto_network; execute worker auto_locale; } && NEXITITEM=5 ;; "5") - execute worker configure_system && S_CONFIG=1 && { execute worker mkinitcpio; execute worker locales; } ;; + check_depend worker install_packages && execute worker configure_system && S_CONFIG=1 && { execute worker mkinitcpio; execute worker locales; } && NEXTITEM=6 ;; "6") - execute worker install_bootloader && S_BOOT=1 ;; + execute worker install_bootloader && S_BOOT=1 && NEXTITEM=7 ;; "7") - notify "If the install finished successfully, you can now type 'reboot' to restart the system." && stop_installer ;; + notify "If the install finished successfully, you can now type 'reboot' to restart the system." && stop_installer ;; *) ask_yesno "Abort Installation?" && stop_installer ;; esac @@ -174,7 +177,8 @@ worker_prepare_disks() DONE=1 ;; esac done - NEXTITEM="1" + [ $S_MKFSAUTO -eq 1 -o $S_MKFS -eq 1 -a $S_PART -eq 1 ] && return 0 + return 1 } -- cgit v1.2.3-54-g00ecf