summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README6
-rwxr-xr-xsrc/aif.sh81
-rw-r--r--src/core/procedures/base7
-rw-r--r--src/core/procedures/interactive8
-rw-r--r--unofficial/modules/dieter/procedures/automatic7
5 files changed, 88 insertions, 21 deletions
diff --git a/README b/README
index ffaf60d..d63f646 100644
--- a/README
+++ b/README
@@ -87,7 +87,11 @@ You can specify a core procedure on the command line by specifying
'<procedure_name>', to specify a user contriubuted procedure, specify
'<module_name>/<procedure_name>'
-
+Commandline arguments are parsed by aif.sh but you can extend/override it's
+behaviour by overriding $var_OPTS_STRING and the process_vars variable.
+Also, you do not _have_ to use the variables they set (eg arg_ui_type). You
+usually will set defaults in the configure worker and override with
+arguments passed by the user (eg to use cli mode unless user wants dia)
** Procedures **
diff --git a/src/aif.sh b/src/aif.sh
index 095256b..2e3c0de 100755
--- a/src/aif.sh
+++ b/src/aif.sh
@@ -5,15 +5,16 @@ TITLE="Arch Linux Installation Framework"
LOG="/dev/tty7"
LOGFILE=/home/arch/aif/runtime/aif.log
-#TODO: maybe we could use optional flags to en/disable logging to a file, override UI_TYPE etc.
-
-
###### Miscalleaneous functions ######
usage ()
{
#NOTE: you can't use dia mode here yet because lib-ui isn't sourced yet. But cli is ok for this anyway.
- msg="$0 <procedurename>\n
+ msg="$0 -p <procedurename> Select a procedure\n
+ -i <dia/cli> Override interface type (optional)\n
+ -d Explicitly enable debugging (optional)\n
+ -l Explicitly enable logging to file (optional)\n
+ -h Help: show usage (optional)
If the procedurename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a procedure in the VFS tree
If the procedurename is prefixed with '<modulename>/' it will be loaded from user module <modulename>. See README\n
Available procedures on the filesystem:
@@ -231,6 +232,11 @@ show_report () #TODO: abstract UI method (cli/dia)
}
+process_args ()
+{
+}
+
+
# use this function to stop the installation procedure.
# $1 exit code (optional)
stop_installer ()
@@ -247,20 +253,6 @@ log "################## START OF INSTALLATION ##################"
mount -o remount,rw / &>/dev/null
-# 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"
@@ -272,6 +264,57 @@ load_procedure "$module" "$procedure"
PACMAN=pacman
PACMAN_TARGET="pacman --root $var_TARGET_DIR --config /tmp/pacman.conf"
+
+### Set configuration values ###
+# note : you're free to use or ignore these in your procedure. probably you want to use these variables to override defaults in your configure worker
+
+var_OPTS_STRING=":i:dlp:" # you can override this variable in your procedure.
+while getopts $var_OPTS_STRING OPTION
+do
+ case $OPTION in
+ i)
+ [ -z "$OPTARG" ] && usage && exit 1 #TODO: check if it's necessary to do this. the ':' in $var_OPTS_STRING might be enough
+ [ "$OPTARG" != cli -a "$OPTARG" = !dia ] && die_error "-i must be dia or cli"
+ arg_ui_type=$OPTARG
+ ;;
+ d)
+ export DEBUG=1
+ ;;
+ l)
+ LOG_TO_FILE=1 #TODO: implement using this variable
+ ;;
+ p)
+ [ -z "$OPTARG" ] && usage && exit 1
+ # 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
+ ;;
+ h)
+ usage
+ stop_installer
+ ;;
+ ?)
+ usage
+ stop_installer 5
+ ;;
+ esac
+
+ process_args $OPTION $OPTARG # you can override this function in your profile to parse additional arguments and/or override the behavior above
+done
+
+[ -z "$procedure" ] && usage && stop_installer 5
+
start_process
-exit 0
+stop_installer
diff --git a/src/core/procedures/base b/src/core/procedures/base
index 24131dd..c163a0e 100644
--- a/src/core/procedures/base
+++ b/src/core/procedures/base
@@ -8,6 +8,7 @@ var_UI_TYPE="cli" # set to cli or dia for dialog
###### Phases ( can be overridden by more specific procedures) ######
phase_preparation=(\
+ configure \
intro \
select_source \
runtime_network \
@@ -44,6 +45,12 @@ worker_intro ()
}
+worker_configure ()
+{
+ var_UI_TYPE=${arg_ui_type:-cli}
+}
+
+
worker_select_source ()
{
var_PKG_SOURCE_TYPE='cd'
diff --git a/src/core/procedures/interactive b/src/core/procedures/interactive
index 9739cd3..c01c0fa 100644
--- a/src/core/procedures/interactive
+++ b/src/core/procedures/interactive
@@ -35,7 +35,7 @@ start_process ()
#####################
## begin execution ##
- var_UI_TYPE=dia
+ execute worker configure
execute worker intro
@@ -190,6 +190,12 @@ worker_intro ()
}
+worker_configure ()
+{
+ var_UI_TYPE=${arg_ui_type:-dia}
+}
+
+
# select_packages()
# prompts the user to select packages to install
worker_package_list() {
diff --git a/unofficial/modules/dieter/procedures/automatic b/unofficial/modules/dieter/procedures/automatic
index 809a8ab..9a093fa 100644
--- a/unofficial/modules/dieter/procedures/automatic
+++ b/unofficial/modules/dieter/procedures/automatic
@@ -5,6 +5,7 @@ depend_procedure core base
var_RUNTIME_PACKAGES="svn"
phase_preparation=(\
+ configure \
intro \
msg_manual \
runtime_network \
@@ -23,6 +24,12 @@ worker_intro ()
}
+worker_configure ()
+{
+ var_UI_TYPE=${arg_ui_type:-cli}
+}
+
+
worker_msg_manual ()
{
# All things that need to be done manually first