diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2008-10-30 19:58:29 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2008-10-30 19:58:29 +0100 |
commit | c4ec3e695b2ebb6d3e57c65e69616d9277fd041f (patch) | |
tree | 83cfd2d9e76d6cc25d2285fbadb14f203d6a89a4 /src |
first commit
Diffstat (limited to 'src')
-rw-r--r-- | src/fifa.sh | 83 | ||||
-rw-r--r-- | src/profiles/profile-base | 80 | ||||
-rw-r--r-- | src/profiles/profile-dieter | 22 |
3 files changed, 185 insertions, 0 deletions
diff --git a/src/fifa.sh b/src/fifa.sh new file mode 100644 index 0000000..28fe891 --- /dev/null +++ b/src/fifa.sh @@ -0,0 +1,83 @@ +#!/bin/bash + + +###### Set some default variables or get them from the setup script ###### +TITLE="Flexible Installer Framework for Arch linux" +eval `grep ^LOG= /arch/setup` +PACMAN_RUNTIME=pacman +PACMAN="pacman --root $DESTDIR --config /tmp/pacman.conf --noconfirm" + + + +###### Miscalleaneous functions ###### + +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" +} + + +die_error () +{ + echo "ERROR: $@" + exit 2 +} + + +load_profile() +{ + #TODO: http support + echo "Loading profile $1 ..." + profile=/home/arch/fifa/profile-"$1" + [ -f "$profile" ] && source "$profile" || die_error "Something went wrong while sourcing profile $profile" +} + + +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" + if type -t $1_$2 | grep -q function + then + PWD_BACKUP=`pwd` + $1_$2 + cd $PWD_BACKUP + else + die_error "$1 $2 is not defined!" + fi +} + + + + +###### perform actual logic ###### +echo "Welcome to $TITLE" +[ -z "$1" ] && usage && exit 1 + +mount -o remount,rw / &>/dev/null + +[ "$1" != base ] && load_profile base +load_profile $1 + +execute phase preparation +execute phase basics +execute phase system +execute phase finish + diff --git a/src/profiles/profile-base b/src/profiles/profile-base new file mode 100644 index 0000000..64605d2 --- /dev/null +++ b/src/profiles/profile-base @@ -0,0 +1,80 @@ +#!/bin/bash + +var_DEFAULTFS="/boot:32:ext2:+ swap:256:swap /:7500:ext3 /home:*:ext3" +var_DESTDIR="/mnt" +var_RUNTIME_PACKAGES= + + + +###### Phases ( can be overridden by more specific profiles) ###### + +phase_preparation () +{ + execute worker runtime_packages +} + + +phase_basics () +{ + execute worker prepare_disks +} + + +phase_system () +{ + execute worker package_list + execute worker install_packages + execute worker install_bootloader +} + + +phase_finish () +{ + execute worker configure_home +} + + + +###### Workers ( can be overridden by more specific profiles) ###### +worker_runtime_packages () +{ + for pkg in $RUNTIME_PACKAGES + do + pacman -Sy $pkg + done +} + + +worker_prepare_disks () +{ + +} + + +# Put the list of packages to be installed in /home/arch/automatic-package-list +worker_package_list () +{ + #TODO: sensible list of packages + echo "No actions specified" +} + + +worker_install_packages () +{ + #TODO: installation of the packages + echo "No actions specified" +} + + +worker_install_bootlader () +{ + #TODO: autodetection or whatever + echo "No actions specified" +} + + +worker_configure_home () +{ + echo "No actions specified" +} + diff --git a/src/profiles/profile-dieter b/src/profiles/profile-dieter new file mode 100644 index 0000000..c4dd75c --- /dev/null +++ b/src/profiles/profile-dieter @@ -0,0 +1,22 @@ +#!/bin/bash +var_RUNTIME_PACKAGES="svn" + +phase_package_list () +{ + # install svn. export list + true +} + + +phase_configure_home () +{ + #checkout from svn + true +} + + +phase_install_bootloader () +{ + install-grub /dev/sda +} + |