summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO8
-rwxr-xr-xsrc/fifa.sh70
-rw-r--r--src/lib/lib-ui.sh32
-rw-r--r--src/lib/whatsthis.txt5
-rw-r--r--src/profiles/profile-base7
-rw-r--r--src/profiles/profile-dieter4
6 files changed, 93 insertions, 33 deletions
diff --git a/TODO b/TODO
index 6352cdb..af5ce25 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,7 @@
-* global variable that says if we're in cli or dialog mode, check that in
- all functions and act accordingly
+* process and fix libraries
+* fix to use $var_UI_TYPE where needed
+* write the ui functions for asking questions etc for both cli and dialog,
+and port all code to use it.
* instead of using the 'base' profile and letting other profiles override,
we should have even more flexibilty to take parts from different profiles.
* fix crossconcerns: some procedures could be about _what_ (desktop,server),
@@ -7,4 +9,4 @@
'mode' ?)
* make some sensible default profiles (eg desktop, server, ...)
* make it work
-* someday.. make a script '/arch/setup' that calls '/arch/fifa.sh interactive' \ No newline at end of file
+* someday.. make a script '/arch/setup' that calls '/arch/fifa.sh interactive'
diff --git a/src/fifa.sh b/src/fifa.sh
index 52635ca..28bc8c8 100755
--- a/src/fifa.sh
+++ b/src/fifa.sh
@@ -14,36 +14,63 @@ PACMAN_TARGET="pacman --root $TARGET_DIR --config /tmp/pacman.conf"
usage ()
{
- echo "$0 <profilename>"
- echo "If the profilename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a profile file like /home/arch/fifa/profile-<profilename>"
- echo "If you wrote your own profile, you can also save it yourself as /home/arch/fifa/profile-custom or something like that"
- echo "Available profiles:"
- ls -l /home/arch/fifa/profile-*
- echo "Extra info:"
- echo "There is a very basic but powerfull workflow defined by variables, phases and workers. Depending on the profile you choose (or write yourself), these will differ."
- echo "they are very recognizable and are named like this:"
- echo " - variable -> var_<foo>"
- echo " - phase -> phase_<bar> (a function that calls workers and maybe does some stuff by itself. There are 4 phases: preparation, basics, system, finish. (executed in that order)"
- echo " - worker -> worker_<baz> ( a worker function, called by a phase. implements some specific logic. eg runtime_packages, prepare_disks, package_list etc)"
- echo "If you specify a profile name other then base, the base profile will be sourced first, then the specific profile. This way you only need to override specific things."
- echo "Notes:"
- echo " - you _can_ override _all_ variables and functions in this script, but you should be able to achieve your goals by overriding things of these 3 classes)"
- echo " - you _must_ specify a profile, to avoid errors. take 'base' if unsure"
- echo " - don't edit the base profile (or any other that comes by default), rather make your own"
+ if [ "$var_UI_TYPE" = dia ]
+ then
+ #TODO: do this
+ true
+ else
+ echo "$0 <profilename>"
+ echo "If the profilename starts with 'http://' it will be wget'ed. Otherwise it's assumed to be a profile file like /home/arch/fifa/profile-<profilename>"
+ echo "If you wrote your own profile, you can also save it yourself as /home/arch/fifa/profile-custom or something like that"
+ echo "Available profiles:"
+ ls -l /home/arch/fifa/profile-*
+ echo "Extra info:"
+ echo "There is a very basic but powerfull workflow defined by variables, phases and workers. Depending on the profile you choose (or write yourself), these will differ."
+ echo "they are very recognizable and are named like this:"
+ echo " - variable -> var_<foo>"
+ echo " - phase -> phase_<bar> (a function that calls workers and maybe does some stuff by itself. There are 4 phases: preparation, basics, system, finish. (executed in that order)"
+ echo " - worker -> worker_<baz> ( a worker function, called by a phase. implements some specific logic. eg runtime_packages, prepare_disks, package_list etc)"
+ echo "If you specify a profile name other then base, the base profile will be sourced first, then the specific profile. This way you only need to override specific things."
+ echo "Notes:"
+ echo " - you _can_ override _all_ variables and functions in this script, but you should be able to achieve your goals by overriding things of these 3 classes)"
+ echo " - you _must_ specify a profile, to avoid errors. take 'base' if unsure"
+ echo " - don't edit the base profile (or any other that comes by default), rather make your own"
+ fi
}
+##### "These functions would fit more in lib-ui, but we need them immediately" functions ######
+
die_error ()
{
- echo "ERROR: $@"
+ if [ "$var_UI_TYPE" = dia ]
+ then
+ DIALOG --msgbox "Error: $@" 0 0
+ else
+ echo "ERROR: $@"
+ fi
exit 2
}
+notify ()
+{
+ if [ "$var_UI_TYPE" = dia ]
+ then
+ #TODO: implement this
+ true
+ else
+ echo "$@"
+ fi
+}
+
+
+###### Core functions ######
+
load_profile()
{
[ -z "$1" ] && die_error "load_profile needs a profile argument"
- echo "Loading profile $1 ..."
+ notify "Loading profile $1 ..."
if [[ $1 =~ ^http:// ]]
then
profile=/home/arch/fifa/profile-downloaded-`basename $1`
@@ -60,7 +87,7 @@ load_library ()
[ -z "$1" ] && die_error "load_library needs a library argument"
for library in $@
do
- echo "Loading library $library ..."
+ notify "Loading library $library ..."
source $library || die_error "Something went wrong while sourcing library $library"
done
}
@@ -70,8 +97,8 @@ 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 ] && echo "******* Executing phase $2"
- [ "$1" = worker ] && echo "*** Executing worker $2"
+ [ "$1" = phase ] && notify "******* Executing phase $2"
+ [ "$1" = worker ] && notify "*** Executing worker $2"
if type -t $1_$2 | grep -q function
then
PWD_BACKUP=`pwd`
@@ -84,7 +111,6 @@ execute ()
-
###### perform actual logic ######
echo "Welcome to $TITLE"
[ -z "$1" ] && usage && exit 1
diff --git a/src/lib/lib-ui.sh b/src/lib/lib-ui.sh
index 5cd7ecc..37f316e 100644
--- a/src/lib/lib-ui.sh
+++ b/src/lib/lib-ui.sh
@@ -58,4 +58,34 @@ gui_ask_bootloader()
"None" "\Zb\Z1Warning\Z0\ZB: you must install your own bootloader!" 2>$ANSWER
cat $ANSWER
}
- \ No newline at end of file
+
+
+# ask the user a password. return is stored in $PASSWORD or $PASSWORD_TYPE
+# $1 type (optional. eg 'svn', 'ssh').
+cli_ask_password ()
+{
+ if [ -n "$1" ]
+ then
+ true
+ fi
+}
+
+cli_ask_yesno ()
+{
+}
+
+cli_ask_string ()
+{
+}
+
+
+cli_ask_number ()
+{
+}
+
+
+cli_ask_option ()
+{
+}
+
+ \ No newline at end of file
diff --git a/src/lib/whatsthis.txt b/src/lib/whatsthis.txt
index 1125767..72e5e15 100644
--- a/src/lib/whatsthis.txt
+++ b/src/lib/whatsthis.txt
@@ -1,7 +1,7 @@
This directory contains several useful functions and scripts, ready to be
used by fifa and it's profiles.
-Right now, all this code is taken (and modified) from the 'real' arch linux install scripts
+Most of this code is taken (and modified) from the 'real' arch linux install scripts
code. (/arch/setup and /arch/quickinst). the modifications are mostly done
to make the code more useable and to separate backend code from the user
interface (which was tightly coupled in the original scripts)
@@ -11,4 +11,5 @@ I couldn't find what license the code is under, but I assume this
is okay.. if not let me know.
The original code is at http://projects.archlinux.org/?p=installer.git;a=summary
-Later on, maybe other code can be put here too.
+I also wrote a few functions myself that I didn't find in the official
+scripts (mostly separate ui functions)
diff --git a/src/profiles/profile-base b/src/profiles/profile-base
index 4c5f77c..72df3b1 100644
--- a/src/profiles/profile-base
+++ b/src/profiles/profile-base
@@ -7,6 +7,7 @@ var_PKG_SOURCE_TYPE='cd'
var_PKG_FILE=/home/arch/fifa/package-list
var_FILE_URL="file:///src/core/pkg"
var_MIRRORLIST="/etc/pacman.d/mirrorlist"
+var_UI_TYPE="cli" # set to cli or dia for dialog
###### Phases ( can be overridden by more specific profiles) ######
@@ -57,7 +58,7 @@ worker_prepare_disks ()
worker_package_list ()
{
#TODO: sensible list of packages
- echo "No actions specified"
+ true
}
@@ -75,12 +76,12 @@ worker_install_packages ()
worker_install_bootlader ()
{
#TODO: autodetection or whatever
- echo "No actions specified"
+ true
}
worker_configure_home ()
{
- echo "No actions specified"
+ notify "No actions specified"
}
diff --git a/src/profiles/profile-dieter b/src/profiles/profile-dieter
index a0c369f..8580fd4 100644
--- a/src/profiles/profile-dieter
+++ b/src/profiles/profile-dieter
@@ -4,7 +4,7 @@ var_RUNTIME_PACKAGES="svn"
phase_preparation ()
{
# All things that need to be done manually first
- echo "A few manual things need to happen first..."
+ notify "A few manual things need to happen first..."
echo -n "Do you want to (re)-configure your networking? (y/*)"
read answer
if [ "$answer" = y ]
@@ -25,7 +25,7 @@ phase_preparation ()
#TODO: find something against svn's interactive ssl cert checking. http://www.7php.net/svn-client-certificate-authentication-cache/ might help
- echo "**** From now on. everything will be automatic. Enjoy the show!"
+ notify "**** From now on. everything will be automatic. Enjoy the show!"
execute worker runtime_packages
}