Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (433f786dfe715b1cdba475e905de7fa963ee5f45)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Justin Boffemmyer <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (433f786dfe715b1cdba475e905de7fa963ee5f45)
  • Date: Sat, 27 Mar 2010 12:26:24 -0500

GIT changes to master cauldron by Justin Boffemmyer <flux AT sourcemage.org>:

cauldron/cauldron | 2
cauldron/errorcodes | 2
cauldron/lib.chroot | 4
cauldron/libcauldron | 24 +-
delint/cauldron_sources | 47 +++++
delint/enchantment_sources | 50 +++++
delint/global_variables | 91 ++++++----
delint/libdelint | 88 +++++++++
delint/test-configvars | 102 +++++++++++
delint/test-errorcodes | 100 +++++++++++
enchantment/errorcodes | 18 +
enchantment/etc/config | 72 ++++++-
enchantment/lib.chroot | 109 ++++++++++++
enchantment/lib.i18n | 202 ++++++++++++++++++++++
enchantment/lib.install | 161 +++++++++++++++++
enchantment/lib.potion | 12 -
enchantment/libenchantment | 87 ++-------
enchantment/menu/libmenu | 2
enchantment/shell/bashrc | 164 +-----------------
enchantment/shell/bin/enchantment | 270 +++++++++++++++++++++++++++++
enchantment/shell/functions | 343
++++++++++++++++++++++++++++++++++++++
enchantment/shell/keymap | 137 ---------------
enchantment/shell/smgl-chroot | 17 -
lib/libcolor | 108 ++++++++---
lib/liberror | 29 ++-
25 files changed, 1765 insertions(+), 476 deletions(-)

New commits:
commit 433f786dfe715b1cdba475e905de7fa963ee5f45
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

delint: configvars and errorcodes test scripts

Implemented 2 new test scripts that are variations on the
global_variablels delinter. Each one sources cauldron_sources and
enchantment_sources to get a list of files to check, and then checks
each one against the etc/config files (test-configvars) or the
errorcodes files (test-errorcodes).

commit 1e0ecdaa97e7c4d87282aab2e61a4602d94000ea
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment/lib.install: don't hardcode paths

Added two new config variables for handling where selected spell sources
and caches are stored.

commit 4c087bb2ba020e18de30ba08e8733ee6fa38e68d
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: reimplement shell installer

Pushed functionality out of bashrc and into a separate and unified
installer command. All shell installer commands are now to be
implemented in this one script (enchantment), with core functionality
defined in the functions file (loaded by the enchantment command
script). I believe everything is implemented, but not all of it has been
tested. The potion functionality, however, is not yet implemented.

commit eb679e798d082277ad99b22c3c9f32091af7d0ba
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: new lib.chroot

Implemented lib.chroot for chrooting to $ENCHANT_TARGET. It is very
similar to cauldron/lib.chroot, but with differences specific to
enchantment. This supercedes smgl-chroot (the user-level functionality
of which will be implemented as a new command, making use of
lib.chroot).

commit 9559628c03fb0cd1c1910a8089e828a69f607a34
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: new lib.i18n

Implemented the i18n sub-library. Currently it only handles
selecting/setting the keymap, but in the future it will also handle
which language the installer is currently running in, loading or
configuring input engines (if necessary), and anything else which may
need to be done in order to make the installer fully i18n capable.

commit 278a51fcf92673448292ebb4b8a77c3b270c2e19
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: fix/clean up enchant_install_kernel

Corrected the assignment of the kernel version to use a 3rd parameter,
changed the parameter variables to use the updated config variable
names for their default values, and updated the code/comments
accordingly.

commit 691e7ac297cd5ddce6f00fdc0a136f7f32406892
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: config vars for target sources/caches

Add config variables for where to install spell sources and caches into
the target. The variables were already in use in lib.install, but their
definitions were missing from etc/config.

commit e3acf15e4bf8407e544f47a6dc58bffc072a85fc
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

cauldron/errorcodes: add ERR_MKISOFS

Add an error code/message for failure to actually create the ISO
filesystem of the final product (i.e., mkisofs failed).

commit fb99d54c1025085ce0183c6fe47a9dc7a5cca385
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

libcolor: add warn color/function

In addtion to "notice" and "error", there is now a "warn" color and
corresponding output function.

commit 187358da4e0dd847070eef1bbd7a712aa8d3047f
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

libcolor: more accessible color definitions

Changed the color definitions to actual escape sequences rather than
shell expandable escape sequences so that they work the same for
non-shell programs (like sed).

commit 2bfd6db8bef15aaf17e71a1843fcbaad26a2270b
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

quote variables in test constructs

Quite a few variables that were used in test constructs were unquoted,
which could cause errors later. They should now all be properly quoted.

commit f93974d116f97b55090e592c9e842a1a14330daf
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

delint: push library loading out to libdelint

Since all delint scripts will be using liberror and libcolor, load them
in libdelint to reduce wasted code.

commit bb05cc247a98ef1cabcb27ac51d153e65c10c8ef
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

update usage of libcolor functions in sources

Update all the uses of libcolor in cauldron and enchantment for the
recent changes in libcolor. Most importantly, make libcolor a
non-optional load, determining the optionality of colored output using
LIBCOLOR_NOCOLOR instead, and change uses of libcolor_message to
libcolor_notice. Also did a little bit of minor cleanup.

commit 503d1a57720ee6290ce67e9074e0d644078bee0a
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

libcolor: rename message to notice

The use of "message" was misleading. Anything output by libcolor is a
type of message, and what was called "message" wasn't really a default.
Rather, it was a highlighted message, which is really a notice. The new
name is hopefully less misleading.

commit 293b11a8156f6927a60bd45d42d82977572e5e53
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

libcolor: multiple arguments and nocolor defaults

When the color output functions are passed more than one argument, they
now output the entirety of their arguments ($*) in the given output
colors. For message and error, if LIBCOLOR_NOCOLOR is 'yes' they output
in plain bold, rather than completely plain.

commit c81c7c930a391079cae764fa555808888e842abc
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

delint: allow disabling color output

If the user passes in the '-n' flag, set LIBCOLOR_NOCOLOR to disable
colored output.

commit b6f75bdb30bc5d8ed1426006d9a719041d183664
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

libcolor: allow disabling color output

Add a mechanism within libcolor for disabling color output, rather than
disabling color output by not loading libcolor. This enables tighter
control of whether output is colored, since a script can source libcolor
and switch back and forth between colored and non-colored messages,
rather than either always outputting color or never outputting it.

commit cbc1da35a5f09857891519195b2367be9d51573a
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

delint: extract functions to common library

Since multiple test commands will be running the same tests, it makes
sense to have a delinting library that they can all include rather than
having to retype the same code. Also set the output messages up to use
libcolor definitions (if available) for colored output.

commit 42c643b8f9fbc9e905dd312125437bb6d7bac8c9
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

delint: delint namespace for uniform (API) naming

Name functions and variables using a delint_ namespace. This unifies the
naming of objects in the delint sources (currently only one committed,
but more coming soon), and hopefully will help to prevent errors in the
error-checkers.

commit c17eab1f641e8427786d1a228abc4d6b28950318
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

delint: better fault checking

Check to make sure that we have a good definition file before attempting
to match against it. If a check file doesn't exist though, just skip it
without emitting an error. We're only interested in catching undefined
variables, and there won't be any undefined variables to check for in a
file that isn't there.

commit 3164eaf8bc833a45cd05362ba6eb250dacb4532a
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

delint: add source file header and footer

Add the header which gives summary information and copyright notice, and
the footer which provides license information.

commit 7292810fe8cf36e893de8e820481f6265e6607d2
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: remove trailing '/' in config

Removed an unnecessary (and possibly misleading) trailing '/' in the
config variable ENCHANT_BASE.

commit 85c7ba8a834ddd90b04c8130a358016a7f1080eb
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: new lib.install

New lib file for handling all install functionality. This includes
installing spell sources, caches, and the kernel image/modules to the
target. This implementation also requires additional variables, which
are all run-time configurable by the user.

commit 87bbc43e143a23a50bfbc09ed7993c207cad0e7e
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: rename color enabled function

Rename the color checking function to enchant_color_enabled to make its
name more straightforward for what it does. Now it should be more clear
that the function does not actually perform coloring, but rather only
checks to determine if color should be enabled/loaded.

Depending on how error checking is handled later, the functionality to
actually do the loading of lib.color might get incorporated into this
function if color should be enabled. For now it's handled in calling
functions/scripts, since the caller determines the severity of failing
to load lib.color when color is not expressly prohibited.

commit a6b886683da38582bd2bb112672c88758ff07b9b
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: prepare config for multi-arch install

Prepare variables in the config file for doing multi-arch installs (one
ISO which provides caches for multiple architectures). The variables are
currently not used by anything in libcauldron yet, as the functions to
control the cache installation have yet to be implemented.

commit c9d444b996ff94559e1f499954cf0b4df052ee53
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: improve history variable definitions

Include a new history variable that determines the path of all the
history files (forward and back), and change the name of ENCHANT_HISTORY
to ENCHANT_HISTORY_SIZE because it's a more fitting and straightforward
name for what it does.

commit d2782d4b50b97965351edb99ee1024b1842ba80e
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: paths relative to ENCHANT_ISO_PATH

All base paths should be relative to ENCHANT_ISO_PATH at a minimum. Any
form of hardcoded path is bad, as this would prevent enchantment from
functioning properly if run relative to a test directory without
chrooting, for example.

diff --git a/cauldron/cauldron b/cauldron/cauldron
index 71ac19e..aeed2ae 100755
--- a/cauldron/cauldron
+++ b/cauldron/cauldron
@@ -139,7 +139,7 @@ function cauldron_menu_build() {
}

function cauldron_main() {
- if [[ -z $1 ]]
+ if [[ -z "$1" ]]
then
cauldron_menu_main
else
diff --git a/cauldron/errorcodes b/cauldron/errorcodes
index f7a2d27..0003c8e 100644
--- a/cauldron/errorcodes
+++ b/cauldron/errorcodes
@@ -59,6 +59,7 @@ ERR_SORCERY_INSTALL=36 # could not install sorcery into
the build dir
ERR_TOOLCHAIN_STAGE1=37 # cross-toolchain failed at stage 1
ERR_TOOLCHAIN_STAGE2=38 # cross-toolchain failed at stage 2
ERR_TOOLCHAIN_STAGE3=39 # cross-toolchain failed at stage 3
+ERR_MKISOFS=40 # could not create final ISO filesystem

# error messages
ERR_MSGS=(
@@ -102,6 +103,7 @@ ERR_MSGS=(
"cross-toolchain failed at stage 1" # ERR_TOOLCHAIN_STAGE1
"cross-toolchain failed at stage 2" # ERR_TOOLCHAIN_STAGE2
"cross-toolchain failed at stage 3" # ERR_TOOLCHAIN_STAGE3
+ "could not create final ISO filesystem" # ERR_MKISOFS
)


#-------------------------------------------------------------------------------
diff --git a/cauldron/lib.chroot b/cauldron/lib.chroot
index 443ec47..6f0db9e 100644
--- a/cauldron/lib.chroot
+++ b/cauldron/lib.chroot
@@ -29,7 +29,7 @@ function cauldron_chroot_init() {
local target="${1:-$CAULDRON_BUILD}"

# if target is somehow null, return an error
- if [[ -z $target ]]
+ if [[ -z "$target" ]]
then
return $ERR_CHROOT_UNDEF
fi
@@ -70,7 +70,7 @@ function cauldron_chroot_done() {
local target="${1:-$CAULDRON_BUILD}"

# if target is somehow null, return an error
- if [[ -z $target ]]
+ if [[ -z "$target" ]]
then
return $ERR_CHROOT_UNDEF
fi
diff --git a/cauldron/libcauldron b/cauldron/libcauldron
index b33f312..9ea27f7 100755
--- a/cauldron/libcauldron
+++ b/cauldron/libcauldron
@@ -35,11 +35,17 @@ function cauldron_fatal_error() {
##

#-------------------------------------------------------------------------------
. "$CAULDRON_BASE/liberror" 2>$CAULDRON_NULL ||
- cauldron_fatal_error "error: cannot load base libraries!"
+ cauldron_fatal_error "error: cannot load base library liberror"

# load cauldron error code and message defines
. "$CAULDRON_LIBS/errorcodes" 2>$CAULDRON_NULL ||
- cauldron_fatal_error "error: cannot load cauldron libraries!"
+ cauldron_fatal_error "error: cannot load cauldron error codes"
+
+. "$CAULDRON_BASE/libcolor" 2>$CAULDRON_NULL ||
+ cauldron_fatal_error "error: cannot load base library libcolor"
+
+# test/set whether color output should be enabled
+[[ $CAULDRON_COLOR != "yes" ]] && LIBCOLOR_NOCOLOR="yes"

# drop cauldron_fatal_error if liberror was successfully loaded
unset cauldron_fatal_error
@@ -71,12 +77,6 @@ cauldron_load_library "lib.init"

#cauldron_load_library "lib.hostcache"

-if [[ $CAULDRON_COLOR == "yes" ]]
-then
- . "$CAULDRON_BASE/libcolor"
- liberror_check_fatal_error
-fi
-

#-------------------------------------------------------------------------------
##
## Scans the sorcery archspec files to find the host triplet
@@ -103,7 +103,7 @@ function cauldron_get_host_triple() {
arch_spec="$(find -L $spec $search -print 2>$CAULDRON_NULL)"
fi

- [[ -n $arch_spec ]] && break
+ [[ -n "$arch_spec" ]] && break
done

host_triple="$(grep 'HOST=' $arch_spec | cut -d = -f 2)"
@@ -131,7 +131,7 @@ function cauldron_base_toolchain() {
# get the value for HOST_TRIPLE
host_triple="$(cauldron_get_host_triple)"

- [[ -z $host_triple ]] && return $ERR_HOST_TRIPLE
+ [[ -z "$host_triple" ]] && return $ERR_HOST_TRIPLE

# grab the list of spells needed as the base tool-chain which will be
# used to create the cross-compile tool-chain
@@ -142,7 +142,7 @@ function cauldron_base_toolchain() {
version="$(grep ^$spell $CAULDRON_HSORCERY_PACKAGES | cut -d: -f4)"

# check if spell found on the system
- if [[ -n $version ]]
+ if [[ -n "$version" ]]
then
# set SPELL_CACHE as shorthand for SPELL-VERSION-HOST_TRIPLE.tar.bz2
spell_cache="${spell}-${version}-${host_triple}.tar${ext}"
@@ -228,7 +228,7 @@ function cauldron_build_target_system() {
# tarball, for each spell we only need to make sure that the cache file is
# available. This will require that the ISO sorcery has caching enabled.
The
# caching should really be turned on from the very beginning though...
- if [[ -z $ARCHIVE ]]
+ if [[ -z "$ARCHIVE" ]]
then
cauldron_source_sorcery || return $ERR_TARGET_SORCERY
fi
diff --git a/delint/cauldron_sources b/delint/cauldron_sources
new file mode 100644
index 0000000..feae9ae
--- /dev/null
+++ b/delint/cauldron_sources
@@ -0,0 +1,47 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of error codes, and ensures that they are defined in the
+## relevant errorcodes files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+cauldron_srcs=(
+ "$cauldron/cauldron"
+ "$cauldron/libcauldron"
+ "$cauldron/lib.chroot"
+ "$cauldron/lib.hostcache"
+ "$cauldron/lib.init"
+ "$cauldron/lib.sorcerous"
+ )
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/enchantment_sources b/delint/enchantment_sources
new file mode 100644
index 0000000..e24fc73
--- /dev/null
+++ b/delint/enchantment_sources
@@ -0,0 +1,50 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of error codes, and ensures that they are defined in the
+## relevant errorcodes files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+enchantment_srcs=(
+ "$enchantment/libenchantment"
+ "$enchantment/lib.chroot"
+ "$enchantment/lib.i18n"
+ "$enchantment/lib.install"
+ "$enchantment/lib.potion"
+ "$enchantment/shell/bashrc"
+ "$enchantment/shell/functions"
+ "$enchantment/shell/bin/enchantment"
+ "$enchantment/modules/*/{enter,exit,potion}/*"
+ )
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/global_variables b/delint/global_variables
index 540e915..dbd10a7 100755
--- a/delint/global_variables
+++ b/delint/global_variables
@@ -1,56 +1,83 @@
#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Global variable delinter - tests all global variables (as defined in the
+## API specification) for whether they are defined in a given definitions
file.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------

-myself="$(dirname $0)"
+DELINT_PATH="$(dirname $0)"

-# load liberror (this is not optional)
-if ! . "${CAULDRON_LIBS:-$myself/../lib}/liberror"
+if ! . "$DELINT_PATH/libdelint"
then
- echo "error: could not load ${CAULDRON_LIBS:-$myself/../lib}/liberror"
+ echo "error: could not load $DELINT_PATH/libdelint"
exit 1
fi

-# load libcolor (there should be an option for this later)
-if ! . "${CAULDRON_LIBS:-$myself/../lib}/libcolor"
-then
- echo "error: could not load ${CAULDRON_LIBS:-$myself/../lib}/libcolor"
- exit 1
-fi
-
-function print_usage() {
+function delint_print_usage() {
cat << EndUsage
-Usage: $(basename $0) definition_file file_to_check1 [file_to_check2 ...]
+Usage: $(basename $0) [-n] DEFINITION_FILE FILE_TO_CHECK1 [FILE_TO_CHECK2
...]

Checks whether global variables in FILE_TO_CHECK1 [FILE_TO_CHECK2 ...] were
defined in DEFINITION_FILE. For any global variables not so defined, they are
-printed on stdout along with the file in which they were used.
+printed on stdout along with the file in which they were used. If passed -n,
+color output is disabled.
EndUsage
}

-function usage() {
- print_usage
+function delint_usage() {
+ delint_print_usage
exit $ERR_FATAL
}

-defines="$1"
-shift
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -gt 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ delint_usage
+ fi
+fi

-if [[ $# -eq 0 ]]
+# we need a minimum of 2 arguments at this point:
+# the defines file + at least one file to check
+if [[ $# -lt 2 ]]
then
- echo "$(print_usage)"
+ echo "$(delint_print_usage)"
liberror_die $ERR_FATAL
fi

-while [[ $# -gt 0 ]]
-do
- file="$1"
- shift
+delint_global_variables "$@"

- # as per the API specification, all global variables are required to be
- # uppercase, and must begin with a letter, containing only letters,
- # underscores, and trailing numbers
- for search in $(grep -o '${\?[A-Z][A-Z_]*[0-9]*' "$file" | sort -u | sed
's/^\${\?//')
- do
- grep -q "$search=" "$defines" || echo "$file: $search"
- done
-done
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------

+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/libdelint b/delint/libdelint
new file mode 100644
index 0000000..16ef376
--- /dev/null
+++ b/delint/libdelint
@@ -0,0 +1,88 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Function and variable definitions for the delinters.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+# ensure that DELINT_PATH has a value
+[[ -z "$DELINT_PATH" ]] && DELINT_PATH="$(dirname $0)"
+
+# load liberror (this is not optional)
+if ! . "$DELINT_PATH/../lib/liberror"
+then
+ echo "error: could not load $DELINT_PATH/../lib/liberror"
+ exit 1
+fi
+
+# load libcolor (there should be an option for this later)
+if ! . "$DELINT_PATH/../lib/libcolor"
+then
+ echo "error: could not load $DELINT_PATH/../lib/libcolor"
+ exit 1
+fi
+
+function delint_global_variables() {
+ local defines=""
+ local file=""
+
+ # get the defines file, then drop it from the argument list
+ defines="$1"
+ shift
+
+ # make sure the defines file exists, otherwise we can't check anything
+ if [[ ! -f "$defines" ]]
+ then
+ echo "error: definition file not found"
+ liberror_die $ERR_FATAL
+ fi
+
+ while [[ $# -gt 0 ]]
+ do
+ file="$1"
+ shift
+
+ [[ -f "$file" ]] || continue
+
+ # as per the API specification, all global variables are required to be
+ # uppercase, and must begin with a letter, containing only letters,
+ # underscores, and trailing numbers
+ for search in $(grep -o '${\?[A-Z][A-Z_]*[0-9]*' "$file" | sort -u | sed
's/^\${\?//')
+ do
+ if ! grep -q "$search=" "$defines"
+ then
+ echo "$(libcolor_file $file): $(libcolor_notice $search)"
+ fi
+ done
+ done
+}
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/test-configvars b/delint/test-configvars
new file mode 100755
index 0000000..dfd5927
--- /dev/null
+++ b/delint/test-configvars
@@ -0,0 +1,102 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of global configurable variables (those listed in the
+## etc/config files), and ensures that they are defined in the relevant
+## config files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+
+DELINT_PATH="$(dirname $0)"
+
+cauldron="$DELINT_PATH/../cauldron"
+c_conf="$cauldron/etc/config"
+
+enchantment="$DELINT_PATH/../enchantment"
+e_conf="$enchantment/etc/config"
+
+if ! . "$DELINT_PATH/libdelint"
+then
+ echo "error: could not load $DELINT_PATH/libdelint"
+ exit 1
+fi
+
+# source the list of cauldron source files to examine
+if ! . "$DELINT_PATH/cauldron_sources"
+then
+ echo "error: could not load cauldron_sources"
+ exit $ERR_FATAL
+fi
+# source the list of enchantment source files to examine
+if ! . "$DELINT_PATH/enchantment_sources"
+then
+ echo "error: could not load enchantment_sources"
+ exit $ERR_FATAL
+fi
+
+function delint_print_usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-n]
+
+Calls the global_variables delinter to check whether there are error codes
used
+in the known cauldron and enchantment source files that aren't defined in the
+respective errorcodes files. If passed -n, color output is disabled.
+EndUsage
+}
+
+function delint_usage() {
+ delint_print_usage
+ exit $ERR_FATAL
+}
+
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -eq 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ delint_usage
+ fi
+fi
+
+# check cauldron files
+delint_global_variables "$c_conf" "${cauldron_srcs[@]}" | \
+ grep -v '[^A-Z_]ERR_[A-Z_]*'
+
+# check enchantment files
+delint_global_variables "$e_conf" "${enchantment_srcs[@]}" | \
+ grep -v '[^A-Z_]ERR_[A-Z_]*'
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/delint/test-errorcodes b/delint/test-errorcodes
new file mode 100755
index 0000000..3849906
--- /dev/null
+++ b/delint/test-errorcodes
@@ -0,0 +1,100 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This goes through all the known sources for both cauldron and
enchantment,
+## scans their uses of error codes, and ensures that they are defined in the
+## relevant errorcodes files.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+DELINT_PATH="$(dirname $0)"
+
+cauldron="$DELINT_PATH/../cauldron"
+c_codes="$cauldron/errorcodes"
+
+enchantment="$DELINT_PATH/../enchantment"
+e_codes="$enchantment/errorcodes"
+
+if ! . "$DELINT_PATH/libdelint"
+then
+ echo "error: could not load $DELINT_PATH/libdelint"
+ exit 1
+fi
+
+# source the list of cauldron source files to examine
+if ! . "$DELINT_PATH/cauldron_sources"
+then
+ echo "error: could not load cauldron_sources"
+ exit $ERR_FATAL
+fi
+# source the list of enchantment source files to examine
+if ! . "$DELINT_PATH/enchantment_sources"
+then
+ echo "error: could not load enchantment_sources"
+ exit $ERR_FATAL
+fi
+
+function delint_print_usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-n]
+
+Calls the global_variables delinter to check whether there are error codes
used
+in the known cauldron and enchantment source files that aren't defined in the
+respective errorcodes files. If passed -n, color output is disabled.
+EndUsage
+}
+
+function delint_usage() {
+ delint_print_usage
+ exit $ERR_FATAL
+}
+
+# check if color should be disabled
+if [[ "$1" == "-n" ]]
+then
+ if [[ "$#" -eq 1 ]]
+ then
+ LIBCOLOR_NOCOLOR="yes"
+ shift
+ else
+ delint_usage
+ fi
+fi
+
+# check cauldron files
+delint_global_variables "$c_codes" "${cauldron_srcs[@]}" | \
+ grep '[^A-Z_]ERR_[A-Z_]*'
+
+# check enchantment files
+delint_global_variables "$e_codes" "${enchantment_srcs[@]}" | \
+ grep '[^A-Z_]ERR_[A-Z_]*'
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/enchantment/errorcodes b/enchantment/errorcodes
index 6779284..c1c2798 100644
--- a/enchantment/errorcodes
+++ b/enchantment/errorcodes
@@ -44,6 +44,15 @@ ERR_MODULE_SCRIPT=21 # could not process module script
ERR_MODULE_ENTER=22 # could not process module entry
ERR_MODULE_EXIT=23 # could not process module exit

+# lib.i18n keymap
+ERR_KEYMAP_EXIT=50
+ERR_KEYMAP_PREFIX=51
+ERR_KEYMAP_LIST=52
+ERR_KEYMAP_LIST_SIZE=53
+ERR_KEYMAP_INPUT=54
+ERR_KEYMAP_LOAD=55
+ERR_KEYMAP_SAVE=56
+
# error messages
ERR_MSGS=(
"operation succeeded" # ERR_OK
@@ -69,6 +78,15 @@ ERR_MSGS=(
"could not process module script" #
ERR_MODULE_SCRIPT
"could not process module entry" #
ERR_MODULE_ENTER
"could not process module exit" # ERR_MODULE_EXIT
+
+ # lib.i18n keymap
+ "keymap processing finished" # ERR_KEYMAP_EXIT
+ "invalid keymap prefix" #
ERR_KEYMAP_PREFIX
+ "keymap list empty or not provided" # ERR_KEYMAP_LIST
+ "invalid list size provided" #
ERR_KEYMAP_LIST_SIZE
+ "invalid user input" #
ERR_KEYMAP_INPUT
+ "could not load selected keymap" # ERR_KEYMAP_LOAD
+ "could not save selected keymap" # ERR_KEYMAP_SAVE
)


#-------------------------------------------------------------------------------
diff --git a/enchantment/etc/config b/enchantment/etc/config
index 752e11c..4e44f8f 100644
--- a/enchantment/etc/config
+++ b/enchantment/etc/config
@@ -5,7 +5,7 @@
ENCHANT_ISO_PATH="${ENCHANT_ISO_PATH:-}"

# path to the enchant library modules
- ENCHANT_BASE="${ENCHANT_BASE:-$ENCHANT_ISO_PATH/var/lib/cauldron/}"
+ ENCHANT_BASE="${ENCHANT_BASE:-$ENCHANT_ISO_PATH/var/lib/cauldron}"
ENCHANT_LIBS="${ENCHANT_LIBS:-$ENCHANT_BASE/enchantment}"

# where the installer files are located
@@ -24,36 +24,74 @@
# where the target system is mounted
ENCHANT_TARGET="${ENCHANT_TARGET:-$ENCHANT_ISO_PATH/mnt/root}"

+ # absolute path to the file which the kernel should be installed as
+
ENCHANT_TARGET_KERNEL="${ENCHANT_TARGET_KERNEL:-$ENCHANT_TARGET/boot/vmlinuz}"
+ # path where kernel modules should be installed
+ ENCHANT_TARGET_KMODS="${ENCHANT_TARGET_KMODS:-$ENCHANT_TARGET/lib/modules}"
+
+# path where spell sources will be installed
+ENCHANT_TARGET_SOURCES="${ENCHANT_TARGET_SOURCES:-$ENCHANT_TARGET/var/spool/sorcery}"
+ # path where spell caches will be installed
+
ENCHANT_TARGET_CACHES="${ENCHANT_TARGET_CACHES:-$ENCHANT_TARGET/var/cache/sorcery}"
+
+ # command to chroot to ENCHANT_TARGET
+ ENCHANT_CHROOT="${ENCHANT_CHROOT:-$ENCHANT_ISO_PATH/bin/chroot}"
+
+ # path to installable spell sources
+
ENCHANT_SPELL_SOURCES="${ENCHANT_SPELL_SOURCES:-$ENCHANT_ISO_PATH/var/spool/sorcery}"
+ # path to installable spell caches (pre-built binaries)
+
ENCHANT_SPELL_CACHES="${ENCHANT_SPELL_CACHES:-$ENCHANT_ISO_PATH/var/cache/sorcery}"
+ # file to hold sources selected for install
+ ENCHANT_SOURCES_LIST="${ENCHANT_SOURCES_LIST:-$ENCHANT_TMP/spell-sources}"
+ # file to hold caches selected for install
+ ENCHANT_CACHES_LIST="${ENCHANT_CACHES_LIST:-$ENCHANT_TMP/spell-caches}"
+
# install module (step) info
ENCHANT_STATUS="${ENCHANT_STATUS:-$ENCHANT_TMP/current_module}"
- # install module history
- ENCHANT_BACK="${ENCHANT_BACK:-$ENCHANT_TMP/history/back}"
- ENCHANT_FORWARD="${ENCHANT_FORWARD:-$ENCHANT_TMP/history/forward}"

- # size of history buffers, total size = $ENCHANT_HISTORY * 2 = (back
+ forward)
- ENCHANT_HISTORY=${ENCHANT_HISTORY:-20}
+ # user-selected keymap
+ ENCHANT_KEYMAP="${ENCHANT_KEYMAP:-$ENCHANT_TMP/i18n-keymap}"
+
+ # install module history settings
+ ENCHANT_HISTORY="${ENCHANT_HISTORY:-$ENCHANT_TMP/history}"
+ ENCHANT_BACK="${ENCHANT_BACK:-$ENCHANT_HISTORY/back}"
+ ENCHANT_FORWARD="${ENCHANT_FORWARD:-$ENCHANT_HISTORY/forward}"
+ # size of history buffers, total size = $ENCHANT_HISTORY * 2 = (back +
forward)
+ ENCHANT_HISTORY_SIZE="${ENCHANT_HISTORY_SIZE:-20}"

# path where potion state data is stored
- ENCHANT_HASHFUNC="${ENCHANT_HASHFUNC:-/bin/sha1sum}"
+ ENCHANT_HASHFUNC="${ENCHANT_HASHFUNC:-$ENCHANT_ISO_PATH/bin/sha1sum}"

# path where potion state data is stored
- ENCHANT_ARCHIVE="${ENCHANT_ARCHIVE:-/bin/tar}"
+ ENCHANT_ARCHIVE="${ENCHANT_ARCHIVE:-$ENCHANT_ISO_PATH/bin/tar}"
# path where potion state data is stored
- ENCHANT_COMPRESS="${ENCHANT_COMPRESS:-/bin/gzip}"
+ ENCHANT_COMPRESS="${ENCHANT_COMPRESS:-$ENCHANT_ISO_PATH/bin/gzip}"

# whether to use color for displaying messages
ENCHANT_COLOR="${ENCHANT_COLOR:-yes}"

+ # kernel version to use for installs
+ ENCHANT_ISO_KVERS="${ENCHANT_ISO_KVERS:-}"
+ # kernel image to use for installs
+
ENCHANT_ISO_KERNEL="${ENCHANT_ISO_KERNEL:-$ENCHANT_ISO_PATH/boot/vmlinux}"
+ # path to the kernel modules to use for the install
+ ENCHANT_ISO_KMODS="${ENCHANT_ISO_KMODS:-$ENCHANT_ISO_PATH/lib/modules}"

-ENCHANT_SORCERY_CONFIG="${ENCHANT_SORCERY_CONFIG:-/etc/sorcery/config}"
- ENCHANT_SORCERY_LIBS="${ENCHANT_SORCERY_LIBS:-/var/lib/sorcery/modules}"
# branch of sorcery to use in the ISO
ENCHANT_SORCERY_BRANCH="${ENCHANT_SORCERY_BRANCH:-stable}"

- HOST_ARCH_PATH=$(grep "ARCH_SPEC=" ${SORCERY_CONFIG} | \
- cut -d = -f 2)
- HOST_ARCH=$(grep "ARCHITECTURE=" ${HOST_SORCERY_CONFIG} | \
- cut -d = -f 2)
- CACHE_EXTENSION=$(grep "EXTENSION=" ${HOST_SORCERY_CONFIG} | \
- cut -d = -f 2)
+# ISO sorcery config paths
+ENCHANT_SORCERY_CONFIG="${ENCHANT_SORCERY_CONFIG:-$ENCHANT_ISO_PATH/etc/sorcery/config}"
+
ENCHANT_SORCERY_LIBS="${ENCHANT_SORCERY_LIBS:-$ENCHANT_ISO_PATH/var/lib/sorcery/modules}"
+
+# ISO architecture/machine/host information (used to select caches when more
+# than one architecture is available for caches)
+ENCHANT_HOST_ARCH_PATH="${ENCHANT_HOST_ARCH_PATH:-$ENCHANT_ISO_PATH/usr/share/archspecs}"
+ # list of archs available for install on this ISO, if undefined
set to
+ # the first entry in the archs file written by cauldron at
generation
+ ENCHANT_ARCH="${ENCHANT_ARCH:-$(head -n1 $ENCHANT_DATA/archs)}"
+ ENCHANT_MACHTYPE="${ENCHANT_HOST_ARCH:-$MACHTYPE}"
+ ENCHANT_CACHE_EXT="${ENCHANT_CACHE_EXT:-tar.bz2}"
+

+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/enchantment/lib.chroot b/enchantment/lib.chroot
new file mode 100644
index 0000000..e0c90d9
--- /dev/null
+++ b/enchantment/lib.chroot
@@ -0,0 +1,109 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Chroot construction and destruction functions for use in the installers.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+## @param target dir to chroot into
+##
+## Prepares a chroot environment and exports necessary variables. For every
+## target dir to chroot into, there should be one
+## [cauldron_chroot_init ... cauldron_chroot_done] pair.
+##
+#-------------------------------------------------------------------------------
+function enchant_chroot_init() {
+ if [[ "$ENCHANT_CHROOT_INIT" -ne 1 ]]
+ then
+ # if target is somehow null, return an error
+ [[ -z "$ENCHANT_TARGET" ]] && return $ERR_CHROOT_UNDEF
+
+ # bind the needed mounts
+ mount --bind "$ENCHANT_ISO_PATH/dev" "$ENCHANT_TARGET/dev" ||
+ return $ERR_CHROOT_INIT
+ mount --bind "$ENCHANT_ISO_PATH/dev/pts" "$ENCHANT_TARGET/dev/pts" ||
+ return $ERR_CHROOT_INIT
+ mount --bind "$ENCHANT_ISO_PATH/proc" "$ENCHANT_TARGET/proc" ||
+ return $ERR_CHROOT_INIT
+
+ # export that the chroot is successfully constructed
+ export ENCHANT_CHROOT_INIT=1
+ fi
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## Cleans up the chroot environment after it is no longer needed
+##
+#-------------------------------------------------------------------------------
+function enchant_chroot_done() {
+ if [[ "$ENCHANT_CHROOT_INIT" -eq 1 ]]
+ then
+ # if target is somehow null, return an error
+ [[ -z "$ENCHANT_TARGET" ]] && return $ERR_CHROOT_UNDEF
+
+ # unmount the bind mounts
+ umount "$ENCHANT_TARGET/proc" || return $ERR_CHROOT_DONE
+ umount "$ENCHANT_TARGET/dev/pts" || return $ERR_CHROOT_DONE
+ umount "$ENCHANT_TARGET/dev" || return $ERR_CHROOT_DONE
+
+ # clear the chroot definitions
+ unset ENCHANT_CHROOTINIT
+ fi
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+## @param command plus args to execute inside the chroot
+##
+## Executes the command given as the first parameter and any args that follow
+## inside the chroot constructed by enchant_chroot_init.
+##
+#-------------------------------------------------------------------------------
+function enchant_chroot() {
+ if [[ "$ENCHANT_CHROOT_INIT" -eq 1 ]]
+ then
+ # if target is somehow null, return an error
+ [[ -z "$ENCHANT_TARGET" ]] && return $ERR_CHROOT_UNDEF
+
+ "$ENCHANT_CHROOT" "$ENCHANT_TARGET" "$@" || return $ERR_CHROOT_EXEC
+ else
+ return $ERR_CHROOT_NOT_INIT
+ fi
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/enchantment/lib.i18n b/enchantment/lib.i18n
new file mode 100644
index 0000000..24c4f34
--- /dev/null
+++ b/enchantment/lib.i18n
@@ -0,0 +1,202 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## These are the functions used for i18n, including setting keymaps, setting
+## the current language the installer is running under, etc.
+##
+## For the keymap functions, only numbers are to be used as input, since
they
+## are more likely to be consistent across different keymaps/keyboards,
whereas
+## letters and punctuation get moved around much more.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+## @param size of choices list (highest numbered entry to choose from)
+##
+## Reads input from the user, and ensures that it is either '*' or a number
in
+## the range of 0-highest_entry. Echoes the input if it is a number that fits
+## the range. If the input is '*', then ERR_KEYMAP_EXIT is returned so that
the
+## caller can do any cleanup needed and then exit.
+##
+#-------------------------------------------------------------------------------
+function enchant_i18n_keymap_get_input() {
+ local max="$1"
+ local input=""
+
+ [[ -z "$max" ]] && return $ERR_KEYMAP_LIST_SIZE
+
+ # grab the input, allowing readline editing
+ read -re input || return $ERR_KEYMAP_INPUT
+
+ if [[ -n "$input" ]]
+ then
+ # if the user entered '*', then we exit without finishing
+ if [[ "$input" == "*" ]]
+ then
+ return $ERR_KEYMAP_EXIT
+ fi
+
+ # if we got a number outside the range of what we can accept,
+ # tell the user before returning an error
+ if [[ "$input" -lt 0 || "$input" -gt "$max" ]]
+ then
+ return $ERR_KEYMAP_INPUT
+ fi
+ fi
+
+ echo "$input"
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+## @param prefix -> path to populate the list of choices from
+##
+## Creates a list of choices consisting of directory entries from the
prefix. If
+## prefix is not explicitly provided, it defaults to /usr/share/keymaps (the
base
+## of the keymap file hierarchy) relative to the ENCHANT_ISO_PATH.
+##
+#-------------------------------------------------------------------------------
+function enchant_i18n_keymap_make_list {
+ local prefix="${1:-$ENCHANT_ISO_PATH/usr/share/keymaps}"
+ local list=()
+ local result=()
+ local i=""
+
+ [[ -d "$prefix" ]] || return $ERR_DIR_NOT_FOUND
+
+ list=( $(find "$prefix"/* -maxdepth 0 -type d -not -name include) )
+
+ if [[ "${#list[*]}" -eq 0 ]]
+ then
+ list=( $(find "$prefix"/* -type f -name *.map.gz) )
+ fi
+
+ [[ "${#list[*]}" -eq 0 ]] && return $ERR_KEYMAP_LIST
+
+ for ((i=0; i < "${#list[*]}"; i++))
+ do
+ result=( "$result" "${list[i]##*/}" )
+ done
+
+ echo "${result[*]}"
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+## @param keymap to load
+##
+## Load the keymap passed as the first argument and store it into the
+## enchantment temporary directory for later use.
+##
+#-------------------------------------------------------------------------------
+function enchant_keymap_change() {
+ local keymap="$1"
+
+ [[ -f "$keymap" ]] || return $ERR_FILE_NOT_FOUND
+
+ loadkeys "$keymap" || return $ERR_KEYMAP_LOAD
+
+ # store the selected keymap for later use by enchantment (e.g., for
potions)
+ echo "${keymap%.*map.*}" > "$ENCHANT_KEYMAP" ||
+ return $ERR_KEYMAP_SAVE
+
+ # instead of returning OK, return ERR_KEYMAP_EXIT to let the caller know
that
+ # a keymap was successfully changed and this round of keymap processing
should
+ # stop
+ return $ERR_KEYMAP_EXIT
+}
+
+#-------------------------------------------------------------------------------
+## @param prefix -> current path to populate the menu from
+## @param size of choices list (highest numbered entry to choose from)
+##
+## Gets the user input and then processes it, possibly calling
+## enchant_keymap_change to actually set the keymap if that's what was input.
+##
+#-------------------------------------------------------------------------------
+function enchant_i18n_keymap_input() {
+ local prefix="${1:-$ENCHANT_ISO_PATH/usr/share/keymaps}"
+ local max="$2"
+ local input=""
+ local rc=""
+
+ [[ ! -e "$prefix" ]] && return $ERR_KEYMAP_PREFIX
+
+ [[ -z "$max" ]] && return $ERR_KEYMAP_LIST_SIZE
+
+ # get the user's menu choice
+ input="$(enchant_i18n_keymap_get_input $max)"
+ rc="$?"
+
+ # if the user entered '*', exit the keymap routines
+ [[ "$rc" -eq "$ERR_KEYMAP_EXIT" ]] && return $ERR_KEYMAP_EXIT
+
+ # if there was an error in getting the input, report it to the caller
+ [[ "$rc" -eq "$ERR_KEYMAP_INPUT" ]] && return $ERR_KEYMAP_INPUT
+
+ # if the user entered '0', go "back" (up a dir/level)
+ if [[ "$input" -eq "0" ]]
+ then
+ # only go up a level if we aren't at the beginning
+ # (don't go lower than the floor)
+ [[ "$prefix" != "$ENCHANT_ISO_PATH/usr/share/keymaps" ]] &&
+ prefix="${prefix%/[^/]*}"
+ else
+ # get the menu item, adjusting for array indexed from 0
+ (( input -= 1 ))
+ input="${choices[input]}"
+
+ # if the input corresponds to a keymap file, attempt to switch to that
+ # keymap, otherwise set the prefix to the new path and loop again
+ if [[ "$input" == *.map.gz ]]
+ then
+ prefix="$prefix/$input"
+
+ enchant_keymap_change "$prefix"
+
+ # returns whatever enchant_keymap_change returns, which is either an
error
+ # if something failed or ERR_KEYMAP_EXIT (meaning the keymap processing
+ # should end) if successful
+ return "$?"
+ else
+ prefix="$prefix/$input"
+
+ # echo (return) the new prefix back to the caller
+ echo "$prefix"
+ fi
+ fi
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/enchantment/lib.install b/enchantment/lib.install
new file mode 100644
index 0000000..16310ce
--- /dev/null
+++ b/enchantment/lib.install
@@ -0,0 +1,161 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## Common functions and variables for different installers related to
+## installing content
+##
+##=head1 DESCRIPTION
+##
+## This is all the functions needed for actually installing content (spell
+## sources, spell caches, kernels and modules, etc.) into a target system.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2009 The Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+##
+## @param source
+## @param destination
+##
+## Installs the source file to the destination.
+##
+#-------------------------------------------------------------------------------
+function enchant_install_file() {
+ local $src="$1"
+ local $dst="$2"
+
+ [[ -z "$src" ]] && return $ERR_INSTALL_FILE
+ [[ -z "$dst" ]] && return $ERR_INSTALL_FILE
+
+ cp -dfp "$src" "$dst" || return $ERR_INSTALL_FILE
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## @param source
+## @param destination
+##
+## Installs the source directory (including all subdirectories and their
+## contents) to the destination.
+##
+#-------------------------------------------------------------------------------
+function enchant_install_dir() {
+ local $src="$1"
+ local $dst="$2"
+
+ [[ -z "$src" ]] && return $ERR_INSTALL_FILE
+ [[ -z "$dst" ]] && return $ERR_INSTALL_FILE
+
+ cp --parents -dfpr "$src" "$dst" || return $ERR_INSTALL_DIR
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## @param sources_list
+##
+## Copies the selected spell sources into the target.
+##
+#-------------------------------------------------------------------------------
+function enchant_install_sources() {
+ local sources=( "${@:-$(cat $ENCHANT_SOURCES_LIST)}" )
+ local dst="$ENCHANT_TARGET_SOURCES"
+
+ for spell in $sources
+ do
+ enchant_install_file "$ENCHANT_SPELL_SOURCES/$spell" "$dst/" ||
+ return $ERR_INSTALL_SOURCES
+ done
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## @param caches_list
+##
+## Copies the selected spell caches into the target.
+##
+#-------------------------------------------------------------------------------
+function enchant_install_caches() {
+ local caches=( "${@:-$(cat $ENCHANT_CACHES_LIST)}" )
+ local dst="$ENCHANT_TARGET_CACHES"
+
+ for spell in $caches
+ do
+ enchant_install_file "$ENCHANT_SPELL_SOURCES/spell" "$dst/" ||
+ return $ERR_INSTALL_CACHES
+ done
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## @param kernel_image (absolute path - e.g. $ENCHANT_ISO_PATH/boot/vmlinux)
+## @param modules_path (absolute path - e.g. $ENCHANT_ISO_PATH/lib/modules)
+## @param kernel_version (e.g. 2.6.32.8)
+##
+## Copies the kernel and it's associated modules from the ISO to the TARGET
+## system. Requires that / and /boot on the TARGET system are mounted (unless
+## ENCHANT_TARGET_KERNEL and ENCHANT_TARGET_KMODS are modified). The second
+## parameter (modules_path) *must* include the kernel version as the last
+## directory in the path (i.e., /path/to/kernel/modules/version/).
+##
+#-------------------------------------------------------------------------------
+function enchant_install_kernel() {
+ local target="$ENCHANT_TARGET"
+ local target_kernel="$ENCHANT_TARGET_KERNEL"
+ local target_kmods="$ENCHANT_TARGET_KMODS"
+ local kernel="${1:-$ENCHANT_ISO_KERNEL}"
+ local kmods="${2:-$ENCHANT_ISO_KMODS}"
+ local kvers="${3:-$ENCHANT_ISO_KVERS}"
+
+ # copy the kernel over
+ enchant_install_file "$kernel" "$target_kernel" || return $ERR_KERNEL
+
+ # copy the modules over
+ enchant_install_dir "$kmods/$kvers" "$target_kmods/$(basename $kmods)" ||
+ return $ERR_KERNEL_MODULES
+
+ # make sure that the proper dep info is generated on the target system
+ depmod -a -b "$target_kmods/$kvers" "$kvers" ||
+ return $ERR_KERNEL_DEPMOD
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##=back
+##
+##=head1 LICENSE
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/enchantment/lib.potion b/enchantment/lib.potion
index b9d8547..4ec2fee 100644
--- a/enchantment/lib.potion
+++ b/enchantment/lib.potion
@@ -135,7 +135,7 @@ function enchant_potion_set_hashsum() {
local file="$1"
local potion="${2:-$ENCHANT_POTION_CURRENT}"

- [[ -f $file ]] || return $ERR_FILE_NOT_FOUND
+ [[ -f "$file" ]] || return $ERR_FILE_NOT_FOUND

"$hashfunc" "$file" >
"$ENCHANT_POTION/$potion/${file##*/}.${hashfunc##*/}" ||
return $ERR_SET_HASHSUM
@@ -156,7 +156,7 @@ function enchant_potion_cache_file() {
local potion="${2:-$ENCHANT_POTION_CURRENT}"
local sum=""

- [[ -f $file ]] || return $ERR_FILE_NOT_FOUND
+ [[ -f "$file" ]] || return $ERR_FILE_NOT_FOUND

sum="$($ENCHANT_HASHFUNC $file | cut -d' ' -f1)"

@@ -188,7 +188,7 @@ function enchant_potion_get_partitions() {
# each match is exact
local excl="$ENCHANT_POTION_MOUNT_EXCLUDES"

- [[ -d $ENCHANT_POTION ]] || return $ERR_POTION_DIR
+ [[ -d "$ENCHANT_POTION" ]] || return $ERR_POTION_DIR

# for every line, if the 2nd field exactly matches one of excl, skip it
# otherwise, store the filesystem (field 3) to the temp file
@@ -237,7 +237,7 @@ function enchant_potion_get_filesystems() {
# each match is exact
local excl="$ENCHANT_POTION_MOUNT_EXCLUDES"

- [[ -d $ENCHANT_POTION ]] || return $ERR_POTION_DIR
+ [[ -d "$ENCHANT_POTION" ]] || return $ERR_POTION_DIR

# for every line, if the 2nd field exactly matches one of excl, skip it
# otherwise, store the filesystem (field 3) to the temp file
@@ -286,7 +286,7 @@ function enchant_potion_get_mount_points() {
# each match is exact
local excl="$ENCHANT_POTION_MOUNT_EXCLUDES"

- [[ -d $ENCHANT_POTION ]] || return $ERR_POTION_DIR
+ [[ -d "$ENCHANT_POTION" ]] || return $ERR_POTION_DIR

# for every line, if the 2nd field exactly matches one of excl, skip it
# otherwise, store the mount point (field 2) to the temp file
@@ -524,7 +524,7 @@ function enchant_potion_quaff() {

# if the end module wasn't explicitly specified, set it to the last
possible
# (non-error) module
- if [[ -z $end ]]
+ if [[ -z "$end" ]]
then
endmod="${#list}"
fi
diff --git a/enchantment/libenchantment b/enchantment/libenchantment
index 1a0e11d..bba44c1 100755
--- a/enchantment/libenchantment
+++ b/enchantment/libenchantment
@@ -41,11 +41,18 @@ function enchant_fatal_error() {
# liberror includes

#-------------------------------------------------------------------------------
. "$ENCHANT_BASE/liberror" ||
- enchant_fatal_error "error: cannot load base libraries!"
+ enchant_fatal_error "error: cannot load base library liberror"

# load enchantment error code and message defines
. "$ENCHANT_LIBS/errorcodes" ||
- enchant_fatal_error "error: cannot load enchantment libraries!"
+ enchant_fatal_error "error: cannot load enchantment error codes"
+
+. "$ENCHANT_BASE/libcolor" ||
+ enchant_fatal_error "error: cannot load base library libcolor"
+
+# test/set whether color output should be enabled
+[[ "$ENCHANT_COLOR" != "yes" || "$(grep -q 'nocolor' /proc/cmdline)" ]] &&
+ LIBCOLOR_NOCOLOR="yes"

# drop enchant_fatal_error if liberror was successfully loaded
unset enchant_fatal_error
@@ -69,6 +76,9 @@ function enchant_load_library() {

#-------------------------------------------------------------------------------
# enchant includes

#-------------------------------------------------------------------------------
+enchant_load_library "lib.chroot"
+enchant_load_library "lib.i18n"
+enchant_load_library "lib.install"
enchant_load_library "lib.potion"


#-------------------------------------------------------------------------------
@@ -76,65 +86,6 @@ enchant_load_library "lib.potion"

#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
##
-## Determines whether we should attempt to load libcolor
-##
-#-------------------------------------------------------------------------------
-function enchant_color() {
- # if ENCHANT_COLOR was set to null
- if [[ -z $ENCHANT_COLOR ]]
- then
- # check if nocolor wasn't passed on the boot command-line
- if ! grep -q 'nocolor' /proc/cmdline
- then
- # we want color
- return 0
- fi
- else
- # if ENCHANT_COLOR specifically set to yes
- if [[ "$ENCHANT_COLOR" == "yes" ]]
- then
- # we want color
- return 0
- fi
- fi
-
- # for all other cases, we don't want color
- return 1
-}
-
-#-------------------------------------------------------------------------------
-##
-## @param kernel
-## @param linux_version
-##
-## Copies the kernel and it's associated modules from the ISO to the TARGET
-## system. Requires that / and /boot on the TARGET system are mounted. It is
-## capable of copying multiple kernels, but for now the ISO will only have 1
-## kernel.
-##
-#-------------------------------------------------------------------------------
-function enchant_copy_kernel() {
- local iso="$ENCHANT_ISO_PATH"
- local kernel="$1"
- local linux_ver="$2"
-
- # copy the kernel over
- cp "$iso/boot/$kernel" "$ENCHANT_TARGET/boot/" ||
- return $ERR_KERNEL
-
- # copy the modules over
- cp --parents -r "$iso/lib/modules/$linux_ver"/* "$ENCHANT_TARGET/" ||
- return $ERR_KERNEL_MODULES
-
- # make sure that the proper dep info is generated on the target system
- depmod -a -b "$ENCHANT_TARGET/lib/modules/$linux_ver" "$linux_ver" ||
- return $ERR_KERNEL_DEPMOD
-
- return $ERR_OK
-}
-
-#-------------------------------------------------------------------------------
-##
## Sets the installer system to a sane, known initial state. Should only be
## called when first entering the installer system or ISO.
##
@@ -193,7 +144,7 @@ function enchant_get_modules() {
##

#-------------------------------------------------------------------------------
function enchant_get_current() {
- [[ -z $ENCHANT_STATUS ]] && return $ERR_GET_CURRENT
+ [[ -z "$ENCHANT_STATUS" ]] && return $ERR_GET_CURRENT

cat "$ENCHANT_STATUS" || return $ERR_GET_CURRENT

@@ -220,7 +171,7 @@ function enchant_set_current() {
enchant_module_exit || return $ERR_MODULE_EXIT

# if the max history size has been reached, then we drop the oldest item
- if [[ "$(wc -l < $ENCHANT_BACK)" -ge "$ENCHANT_HISTORY" ]]
+ if [[ "$(wc -l < $ENCHANT_BACK)" -ge "$ENCHANT_HISTORY_SIZE" ]]
then
sed -i '1d' "$ENCHANT_BACK" || return $ERR_SET_CURRENT
fi
@@ -251,7 +202,7 @@ function enchant_get_next() {

step="$(echo $step | cut -d: -f2)" || return $ERR_GET_NEXT

- if [[ -z $step ]]
+ if [[ -z "$step" ]]
then
echo "error"
return $ERR_GET_NEXT
@@ -294,7 +245,7 @@ function enchant_get_prev() {

step="$(echo $step | cut -d: -f1)" || return $ERR_GET_PREV

- if [[ -z $step ]]
+ if [[ -z "$step" ]]
then
echo "error"
return $ERR_GET_PREV
@@ -334,7 +285,7 @@ function enchant_back() {
[[ "$(wc -l < $ENCHANT_BACK)" -eq 0 ]] && return $ERR_BACK

# if the max forward history size has been reached
- if [[ "$(wc -l < $ENCHANT_FORWARD)" -ge $ENCHANT_HISTORY ]]
+ if [[ "$(wc -l < $ENCHANT_FORWARD)" -ge "$ENCHANT_HISTORY_SIZE" ]]
then
# then we drop the oldest item from the forward history
sed -i '1d' "$ENCHANT_FORWARD" || return $ERR_BACK
@@ -366,7 +317,7 @@ function enchant_forward() {
[[ "$(wc -l < $ENCHANT_FORWARD)" -eq 0 ]] && return $ERR_FORWARD

# if the max back history size has been reached
- if [[ "$(wc -l < $ENCHANT_BACK)" -ge "$ENCHANT_HISTORY" ]]
+ if [[ "$(wc -l < $ENCHANT_BACK)" -ge "$ENCHANT_HISTORY_SIZE" ]]
then
# then we drop the oldest item from the back history
sed -i '1d' "$ENCHANT_BACK" || return $ERR_FORWARD
@@ -396,7 +347,7 @@ function enchant_forward() {
function enchant_get_num() {
local num="$(grep -n -m1 \"^$(enchant_get_current):\"
$ENCHANT_INSTALLER/modules)"

- if [[ -z $num ]]
+ if [[ -z "$num" ]]
then
return $ERR_GET_NUM
fi
diff --git a/enchantment/menu/libmenu b/enchantment/menu/libmenu
index 5fd705c..52e53a1 100644
--- a/enchantment/menu/libmenu
+++ b/enchantment/menu/libmenu
@@ -18,7 +18,7 @@ function die_cmd() {
local rc=${2:-$?}
local message

- [[ -n $1 ]] &&
+ [[ -n "$1" ]] &&
message="Error: $1 failed with exit code $rc, "

message="${message}bailing out."
diff --git a/enchantment/shell/bashrc b/enchantment/shell/bashrc
index 077705e..bca3877 100755
--- a/enchantment/shell/bashrc
+++ b/enchantment/shell/bashrc
@@ -3,13 +3,13 @@
##
##=head1 SYNOPSIS
##
-## This file is the SMGL shell installer.
+## This is the init/setup of the SMGL shell installer.
## Take care not to pollute the user's namespace too much,
## And make sure your functions don't collide with existing commands.
##
##=head1 COPYRIGHT
##
-## Copyright 2009 by the Cauldron Team
+## Copyright 2010 by the Cauldron Team
##
##=head1 FUNCTIONS
##
@@ -17,156 +17,26 @@
##

#-------------------------------------------------------------------------------

+# these variables are defined the same in etc/enchantment/config
+# if redefined in the environment, they will be overridden for
+# all enchantment scripts
+ENCHANT_ISO_PATH="${ENCHANT_ISO_PATH:-}"
+ENCHANT_DATA="${ENCHANT_DATA:-$ENCHANT_ISO_PATH/usr/share/enchantment}"

-# source configs and libenchantment
-. "/etc/cauldron/enchant.config"
-. "/etc/cauldron/local/enchant.config" 2> /dev/null
-. "${ENCHANT_DATA}/libenchantment"
+# set path to include the shell installer commands
+PATH="$ENCHANT_DATA/shell/bin:$PATH"

-# source libcolor if possible
-if enchant_color
-then
- . "${ENCHANT_BASE}/libcolor" ||
- liberror_print_error $ERR_LIBCOLOR $LIBERR_STDERR
-fi
+# initialize the installer
+enchantment init

-# let libenchantment know which installer this is
-ENCHANT_INSTALLER="shell"
-
-# Ensure installer sanity
-enchant_prepare
-
-# print a standardized header
-# if given a filename for an argument, it will print the contents of the file
-# after the header
-function shell_header() {
- echo ""
- echo ""
- echo ""
-
- # if arg1 supplied, cat it
- [[ -n $1 ]] && cat $1
-}
-
-# output the step instructions
-# use color if libcolor loaded, else just plain bold
-function shell_instructions() {
- local file=$1
- local hilight="${LIBCOLOR_MESSAGE_COLOR:-}"
- local normal="${LIBCOLOR_NORMAL_COLOR:-}"
-
- sed 's/@\[\([^]]*\)\]/'$hilight'\1'$normal'/g' "$file"
-}
-
-# display module names with short descriptions in columns
-function shell_modules() {
- local list
- local module
- local col_width=0
-
- # get the list of modules
- list=( $(enchant_get_modules) )
-
- # get the width of the widest column
- for col in ${list[*]}
- do
- [[ ${#col} -gt $col_width ]] && col_width=${#col}
- done
-
- header
- for module in ${list[*]}
- do
- # pad the output to align the columns
- while [[ ${#module} -lt $col_width ]]
- do
- module="$module "
- done
-
- # output name and info in columns
- echo "$module" | paste - "$ENCHANT_MODULES/$module/${module}.info"
- done
-}
-
-function shell_set_ps() {
- local hilight="${LIBCOLOR_MESSAGE_COLOR:-}"
- local normal="${LIBCOLOR_NORMAL_COLOR:-}"
-
- PS1=""
- PS1="$PS1 ["
- PS1="$PS1 current:\$(enchant_get_current)"
- PS1="$PS1 next:\$(enchant_get_next)"
- PS1="$PS1 \$(enchant_get_num)/\$(enchant_get_total)"
- PS1="$PS1 ]"
- PS1="$PS1 For a list of commands, type ${hilight}help${normal}\n\u \w\$ "
-}
-
-function todo() {
- local curstep="$1"
- curstep="${curstep:-$(enchant_getstep)}"
-
- # output the header
- shell_header
-
- # output the current module's instructions
- shell_instructions "$ENCHANT_MODULES/$curstep/$curstep"
-}
-
-function next() {
- enchant_set_next
- todo
-}
-
-function prev() {
- enchant_set_prev
- todo
-}
-
-function back() {
- enchant_back
-}
-
-function forward() {
- enchant_forward
-}
-
-function steps() {
- shell_modules
-}
-
-function jump() {
- local hilight="${LIBCOLOR_MESSAGE_COLOR:-}"
- local normal="${LIBCOLOR_NORMAL_COLOR:-}"
-
- if ! enchant_set_current $*
- then
- echo ""
- echo -n "'$*': error: "
- liberror_print_error $?
-
- if [[ $? = $ERR_STEP ]]
- then
- echo "Type ${hilight}steps${normal} to see a list of steps."
- fi
- fi
-}
-
-function welcome() {
- shell_header
- shell_instructions "$ENCHANT_MODULES/welcome/welcome"
-}
-
-function help() {
- helpfile="$ENCHANT_MODULES/help/${1:-index}"
- if [[ -e $helpfile ]] ;then
- shell_header
- shell_instructions $helpfile
- else
- echo "No installer help for '$1', falling back to bash's builtin help"
- builtin help $1
- fi
+# use titlecase because this will pollute the user's namespace, and we want
to
+# minimize the likelihood that it would interfere with the user's regular
+# processing
+function Shell_Set_Prompt() {
+ enchantment prompt
}

-shell_set_ps
+PS1="\$(Shell_Set_Prompt)\n\u \w\$ "


#-------------------------------------------------------------------------------
##
diff --git a/enchantment/shell/bin/enchantment
b/enchantment/shell/bin/enchantment
new file mode 100755
index 0000000..867af70
--- /dev/null
+++ b/enchantment/shell/bin/enchantment
@@ -0,0 +1,270 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## This file is the user-level interface of the SMGL shell installer. All
+## user-level commands are defined here, and either handle the input
directly
+## using libenchanment (and its sub-libraries) or route it to more
high-level
+## functions defined in the shell functions file.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+# let libenchantment know which installer this is
+ENCHANT_INSTALLER="shell"
+
+# source configs and libenchantment
+. "/etc/cauldron/enchant.config"
+. "/etc/cauldron/local/enchant.config" 2> /dev/null
+
+# load the main library (which in turn loads sub-libraries)
+if ! . "$ENCHANT_LIBS/libenchantment"
+then
+ echo "error: could not load libenchantment"
+ exit 1
+fi
+
+# add local error message(s) and error code(s)
+ERR_INSTALLER_FUNCS="$(echo $((${#ERR_MSGS[*]}+1)))"
+ERR_INSTALLER_CHROOT_MOUNT="$(echo $((${#ERR_MSGS[*]}+2)))"
+ERR_INSTALLER_CHROOT_EXEC="$(echo $((${#ERR_MSGS[*]}+3)))"
+ERR_INSTALLER_CHROOT_UMOUNT="$(echo $((${#ERR_MSGS[*]}+4)))"
+$enchant_shell_err_msgs=(
+ "could not load $ENCHANT_INSTALLER functions file"
+ "could not mount chroot subdirs"
+ "could not execute chroot command"
+ "could not unmount chroot subdirs"
+ )
+$ERR_MSGS=( "$ERR_MSGS" "${enchant_shell_err_msgs[*]}" )
+
+# source installer-specific functions
+[[ -f "$ENCHANT_DATA/$ENCHANT_INSTALLER/functions" ]] ||
+ liberror_die $ERR_INSTALLER_FUNCS
+
+
+#------------------------------------------------------------------------------
+function enchant_shell_command_keymap() {
+ [[ "$#" -eq 0 ]] || return $ERR_INSTALLER_CMD
+
+ enchant_shell_perform_keymap || return $ERR_INSTALLER_KEYMAP
+
+ return $ERR_OK
+}
+
+function enchant_shell_command_prompt() {
+ [[ "$#" -eq 0 ]] || return $ERR_INSTALLER_CMD
+
+ local current="current:$(enchant_get_current)"
+ local next="next:$(enchant_get_next)"
+ local num="$(enchant_get_num)"
+ local total="$(enchant_get_total)"
+
+ echo -n "[$current $next $num/$total] "
+ echo -n "For a list of commands, type "
+ libcolor_notice "help"
+
+ return $ERR_OK
+}
+
+function enchant_shell_command_chroot() {
+ # can take either 0 or multiple arguments,
+ # so don't check the number of arguments
+
+ enchant_shell_perform_chroot "$@"
+ liberror_check_fatal_error
+
+ return $ERR_OK
+}
+
+function_enchant_shell_command_list() {
+ [[ $# -eq 0 ]] || return $ERR_INSTALLER_CMD
+
+ enchant_shell_list_modules
+ liberror_check_fatal_error
+
+ return $ERR_OK
+}
+
+function enchant_shell_command_todo() {
+ [[ $# -le 1 ]] || return $ERR_INSTALLER_CMD
+
+ enchant_shell_perform_todo "$@"
+ liberror_check_fatal_error
+
+ return $ERR_OK
+}
+
+function enchant_shell_command_jump() {
+ [[ $# -eq 1 ]] || return $ERR_INSTALLER_CMD
+
+ enchant_shell_perform_jump "$@"
+ liberror_check_fatal_error
+
+ return $ERR_OK
+}
+
+function enchant_shell_command_help() {
+ [[ $# -le 1 ]] || return $ERR_INSTALLER_CMD
+
+ enchant_shell_perform_help "$@"
+ liberror_check_fatal_error
+
+ return $ERR_OK
+}
+
+# Initialize installer
+function enchant_shell_command_init() {
+ [[ "$#" -eq 0 ]] || return $ERR_INSTALLER_CMD
+
+ enchant_prepare
+ liberror_check_fatal_error
+
+ return $ERR_OK
+}
+
+function enchant_shell_command_install {
+ local command="$1"
+ shift
+
+ case "$command" in
+ "kernel" )
+ [[ $# -ne 3 ]] && return $ERR_INSTALLER_CMD
+ enchant_install_kernel "$@"
+ liberror_check_fatal_error
+ ;;
+ "isokernel" )
+ [[ $# -ne 0 ]] && return $ERR_INSTALLER_CMD
+ enchant_install_kernel
+ liberror_check_fatal_error
+ ;;
+ "system" )
+ [[ $# -ne 0 ]] && return $ERR_INSTALLER_CMD
+ enchant_install_system
+ liberror_check_fatal_error
+ ;;
+ "spells" )
+ [[ $# -ne 0 ]] && return $ERR_INSTALLER_CMD
+ enchant_install_spell_sources
+ liberror_check_fatal_error
+ enchant_install_spell_caches
+ liberror_check_fatal_error
+ ;;
+ "sources" )
+ # can take either 0 or multiple arguments,
+ # so don't check the number of arguments
+ enchant_install_spell_sources "$@"
+ liberror_check_fatal_error
+ ;;
+ "caches" )
+ # can take either 0 or multiple arguments,
+ # so don't check the number of arguments
+ enchant_install_spell_caches "$@"
+ liberror_check_fatal_error
+ ;;
+ * ) return $ERR_INSTALLER_CMD ;;
+ esac
+
+ return $ERR_OK
+}
+
+function enchant_shell_command_potion() {
+ # TODO: not yet implemented
+
+ return $ERR_OK
+}
+#------------------------------------------------------------------------------
+
+
+#####################
+## MAIN PROCESSING ##
+#####################
+
+command="$1"
+shift
+
+case "$command" in
+ "keymap" )
+ enchant_shell_command_keymap
+ liberror_check_fatal_error
+ ;;
+ "init" )
+ enchant_shell_command_init
+ liberror_check_fatal_error
+ ;;
+ "prompt" )
+ enchant_shell_command_prompt
+ liberror_check_fatal_error
+ ;;
+ "chroot" )
+ enchant_shell_command_chroot "$@"
+ liberror_check_fatal_error
+ ;;
+ "todo" )
+ enchant_shell_command_todo "$@"
+ liberror_check_fatal_error
+ ;;
+ "list" )
+ enchant_shell_command_list_modules "$@"
+ liberror_check_fatal_error
+ ;;
+ "next" )
+ enchant_shell_perform_next
+ liberror_check_fatal_error
+ ;;
+ "prev" )
+ enchant_shell_perform_prev
+ liberror_check_fatal_error
+ ;;
+ "jump" )
+ enchant_shell_command_jump "$@"
+ liberror_check_fatal_error
+ ;;
+ "welcome" )
+ enchant_shell_perform_welcome
+ liberror_check_fatal_error
+ ;;
+ "help" )
+ enchant_shell_command_help "$@"
+ liberror_check_fatal_error
+ ;;
+ "install" )
+ enchant_shell_command_install "$@"
+ liberror_check_fatal_error
+ ;;
+ "potion" )
+ enchant_shell_command_potion "$@"
+ liberror_check_fatal_error
+ ;;
+ * )
+ enchant_shell_command_help
+ liberror_check_fatal_error
+ ;;
+esac
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/enchantment/shell/functions b/enchantment/shell/functions
new file mode 100644
index 0000000..cf10f65
--- /dev/null
+++ b/enchantment/shell/functions
@@ -0,0 +1,343 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## These are the functions used by the SMGL shell installer.
+## Take care not to pollute the user's namespace too much,
+## and make sure your functions don't (accidentally) collide
+## with existing commands.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2010 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+# print a standardized header
+# if given a filename for an argument, it will print the contents of the file
+# after the header
+function enchant_shell_header() {
+ echo ""
+ echo ""
+ echo ""
+
+ # if arg1 supplied, cat it
+ if [[ -n "$1" ]]
+ then
+ [[ -f "$1" ]] || return $ERR_FILE_NOT_FOUND
+ cat "$1"
+ fi
+
+ return $ERR_OK
+}
+
+# output the step instructions
+# use color if libcolor loaded, else just plain bold
+function enchant_shell_instructions() {
+ local file="$1"
+ local hilight=""
+ local normal=""
+
+ [[ -f "$file" ]] || return $ERR_FILE_NOT_FOUND
+
+ if [[ "$LIBCOLOR_NOCOLOR" == "yes" ]]
+ then
+ hilight="$LIBCOLOR_NOTICE_COLOR"
+ normal="$LIBCOLOR_NORMAL_COLOR"
+ else
+ hilight="$LIBCOLOR_BOLD"
+ normal="$LIBCOLOR_NORMAL"
+ fi
+
+ # replace instances of "@[...]" with $hilight...$normal in situ
+ # the color codes have to be used directly (rather than the libcolor_
message
+ # functions) due to the in situ nature of the markup, otherwise we would
have
+ # to overly complicate the instruction printing function by printing one
line
+ # at a time
+ sed "s/@\[\([^]]*\)\]/$hilight\1$normal/g" "$file"
+
+ return $ERR_OK
+}
+
+# display module names with short descriptions in columns
+function enchant_shell_modules() {
+ local list=""
+ local module=""
+ local col_width="0"
+
+ # get the list of modules
+ list=( $(enchant_get_modules) )
+
+ [[ "${#list[*]}" -eq 0 ]] && return $ERR_MODULE_NONE
+
+ # get the width of the widest column
+ for col in ${list[*]}
+ do
+ [[ "${#col}" -gt "$col_width" ]] && col_width="${#col}"
+ done
+
+ enchant_shell_header || return $ERR_FILE_NOT_FOUND
+
+ for module in ${list[*]}
+ do
+ # pad the output to align the columns
+ while [[ "${#module}" -lt "$col_width" ]]
+ do
+ module="$module "
+ done
+
+ # output name and info in columns
+ echo "$module" | paste - "$ENCHANT_MODULES/$module/${module}.info"
+ done
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_todo() {
+ local curstep="${1:-$(enchant_get_current)}"
+
+ [[ -z "$curstep" ]] && return $ERR_GET_CURRENT
+
+ # output the header
+ enchant_shell_header || return $ERR_FILE_NOT_FOUND
+
+ # output the current module's instructions
+ enchant_shell_instructions "$ENCHANT_MODULES/$curstep/$curstep" ||
+ return $ERR_FILE_NOT_FOUND
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_next() {
+ enchant_set_next || return $ERR_SET_NEXT
+
+ todo || return $ERR_FILE_NOT_FOUND
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_prev() {
+ enchant_set_prev || return $ERR_SET_PREV
+
+ todo || return $ERR_FILE_NOT_FOUND
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_back() {
+ enchant_back || return $ERR_HISTORY_BACK
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_forward() {
+ enchant_forward || return $ERR_HISTORY_FORWARD
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_list_modules() {
+ enchant_shell_modules || return $ERR_INSTALLER_MODULES
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_jump() {
+ local rc=""
+
+ enchant_set_current $*
+ rc="$?"
+
+ if [[ "$rc" -gt 0 ]]
+ then
+ echo ""
+ libcolor_error "'$@': error: "
+ liberror_print_error "$rc"
+
+ if [[ "$rc" == $ERR_SET_CURRENT ]]
+ then
+ echo "Type $(libcolor_notice enchantment list) to see a list of steps."
+ fi
+ fi
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_welcome() {
+ enchant_shell_header || return $ERR_FILE_NOT_FOUND
+
+ enchant_shell_instructions "$ENCHANT_MODULES/welcome/welcome" ||
+ return $ERR_FILE_NOT_FOUND
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_help() {
+ helpfile="$ENCHANT_MODULES/help/${1:-index}"
+
+ if [[ ! -f "$helpfile" ]]
+ then
+ if [[ -n "$1" ]]
+ then
+ libcolor_warn "No installer help for '$1', falling back to bash's
builtin help"
+ echo ""
+ builtin help "$1"
+ fi
+ else
+ return $ERR_FILE_NOT_FOUND
+ fi
+
+ enchant_shell_header || return $ERR_FILE_NOT_FOUND
+ enchant_shell_instructions "$helpfile" ||
+ return $ERR_FILE_NOT_FOUND
+
+ return $ERR_OK
+}
+
+function enchant_shell_perform_chroot() {
+ enchant_chroot_init || return $ERR_CHROOT_INIT
+
+ # set the prompt to let the user know
+ # we are entering... the Chroot Zone
+ PS1="[inside chroot, type"
+ PS1="$PS1 $(libcolor_notice exit)"
+ PS1="$PS1 to return to installer]"
+ PS1="${PS1}\n\u \w\$ "
+ export PS1
+
+ enchant_chroot "$@" || return $ERR_CHROOT_EXEC
+
+ enchant_chroot_done || return $ERR_CHROOT_DONE
+
+ return $ERR_OK
+}
+
+function enchant_shell_keymap_list {
+ local choices=( "$@" )
+ local max="${#choices[*]}"
+ local i=""
+
+ [[ "$max" -lt 1 ]] && return $ERR_INSTALLER_KEYMAP
+
+ if [[ "$max" -gt 20 ]]
+ then
+ for ((i=0; i < "$max"; i++))
+ do
+ printf "\n[%2d] %s\n" "$(($i + 1))" "${choices[i]}"
+ done | column | more
+ else
+ for ((i=0; i < "$max"; i++))
+ do
+ printf "\n\t\t\t[%2d] %s\n" "$(($i + 1))" "${choices[i]}"
+ done | more
+ fi
+
+ return $ERR_OK
+}
+
+function enchant_shell_keymap_info() {
+ local i="0"
+
+ local msgs=(
+ "First, choose your keyboard's hardware type from the list below."
+ "Some hardware types will also have a subtype,"
+ "which will be presented in another menu."
+ "After you are done choosing your hardware type (and subtype),"
+ "choose your preferred keymapping from the menu you are presented with."
+ ""
+ "You may enter 0 to go back to a previous menu."
+ )
+
+ # print a header
+ printf "\n\t$(libcolor_notice Keymap Selection Menu)\n\n"
+
+ # print the welcome information
+ for ((i; i < "${#msgs[*]}"; i++))
+ do
+ printf "\t$(libcolor_notice ${msgs[i]})\n"
+ done
+
+ return $ERR_OK
+}
+
+function enchant_shell_keymap_prompt() {
+ # print an indented prompt
+ echo ""
+ printf "\t$(libcolor_notice Please enter a number (0 to go back, * to
exit):)"
+ echo " "
+}
+
+function enchant_shell_peform_keymap() {
+ local choices=()
+ local prefix=""
+ local rc=""
+
+ # print the initial welcome info
+ enchant_shell_keymap_info
+
+ while [[ "$rc" -ne "$ERR_KEYMAP_EXIT" ]]
+ do
+ # get the list of choices
+ choices=( "$(enchant_i18n_keymap_make_list $prefix)" )
+
+ # print the list of choices as a numbered menu
+ enchant_shell_keymap_list "${choices[@]}"
+
+ # print a prompt, with indentation
+ enchant_shell_keymap_prompt
+
+ # get user input and update the menu prefix
+ # enchant_i18n_keymap_input will automatically set the keymap if the
input
+ # is for a specific keymap rather than a directory
+ prefix="$(enchant_i18n_keymap_input $prefix ${#choices[*]})"
+ rc="$?"
+
+ # if we got bad input, just repeat the loop until we get good input
+ # but warn the user so they know what happened
+ if [[ "$rc" -ge 1 ]]
+ then
+ case "$rc" in
+ # exit is handled by the loop condition itself, so we don't need to
do
+ # anything for this one
+ "$ERR_KEYMAP_EXIT" )
+ ;;
+ # if there was a problem with the input, let the user know and
re-loop
+ "$ERR_KEYMAP_INPUT" )
+ echo "Error: You must enter a number corresponding to one"
+ echo "of the choices in the list above!"
+ ;;
+ * )
+ # return any errors which weren't explicitly handled above
+ return $rc
+ ;;
+ esac
+ fi
+ done
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/enchantment/shell/keymap b/enchantment/shell/keymap
deleted file mode 100755
index 531d824..0000000
--- a/enchantment/shell/keymap
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/bash
-
-PREFIX=/usr/share/keymaps
-CHOICES=
-MAX=
-INPUT=
-RESULT=1
-
-function prompt() {
- echo ""
- printf "\tPlease enter a number (0 to go back): "
- read INPUT
- if [[ -n $INPUT ]]
- then
- if [[ $INPUT -lt 0 || $INPUT -gt $MAX ]]
- then
- echo "Error: You must enter a number corresponding to one"
- echo "of the choices in the list above!"
- return 1
- fi
- else
- return 0
- fi
-}
-
-function make_list {
- local list
-
- #LIST=$(find $PREFIX/$LISTDIR/* -maxdepth 0 -type d -not -name include)
- list=( $(find $PREFIX/* -maxdepth 0 -type d -not -name include) )
- MAX=${#list[*]}
- if [[ $MAX = 0 ]]
- then
- #LIST=$(find $PREFIX/$LISTDIR/* -type f -name *.map.gz)
- list=( $(find $PREFIX/* -type f -name *.map.gz) )
- MAX=${#list[*]}
- fi
- for ((i=0; i < $MAX; i++))
- do
- CHOICES[$i]=${list[i]##*/}
- done
-}
-
-function print_dirs {
- echo ""
- for ((i=0; i < $MAX; i++))
- do
- printf "\t\t\t[%2d] %s\n" "$(($i + 1))" "${CHOICES[i]}"
- done | more
-}
-
-function print_files {
- echo ""
- for ((i=0; i < $MAX; i++))
- do
- #printf "[%2d] %s" "$i" "${CHOICES[i]%.map.gz}"
- #printf "%2d %s" "$i" "${CHOICES[i]%.map.gz}"
- printf "[%2d] %s\n" "$(($i + 1))" "${CHOICES[i]}"
- done | column | more
-}
-
-function print_list {
- if [[ $MAX -gt 20 ]]
- then
- print_files
- else
- print_dirs
- fi
-}
-
-function go_list {
- local rc=1
-
- make_list
- print_list
- while [[ $rc = 1 ]]
- do
- prompt
- rc="$?"
- done
- if [[ $INPUT = 0 ]]
- then
- if [[ $PREFIX != "/usr/share/keymaps" ]]
- then
- PREFIX=${PREFIX%/[^/]*}
- fi
- else
- (( INPUT -= 1 ))
- INPUT=${CHOICES[INPUT]}
- if [[ $INPUT == *.map.gz ]]
- then
- PREFIX="$PREFIX/$INPUT"
- if [[ $(loadkeys $PREFIX) ]]
- then
- # TODO: figure out what the user needs to enter in sysconfig/keymap
- echo "${prefix%.*map.*}" >/tmp/selected-keymap
- RESULT=0
- else
- RESULT=2
- fi
- else
- PREFIX="$PREFIX/$INPUT"
- fi
- fi
-}
-
-echo ""
-cat <<EOF
-Keymap selection menu.
-First, choose your keyboard's hardware type from the list below. Some
hardware
-types will also have a subtype, which will be presented in another menu.
-After you are done choosing your hardware type (and subtype), choose your
-preferred keymapping from the menu you are presented with. You may enter 0
-to go back to a previous menu.
-EOF
-
-while [[ $RESULT = "1" ]]
-do
- go_list
- #clear
-done
-
-if [[ $RESULT = "0" ]]
-then
- exit 0
-else
- exit 1
-fi
-
-#ls | sed 's/.map.gz$//' | nl -w 2 -s ' ' -nln | column | more
-
-#entries=( dummy $(echo * | sed -n 's/.k\?map\(.gz\)\?$//p') ); for((i=1;
-#i<${#entries[*]}; i++)) ;do printf "%2d %s" "$i" "${entries[i]}"; done |
-#column | more
-
-
-# vim:tabstop=2:softtabstop=2:shiftwidth=2:expandtab:ai
diff --git a/enchantment/shell/smgl-chroot b/enchantment/shell/smgl-chroot
deleted file mode 100755
index 717fcd9..0000000
--- a/enchantment/shell/smgl-chroot
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-# Note: don't use --rbind: It creates several mounts, and we wouldn't be able
-# to figure out easily what to umount.
-mount --bind /dev /mnt/root/dev &&
-mount --bind /dev/pts /mnt/root/dev/pts &&
-mount --bind /proc /mnt/root/proc &&
-export PS1="[inside chroot, type exit to return to installer]\n\u
\w\$ " &&
-chroot /mnt/root "$@"
-rc=$?
-umount /mnt/root/proc
-umount /mnt/root/dev/pts
-umount /mnt/root/dev
-
-exit $rc
-
-# vim:sw=2:ts=2:softtabstop=2:expandtab:ai
diff --git a/lib/libcolor b/lib/libcolor
index 67fc44c..6361452 100644
--- a/lib/libcolor
+++ b/lib/libcolor
@@ -15,22 +15,26 @@
##

#-------------------------------------------------------------------------------

+# initialize for color - can be overridden after libcolor is loaded
+LIBCOLOR_NOCOLOR="no"
+

#-------------------------------------------------------------------------------
# Message Color Definitions

#-------------------------------------------------------------------------------
-LIBCOLOR_NORMAL="\e[0m"
-LIBCOLOR_BOLD="\e[1m"
-LIBCOLOR_BLACK="\e[30m"
-LIBCOLOR_RED="\e[31m"
-LIBCOLOR_GREEN="\e[32m"
-LIBCOLOR_YELLOW="\e[33m"
-LIBCOLOR_BLUE="\e[34m"
-LIBCOLOR_VIOLET="\e[35m"
-LIBCOLOR_CYAN="\e[36m"
-LIBCOLOR_WHITE="\e[37m"
+LIBCOLOR_NORMAL=""
+LIBCOLOR_BOLD=""
+LIBCOLOR_BLACK=""
+LIBCOLOR_RED=""
+LIBCOLOR_GREEN=""
+LIBCOLOR_YELLOW=""
+LIBCOLOR_BLUE=""
+LIBCOLOR_VIOLET=""
+LIBCOLOR_CYAN=""
+LIBCOLOR_WHITE=""

LIBCOLOR_NORMAL_COLOR="${LIBCOLOR_NORMAL}${LIBCOLOR_WHITE}"
-LIBCOLOR_MESSAGE_COLOR="${LIBCOLOR_NORMAL}${LIBCOLOR_CYAN}"
+LIBCOLOR_NOTICE_COLOR="${LIBCOLOR_BOLD}${LIBCOLOR_BLUE}"
+LIBCOLOR_WARN_COLOR="${LIBCOLOR_NORMAL}${LIBCOLOR_CYAN}"
LIBCOLOR_ERROR_COLOR="${LIBCOLOR_BOLD}${LIBCOLOR_RED}"
LIBCOLOR_QUERY_COLOR="${LIBCOLOR_BOLD}${LIBCOLOR_YELLOW}"
LIBCOLOR_FILE_COLOR="${LIBCOLOR_BOLD}${LIBCOLOR_GREEN}"
@@ -39,13 +43,39 @@ LIBCOLOR_SYMLINK_COLOR="${LIBCOLOR_BOLD}${LIBCOLOR_CYAN}"

#-------------------------------------------------------------------------------
## @param message
##
-## Prints the given message in "message" color.
+## Prints the given message in "notice" color.
+##
+#-------------------------------------------------------------------------------
+function libcolor_notice() {
+ if [[ "LIBCOLOR_NOCOLOR" == "yes" ]]
+ then
+ echo -ne "$LIBCOLOR_BOLD"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL"
+ else
+ echo -ne "$LIBCOLOR_NOTICE_COLOR"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL_COLOR"
+ fi
+}
+
+#-------------------------------------------------------------------------------
+## @param message
+##
+## Prints the given message in "warn" color.
##

#-------------------------------------------------------------------------------
-function libcolor_message() {
- echo -n "$LIBCOLOR_MESSAGE_COLOR"
- echo -n $1
- echo -n "$LIBCOLOR_NORMAL_COLOR"
+function libcolor_warn() {
+ if [[ "LIBCOLOR_NOCOLOR" == "yes" ]]
+ then
+ echo -ne "$LIBCOLOR_BOLD"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL"
+ else
+ echo -ne "$LIBCOLOR_WARN_COLOR"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL_COLOR"
+ fi
}


#-------------------------------------------------------------------------------
@@ -55,9 +85,16 @@ function libcolor_message() {
##

#-------------------------------------------------------------------------------
function libcolor_error() {
- echo -n "$LIBCOLOR_MESSAGE_COLOR"
- echo -n $1
- echo -n "$LIBCOLOR_NORMAL_COLOR"
+ if [[ "LIBCOLOR_NOCOLOR" == "yes" ]]
+ then
+ echo -ne "$LIBCOLOR_BOLD"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL"
+ else
+ echo -ne "$LIBCOLOR_ERROR_COLOR"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL_COLOR"
+ fi
}


#-------------------------------------------------------------------------------
@@ -67,9 +104,14 @@ function libcolor_error() {
##

#-------------------------------------------------------------------------------
function libcolor_query() {
- echo -n "$LIBCOLOR_MESSAGE_COLOR"
- echo -n $1
- echo -n "$LIBCOLOR_NORMAL_COLOR"
+ if [[ "LIBCOLOR_NOCOLOR" == "yes" ]]
+ then
+ echo -n "$*"
+ else
+ echo -ne "$LIBCOLOR_QUERY_COLOR"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL_COLOR"
+ fi
}


#-------------------------------------------------------------------------------
@@ -79,9 +121,14 @@ function libcolor_query() {
##

#-------------------------------------------------------------------------------
function libcolor_file() {
- echo -n "$LIBCOLOR_MESSAGE_COLOR"
- echo -n $1
- echo -n "$LIBCOLOR_NORMAL_COLOR"
+ if [[ "LIBCOLOR_NOCOLOR" == "yes" ]]
+ then
+ echo -n "$*"
+ else
+ echo -ne "$LIBCOLOR_FILE_COLOR"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL_COLOR"
+ fi
}


#-------------------------------------------------------------------------------
@@ -91,9 +138,14 @@ function libcolor_file() {
##

#-------------------------------------------------------------------------------
function libcolor_symlink() {
- echo -n "$LIBCOLOR_MESSAGE_COLOR"
- echo -n $1
- echo -n "$LIBCOLOR_NORMAL_COLOR"
+ if [[ "LIBCOLOR_NOCOLOR" == "yes" ]]
+ then
+ echo -n "$*"
+ else
+ echo -ne "$LIBCOLOR_SYMLINK_COLOR"
+ echo -n "$*"
+ echo -ne "$LIBCOLOR_NORMAL_COLOR"
+ fi
}


#-------------------------------------------------------------------------------
diff --git a/lib/liberror b/lib/liberror
index ba535d6..b73eaeb 100755
--- a/lib/liberror
+++ b/lib/liberror
@@ -46,8 +46,8 @@ ERR_MSGS=(
## defined as a variable in an errorcodes file, e.g. $ERR_FATAL) to the given
## output stream (defaults to STDOUT) in the configured error message color.
##
-## If libcolor is sourced and the $LIBCOLOR_ variables are defined then the
-## error message will be output in color.
+## If libcolor is sourced and color is not specifically disabled, then the
error
+## message will be output in color.
##

#-------------------------------------------------------------------------------
function liberror_print_error() {
@@ -59,15 +59,28 @@ function liberror_print_error() {
output=${output:=$LIBERR_STDOUT}

# exit if $errmsg not defined
- [[ -z $errmsg ]] && return 1
+ [[ -z "$errmsg" ]] && return 1

+ # print an OK message if the "error" is 0, otherwise print an error message
if [[ "$error" == 0 ]]
then
- # print an OK message
- echo -e "${LIBCOLOR_MESSAGE_COLOR}${errmsg}${LIBCOLOR_NORMAL_COLOR}"
>&$output
+ # output using libcolor if available
+ if [[ "$(type -t libcolor_notice)" == "function" ]]
+ then
+ libcolor_notice "$errmsg" >&$output
+ echo "" >&$output
+ else
+ echo "$errmsg" >&$output
+ fi
else
- # print the error message
- echo -e "${LIBCOLOR_ERROR_COLOR}${errmsg}${LIBCOLOR_NORMAL_COLOR}"
>&$output
+ # output using libcolor if available
+ if [[ "$(type -t libcolor_error)" == "function" ]]
+ then
+ libcolor_error "$errmsg" >&$output
+ echo "" >&$output
+ else
+ echo "$errmsg" >&$output
+ fi
fi || return 1

return 0
@@ -85,7 +98,7 @@ function liberror_die() {
local error=$1

# exit if $errmsg not defined
- [[ -z $error ]] && return 1
+ [[ -z "$error" ]] && return 1

# print the corresponding error message on STDERR
liberror_print_error $error $LIBERR_STDERR



  • [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (433f786dfe715b1cdba475e905de7fa963ee5f45), Justin Boffemmyer, 03/27/2010

Archive powered by MHonArc 2.6.24.

Top of Page