summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/procedures/base52
-rw-r--r--src/core/procedures/interactive2
-rwxr-xr-xsrc/fifa.sh63
3 files changed, 76 insertions, 41 deletions
diff --git a/src/core/procedures/base b/src/core/procedures/base
index dd2842e..2c76d16 100644
--- a/src/core/procedures/base
+++ b/src/core/procedures/base
@@ -8,39 +8,28 @@ var_UI_TYPE="cli" # set to cli or dia for dialog
###### Phases ( can be overridden by more specific procedures) ######
-phase_preparation ()
-{
- execute worker select_source
- execute worker runtime_network
- execute worker runtime_packages
-}
+phase_preparation=(\
+ select_source \
+ runtime_network \
+ runtime_packages)
+phase_basics=(\
+ set_clock \
+ prepare_disks)
-phase_basics ()
-{
- execute worker set_clock
- execute worker prepare_disks
-}
+phase_system=(\
+ package_list \
+ install_packages \
+ auto_fstab \
+ auto_network \
+ auto_locale \
+ configure_system \
+ mkinitcpio \
+ locales \
+ install_bootloader)
-phase_system ()
-{
- execute worker package_list
- execute worker install_packages
- execute worker auto_fstab #TODO: exact names of these 3
- execute worker auto_network
- execute worker auto_locale
- execute worker configure_system
- execute worker mkinitcpio
- execute worker locales
- execute worker install_bootloader
-}
-
-
-phase_finish ()
-{
- true
-}
+phase_finish=(msg_report)
@@ -153,3 +142,8 @@ worker_install_bootlader ()
#TODO: ask which disk, install grub on it
true
}
+
+worker_msg_report ()
+{
+ show_report
+}
diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive
index 85e47b2..3bc8ee4 100644
--- a/src/core/procedures/interactive
+++ b/src/core/procedures/interactive
@@ -27,7 +27,7 @@ start_process ()
#####################
## begin execution ##
- # install stages
+ # install stages #TODO: now that exit states of all workers are maintained by the execute function, we can probably simplify this
S_SRC=0 # choose install medium
S_NET=0 # network configuration
S_CLOCK=0 # clock and timezone
diff --git a/src/fifa.sh b/src/fifa.sh
index 795cd15..0812902 100755
--- a/src/fifa.sh
+++ b/src/fifa.sh
@@ -103,20 +103,37 @@ execute ()
{
[ -z "$1" -o -z "$2" ] && die_error "Use the execute function like this: execute <type> <name> with type=phase/worker"
[ "$1" != phase -a "$1" != worker ] && die_error "execute's first argument must be a valid type (phase/worker)"
- [ "$1" = phase ] && log "******* Executing phase $2"
- [ "$1" = worker ] && log "*** Executing worker $2"
- to_execute=$1_$2
- shift 2
- if type -t $to_execute | grep -q function
+ PWD_BACKUP=`pwd`
+ object=$1_$2
+
+ if [ "$1" = worker ]
then
- PWD_BACKUP=`pwd`
- $to_execute "$@"
- ret=$?
- cd $PWD_BACKUP
- else
- die_error "$to_execute is not defined!"
+ log "*** Executing worker $2"
+ if type -t $object | grep -q function
+ then
+ shift 2
+ $object "$@"
+ ret=$?
+ exit_var=exit_$object
+ read $exit_var <<< $ret # maintain exit status of each worker
+ else
+ die_error "$object is not defined!"
+ fi
+ elif [ "$1" = phase ]
+ then
+ log "******* Executing phase $2"
+ exit_var=exit_$object
+ read $exit_var <<< 0
+
+ eval phase_array=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-) # props to jedinerd at #bash for this hack.
+ for worker_str in "${phase_array[@]}" # worker_str contains the name of the worker and optionally any arguments
+ do
+ execute worker $worker_str || read $exit_var <<< $? # assign last failing exit code to exit_phase_<phasename>, if any.
+ done
+ ret={!exit_var}
fi
+ cd $PWD_BACKUP
return $ret
}
@@ -142,6 +159,30 @@ start_process ()
}
+show_report () #TODO: abstract UI method (cli/dia)
+{
+ echo "Execution Report:"
+ echo "-----------------"
+ for phase in preparation basics system finish
+ do
+ object=phase_$phase
+ exit_var=exit_$object
+ ret={!exit_var}
+ echo -n "Phase $phase: "
+ [ "$ret" = "0" ] && echo "Success" || echo "Failed"
+ eval phase_array=$(declare | grep -e "^${object}=" | cut -d"=" -f 2-)
+ for worker_str in "${phase_array[@]}"
+ do
+ worker=${worker_str%% *}
+ exit_var=exit_worker_$worker
+ ret={!exit_var}
+ echo -n " > Worker $worker: "
+ [ "$ret" = "0" ] && echo "Success" || echo "Failed"
+ done
+ done
+}
+
+
# use this function to stop the installation procedure.
# $1 exit code (optional)
stop_installer ()