summaryrefslogtreecommitdiff
path: root/src/fifa.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/fifa.sh')
-rwxr-xr-xsrc/fifa.sh120
1 files changed, 88 insertions, 32 deletions
diff --git a/src/fifa.sh b/src/fifa.sh
index 53ad10b..0209bf2 100755
--- a/src/fifa.sh
+++ b/src/fifa.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-
+# TODO: we should be able to get away with not defining the "These functions would fit more in lib-ui, but we need them immediately" functions in lib-ui, but just sourcing lib-ui very early
###### Set some default variables or get them from the setup script ######
TITLE="Flexible Installer Framework for Arch linux"
@@ -11,17 +11,17 @@ LOG="/dev/tty7"
usage ()
{
+ msg="$0 <procedurename>\n
+If the procedurename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a procedure in the VFS tree\n
+If the procedurename is prefixed with '<modulename>/' it will be loaded from user module <modulename>. See README\n
+Available procedures:\n
+`ls -l /home/arch/fifa/core/procedures`\n
+`ls -l /home/arch/fifa/user/*/procedures`"
if [ "$var_UI_TYPE" = dia ]
then
- DIALOG --msgbox "$0 <profilename>\n
- If the profilename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a profile saved on disk. See README\n
- Available profiles:\n
- `ls -l /home/arch/fifa/profile-*`" 14 65
+ DIALOG --msgbox "$msg" 14 65
else
- echo "$0 <profilename>"
- echo "If the profilename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a profile saved on disk. See README"
- echo "Available profiles:"
- ls -l /home/arch/fifa/profile-*
+ echo "$msg"
fi
}
@@ -77,29 +77,63 @@ notify ()
###### Core functions ######
-load_profile()
+
+# $1 module name
+load_module ()
+{
+ [ -z "$1" ] && die_error "load_module needs a module argument"
+ notify "Loading module $1 ..."
+ path=/home/arch/fifa/user/"$1"
+ [ "$1" = core ] && path=/home/arch/fifa/core
+
+ for submodule in lib procedure
+ do
+ if [ ! -d "$path/${submodule}s" ]
+ then
+ # ignore this problem for not-core modules
+ [ "$1" = core ] && die_error "$path/${submodule}s does not exist. something is horribly wrong with this installation"
+ else
+ shopt -s nullglob
+ for i in "$path/${submodule}s"/*
+ do
+ load_${submodule} "$1" "`basename "$i"`"
+ done
+ fi
+ done
+
+}
+
+
+# $1 module name
+# $2 procedure name
+load_procedure()
{
- [ -z "$1" ] && die_error "load_profile needs a profile argument"
- notify "Loading profile $1 ..."
- if [[ $1 =~ ^http:// ]]
+ [ -z "$1" ] && die_error "load_procedure needs a module as \$1 and procedure as \$2"
+ [ -z "$2" ] && die_error "load_procedure needs a procedure as \$2"
+ if [ "$1" = 'http:' ]
then
- profile=/home/arch/fifa/profile-downloaded-`basename $1`
- wget $1 -q -O $profile >/dev/null || die_error "Could not download profile $1"
+ notify "Loading procedure $2 ..."
+ procedure=/home/arch/fifa/runtime/procedure-downloaded-`basename $2`
+ wget "$2" -q -O $procedure >/dev/null || die_error "Could not download procedure $2"
else
- profile=/home/arch/fifa/profile-$1
+ notify "Loading procedure $1/procedures/$2 ..."
+ procedure=/home/arch/fifa/user/"$1"/procedures/"$2"
+ [ "$1" = core ] && procedure=/home/arch/fifa/core/procedures/"$2"
fi
- [ -f "$profile" ] && source "$profile" || die_error "Something went wrong while sourcing profile $profile"
+ [ -f "$procedure" ] && source "$procedure" || die_error "Something went wrong while sourcing procedure $procedure"
}
-load_library ()
+# $1 module name
+# $2 library name
+load_lib ()
{
- [ -z "$1" ] && die_error "load_library needs a library argument"
- for library in $@
- do
- notify "Loading library $library ..."
- source $library || die_error "Something went wrong while sourcing library $library"
- done
+ [ -z "$1" ] && die_error "load_library needs a module als \$1 and library as \$2"
+ [ -z "$2" ] && die_error "load_library needs a library as \$2"
+ notify "Loading library $1/libs/$2 ..."
+ lib=/home/arch/fifa/user/"$1"/libs/"$2"
+ [ "$1" = core ] && lib=/home/arch/fifa/core/libs/"$2"
+ source $lib || die_error "Something went wrong while sourcing library $lib"
}
@@ -120,6 +154,12 @@ execute ()
}
+depend_module ()
+{
+ load_module "$1"
+}
+
+
start_process ()
{
execute phase preparation
@@ -136,16 +176,32 @@ echo "Welcome to $TITLE"
mount -o remount,rw / &>/dev/null
-load_library /home/arch/fifa/lib/lib-*.sh
-
-[ "$1" != base ] && load_profile base
-load_profile $1
-
-# Set pacman vars. allow profiles to have set $var_TARGET_DIR (TODO: look up how delayed variable substitution works. then we can put this at the top again)
-# flags like --noconfirm should not be specified here. it's up to the profile to decide the interactivity
+# note that we allow procedures like http://foo/bar. module -> http:, procedure -> http://foo/bar.
+if [[ $1 =~ ^http:// ]]
+then
+ module=http
+ procedure="$1"
+elif grep -q '\/' <<< "$1"
+then
+ #user specified module/procedure
+ module=`dirname "$1"`
+ procedure=`basename "$1"`
+else
+ module=core
+ procedure="$1"
+fi
+
+load_module core
+[ "$module" != core -a "$module" != http ] && load_module "$module"
+
+[ "$module" != core -o "$procedure" != base ] && load_procedure core base
+load_procedure "$module" "$procedure"
+
+# Set pacman vars. allow procedures to have set $var_TARGET_DIR (TODO: look up how delayed variable substitution works. then we can put this at the top again)
+# flags like --noconfirm should not be specified here. it's up to the procedure to decide the interactivity
PACMAN=pacman
PACMAN_TARGET="pacman --root $var_TARGET_DIR --config /tmp/pacman.conf"
start_process
-exit 0 \ No newline at end of file
+exit 0